Skip to content

Commit 2d3e486

Browse files
committed
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Pull KVM updates from Paolo Bonzini: "ARM: - HYP mode stub supports kexec/kdump on 32-bit - improved PMU support - virtual interrupt controller performance improvements - support for userspace virtual interrupt controller (slower, but necessary for KVM on the weird Broadcom SoCs used by the Raspberry Pi 3) MIPS: - basic support for hardware virtualization (ImgTec P5600/P6600/I6400 and Cavium Octeon III) PPC: - in-kernel acceleration for VFIO s390: - support for guests without storage keys - adapter interruption suppression x86: - usual range of nVMX improvements, notably nested EPT support for accessed and dirty bits - emulation of CPL3 CPUID faulting generic: - first part of VCPU thread request API - kvm_stat improvements" * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (227 commits) kvm: nVMX: Don't validate disabled secondary controls KVM: put back #ifndef CONFIG_S390 around kvm_vcpu_kick Revert "KVM: Support vCPU-based gfn->hva cache" tools/kvm: fix top level makefile KVM: x86: don't hold kvm->lock in KVM_SET_GSI_ROUTING KVM: Documentation: remove VM mmap documentation kvm: nVMX: Remove superfluous VMX instruction fault checks KVM: x86: fix emulation of RSM and IRET instructions KVM: mark requests that need synchronization KVM: return if kvm_vcpu_wake_up() did wake up the VCPU KVM: add explicit barrier to kvm_vcpu_kick KVM: perform a wake_up in kvm_make_all_cpus_request KVM: mark requests that do not need a wakeup KVM: remove #ifndef CONFIG_S390 around kvm_vcpu_wake_up KVM: x86: always use kvm_make_request instead of set_bit KVM: add kvm_{test,clear}_request to replace {test,clear}_bit s390: kvm: Cpu model support for msa6, msa7 and msa8 KVM: x86: remove irq disablement around KVM_SET_CLOCK/KVM_GET_CLOCK kvm: better MWAIT emulation for guests KVM: x86: virtualize cpuid faulting ...
2 parents 9c6ee01 + 2e5b0bd commit 2d3e486

150 files changed

Lines changed: 9189 additions & 3843 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Documentation/virtual/kvm/api.txt‎

Lines changed: 157 additions & 210 deletions
Large diffs are not rendered by default.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
* Internal ABI between the kernel and HYP
2+
3+
This file documents the interaction between the Linux kernel and the
4+
hypervisor layer when running Linux as a hypervisor (for example
5+
KVM). It doesn't cover the interaction of the kernel with the
6+
hypervisor when running as a guest (under Xen, KVM or any other
7+
hypervisor), or any hypervisor-specific interaction when the kernel is
8+
used as a host.
9+
10+
On arm and arm64 (without VHE), the kernel doesn't run in hypervisor
11+
mode, but still needs to interact with it, allowing a built-in
12+
hypervisor to be either installed or torn down.
13+
14+
In order to achieve this, the kernel must be booted at HYP (arm) or
15+
EL2 (arm64), allowing it to install a set of stubs before dropping to
16+
SVC/EL1. These stubs are accessible by using a 'hvc #0' instruction,
17+
and only act on individual CPUs.
18+
19+
Unless specified otherwise, any built-in hypervisor must implement
20+
these functions (see arch/arm{,64}/include/asm/virt.h):
21+
22+
* r0/x0 = HVC_SET_VECTORS
23+
r1/x1 = vectors
24+
25+
Set HVBAR/VBAR_EL2 to 'vectors' to enable a hypervisor. 'vectors'
26+
must be a physical address, and respect the alignment requirements
27+
of the architecture. Only implemented by the initial stubs, not by
28+
Linux hypervisors.
29+
30+
* r0/x0 = HVC_RESET_VECTORS
31+
32+
Turn HYP/EL2 MMU off, and reset HVBAR/VBAR_EL2 to the initials
33+
stubs' exception vector value. This effectively disables an existing
34+
hypervisor.
35+
36+
* r0/x0 = HVC_SOFT_RESTART
37+
r1/x1 = restart address
38+
x2 = x0's value when entering the next payload (arm64)
39+
x3 = x1's value when entering the next payload (arm64)
40+
x4 = x2's value when entering the next payload (arm64)
41+
42+
Mask all exceptions, disable the MMU, move the arguments into place
43+
(arm64 only), and jump to the restart address while at HYP/EL2. This
44+
hypercall is not expected to return to its caller.
45+
46+
Any other value of r0/x0 triggers a hypervisor-specific handling,
47+
which is not documented here.
48+
49+
The return value of a stub hypercall is held by r0/x0, and is 0 on
50+
success, and HVC_STUB_ERR on error. A stub hypercall is allowed to
51+
clobber any of the caller-saved registers (x0-x18 on arm64, r0-r3 and
52+
ip on arm). It is thus recommended to use a function call to perform
53+
the hypercall.

‎Documentation/virtual/kvm/devices/s390_flic.txt‎

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ FLIC provides support to
1414
- purge one pending floating I/O interrupt (KVM_DEV_FLIC_CLEAR_IO_IRQ)
1515
- enable/disable for the guest transparent async page faults
1616
- register and modify adapter interrupt sources (KVM_DEV_FLIC_ADAPTER_*)
17+
- modify AIS (adapter-interruption-suppression) mode state (KVM_DEV_FLIC_AISM)
18+
- inject adapter interrupts on a specified adapter (KVM_DEV_FLIC_AIRQ_INJECT)
1719

1820
Groups:
1921
KVM_DEV_FLIC_ENQUEUE
@@ -64,12 +66,18 @@ struct kvm_s390_io_adapter {
6466
__u8 isc;
6567
__u8 maskable;
6668
__u8 swap;
67-
__u8 pad;
69+
__u8 flags;
6870
};
6971

7072
id contains the unique id for the adapter, isc the I/O interruption subclass
71-
to use, maskable whether this adapter may be masked (interrupts turned off)
72-
and swap whether the indicators need to be byte swapped.
73+
to use, maskable whether this adapter may be masked (interrupts turned off),
74+
swap whether the indicators need to be byte swapped, and flags contains
75+
further characteristics of the adapter.
76+
Currently defined values for 'flags' are:
77+
- KVM_S390_ADAPTER_SUPPRESSIBLE: adapter is subject to AIS
78+
(adapter-interrupt-suppression) facility. This flag only has an effect if
79+
the AIS capability is enabled.
80+
Unknown flag values are ignored.
7381

7482

7583
KVM_DEV_FLIC_ADAPTER_MODIFY
@@ -101,6 +109,33 @@ struct kvm_s390_io_adapter_req {
101109
release a userspace page for the translated address specified in addr
102110
from the list of mappings
103111

112+
KVM_DEV_FLIC_AISM
113+
modify the adapter-interruption-suppression mode for a given isc if the
114+
AIS capability is enabled. Takes a kvm_s390_ais_req describing:
115+
116+
struct kvm_s390_ais_req {
117+
__u8 isc;
118+
__u16 mode;
119+
};
120+
121+
isc contains the target I/O interruption subclass, mode the target
122+
adapter-interruption-suppression mode. The following modes are
123+
currently supported:
124+
- KVM_S390_AIS_MODE_ALL: ALL-Interruptions Mode, i.e. airq injection
125+
is always allowed;
126+
- KVM_S390_AIS_MODE_SINGLE: SINGLE-Interruption Mode, i.e. airq
127+
injection is only allowed once and the following adapter interrupts
128+
will be suppressed until the mode is set again to ALL-Interruptions
129+
or SINGLE-Interruption mode.
130+
131+
KVM_DEV_FLIC_AIRQ_INJECT
132+
Inject adapter interrupts on a specified adapter.
133+
attr->attr contains the unique id for the adapter, which allows for
134+
adapter-specific checks and actions.
135+
For adapters subject to AIS, handle the airq injection suppression for
136+
an isc according to the adapter-interruption-suppression mode on condition
137+
that the AIS capability is enabled.
138+
104139
Note: The KVM_SET_DEVICE_ATTR/KVM_GET_DEVICE_ATTR device ioctls executed on
105140
FLIC with an unknown group or attribute gives the error code EINVAL (instead of
106141
ENXIO, as specified in the API documentation). It is not possible to conclude

‎Documentation/virtual/kvm/devices/vfio.txt‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,21 @@ Groups:
1616

1717
KVM_DEV_VFIO_GROUP attributes:
1818
KVM_DEV_VFIO_GROUP_ADD: Add a VFIO group to VFIO-KVM device tracking
19+
kvm_device_attr.addr points to an int32_t file descriptor
20+
for the VFIO group.
1921
KVM_DEV_VFIO_GROUP_DEL: Remove a VFIO group from VFIO-KVM device tracking
22+
kvm_device_attr.addr points to an int32_t file descriptor
23+
for the VFIO group.
24+
KVM_DEV_VFIO_GROUP_SET_SPAPR_TCE: attaches a guest visible TCE table
25+
allocated by sPAPR KVM.
26+
kvm_device_attr.addr points to a struct:
2027

21-
For each, kvm_device_attr.addr points to an int32_t file descriptor
22-
for the VFIO group.
28+
struct kvm_vfio_spapr_tce {
29+
__s32 groupfd;
30+
__s32 tablefd;
31+
};
32+
33+
where
34+
@groupfd is a file descriptor for a VFIO group;
35+
@tablefd is a file descriptor for a TCE table allocated via
36+
KVM_CREATE_SPAPR_TCE.

‎Documentation/virtual/kvm/devices/vm.txt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ struct kvm_s390_vm_cpu_subfunc {
140140
u8 kmo[16]; # valid with Message-Security-Assist-Extension 4
141141
u8 pcc[16]; # valid with Message-Security-Assist-Extension 4
142142
u8 ppno[16]; # valid with Message-Security-Assist-Extension 5
143-
u8 reserved[1824]; # reserved for future instructions
143+
u8 kma[16]; # valid with Message-Security-Assist-Extension 8
144+
u8 reserved[1808]; # reserved for future instructions
144145
};
145146

146147
Parameters: address of a buffer to load the subfunction blocks from.

‎Documentation/virtual/kvm/hypercalls.txt‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ S390:
2828
property inside the device tree's /hypervisor node.
2929
For more information refer to Documentation/virtual/kvm/ppc-pv.txt
3030

31+
MIPS:
32+
KVM hypercalls use the HYPCALL instruction with code 0 and the hypercall
33+
number in $2 (v0). Up to four arguments may be placed in $4-$7 (a0-a3) and
34+
the return value is placed in $2 (v0).
35+
3136
KVM Hypercalls Documentation
3237
===========================
3338
The template for each hypercall is:

‎arch/arm/boot/compressed/head.S‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,17 @@ dtb_check_done:
422422
cmp r0, #HYP_MODE
423423
bne 1f
424424

425-
bl __hyp_get_vectors
425+
/*
426+
* Compute the address of the hyp vectors after relocation.
427+
* This requires some arithmetic since we cannot directly
428+
* reference __hyp_stub_vectors in a PC-relative way.
429+
* Call __hyp_set_vectors with the new address so that we
430+
* can HVC again after the copy.
431+
*/
432+
0: adr r0, 0b
433+
movw r1, #:lower16:__hyp_stub_vectors - 0b
434+
movt r1, #:upper16:__hyp_stub_vectors - 0b
435+
add r0, r0, r1
426436
sub r0, r0, r5
427437
add r0, r0, r10
428438
bl __hyp_set_vectors

‎arch/arm/include/asm/kvm_asm.h‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#define ARM_EXCEPTION_IRQ 5
3434
#define ARM_EXCEPTION_FIQ 6
3535
#define ARM_EXCEPTION_HVC 7
36-
36+
#define ARM_EXCEPTION_HYP_GONE HVC_STUB_ERR
3737
/*
3838
* The rr_lo_hi macro swaps a pair of registers depending on
3939
* current endianness. It is used in conjunction with ldrd and strd
@@ -72,10 +72,11 @@ extern int __kvm_vcpu_run(struct kvm_vcpu *vcpu);
7272

7373
extern void __init_stage2_translation(void);
7474

75-
extern void __kvm_hyp_reset(unsigned long);
76-
7775
extern u64 __vgic_v3_get_ich_vtr_el2(void);
76+
extern u64 __vgic_v3_read_vmcr(void);
77+
extern void __vgic_v3_write_vmcr(u32 vmcr);
7878
extern void __vgic_v3_init_lrs(void);
79+
7980
#endif
8081

8182
#endif /* __ARM_KVM_ASM_H__ */

‎arch/arm/include/asm/kvm_host.h‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#define __KVM_HAVE_ARCH_INTC_INITIALIZED
3131

3232
#define KVM_USER_MEM_SLOTS 32
33-
#define KVM_COALESCED_MMIO_PAGE_OFFSET 1
3433
#define KVM_HAVE_ONE_REG
3534
#define KVM_HALT_POLL_NS_DEFAULT 500000
3635

@@ -45,7 +44,7 @@
4544
#define KVM_MAX_VCPUS VGIC_V2_MAX_CPUS
4645
#endif
4746

48-
#define KVM_REQ_VCPU_EXIT 8
47+
#define KVM_REQ_VCPU_EXIT (8 | KVM_REQUEST_WAIT | KVM_REQUEST_NO_WAKEUP)
4948

5049
u32 *kvm_vcpu_reg(struct kvm_vcpu *vcpu, u8 reg_num, u32 mode);
5150
int __attribute_const__ kvm_target_cpu(void);
@@ -270,12 +269,6 @@ static inline void __cpu_init_stage2(void)
270269
kvm_call_hyp(__init_stage2_translation);
271270
}
272271

273-
static inline void __cpu_reset_hyp_mode(unsigned long vector_ptr,
274-
phys_addr_t phys_idmap_start)
275-
{
276-
kvm_call_hyp((void *)virt_to_idmap(__kvm_hyp_reset), vector_ptr);
277-
}
278-
279272
static inline int kvm_arch_dev_ioctl_check_extension(struct kvm *kvm, long ext)
280273
{
281274
return 0;

‎arch/arm/include/asm/kvm_mmu.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ void kvm_mmu_free_memory_caches(struct kvm_vcpu *vcpu);
5656

5757
phys_addr_t kvm_mmu_get_httbr(void);
5858
phys_addr_t kvm_get_idmap_vector(void);
59-
phys_addr_t kvm_get_idmap_start(void);
6059
int kvm_mmu_init(void);
6160
void kvm_clear_hyp_idmap(void);
6261

0 commit comments

Comments
 (0)