Skip to content

Commit 89f8833

Browse files
committed
Merge tag 'kvm-3.9-1' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Pull KVM updates from Marcelo Tosatti: "KVM updates for the 3.9 merge window, including x86 real mode emulation fixes, stronger memory slot interface restrictions, mmu_lock spinlock hold time reduction, improved handling of large page faults on shadow, initial APICv HW acceleration support, s390 channel IO based virtio, amongst others" * tag 'kvm-3.9-1' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (143 commits) Revert "KVM: MMU: lazily drop large spte" x86: pvclock kvm: align allocation size to page size KVM: nVMX: Remove redundant get_vmcs12 from nested_vmx_exit_handled_msr x86 emulator: fix parity calculation for AAD instruction KVM: PPC: BookE: Handle alignment interrupts booke: Added DBCR4 SPR number KVM: PPC: booke: Allow multiple exception types KVM: PPC: booke: use vcpu reference from thread_struct KVM: Remove user_alloc from struct kvm_memory_slot KVM: VMX: disable apicv by default KVM: s390: Fix handling of iscs. KVM: MMU: cleanup __direct_map KVM: MMU: remove pt_access in mmu_set_spte KVM: MMU: cleanup mapping-level KVM: MMU: lazily drop large spte KVM: VMX: cleanup vmx_set_cr0(). KVM: VMX: add missing exit names to VMX_EXIT_REASONS array KVM: VMX: disable SMEP feature when guest is in non-paging mode KVM: Remove duplicate text in api.txt Revert "KVM: MMU: split kvm_mmu_free_page" ...
2 parents 9e2d59a + 6b73a96 commit 89f8833

65 files changed

Lines changed: 4359 additions & 1671 deletions

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: 85 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -219,19 +219,6 @@ allocation of vcpu ids. For example, if userspace wants
219219
single-threaded guest vcpus, it should make all vcpu ids be a multiple
220220
of the number of vcpus per vcore.
221221

222-
On powerpc using book3s_hv mode, the vcpus are mapped onto virtual
223-
threads in one or more virtual CPU cores. (This is because the
224-
hardware requires all the hardware threads in a CPU core to be in the
225-
same partition.) The KVM_CAP_PPC_SMT capability indicates the number
226-
of vcpus per virtual core (vcore). The vcore id is obtained by
227-
dividing the vcpu id by the number of vcpus per vcore. The vcpus in a
228-
given vcore will always be in the same physical core as each other
229-
(though that might be a different physical core from time to time).
230-
Userspace can control the threading (SMT) mode of the guest by its
231-
allocation of vcpu ids. For example, if userspace wants
232-
single-threaded guest vcpus, it should make all vcpu ids be a multiple
233-
of the number of vcpus per vcore.
234-
235222
For virtual cpus that have been created with S390 user controlled virtual
236223
machines, the resulting vcpu fd can be memory mapped at page offset
237224
KVM_S390_SIE_PAGE_OFFSET in order to obtain a memory map of the virtual
@@ -345,7 +332,7 @@ struct kvm_sregs {
345332
__u64 interrupt_bitmap[(KVM_NR_INTERRUPTS + 63) / 64];
346333
};
347334

348-
/* ppc -- see arch/powerpc/include/asm/kvm.h */
335+
/* ppc -- see arch/powerpc/include/uapi/asm/kvm.h */
349336

350337
interrupt_bitmap is a bitmap of pending external interrupts. At most
351338
one bit may be set. This interrupt has been acknowledged by the APIC
@@ -892,12 +879,12 @@ It is recommended that the lower 21 bits of guest_phys_addr and userspace_addr
892879
be identical. This allows large pages in the guest to be backed by large
893880
pages in the host.
894881

895-
The flags field supports two flag, KVM_MEM_LOG_DIRTY_PAGES, which instructs
896-
kvm to keep track of writes to memory within the slot. See KVM_GET_DIRTY_LOG
897-
ioctl. The KVM_CAP_READONLY_MEM capability indicates the availability of the
898-
KVM_MEM_READONLY flag. When this flag is set for a memory region, KVM only
899-
allows read accesses. Writes will be posted to userspace as KVM_EXIT_MMIO
900-
exits.
882+
The flags field supports two flags: KVM_MEM_LOG_DIRTY_PAGES and
883+
KVM_MEM_READONLY. The former can be set to instruct KVM to keep track of
884+
writes to memory within the slot. See KVM_GET_DIRTY_LOG ioctl to know how to
885+
use it. The latter can be set, if KVM_CAP_READONLY_MEM capability allows it,
886+
to make a new slot read-only. In this case, writes to this memory will be
887+
posted to userspace as KVM_EXIT_MMIO exits.
901888

902889
When the KVM_CAP_SYNC_MMU capability is available, changes in the backing of
903890
the memory region are automatically reflected into the guest. For example, an
@@ -931,7 +918,7 @@ documentation when it pops into existence).
931918
4.37 KVM_ENABLE_CAP
932919

933920
Capability: KVM_CAP_ENABLE_CAP
934-
Architectures: ppc
921+
Architectures: ppc, s390
935922
Type: vcpu ioctl
936923
Parameters: struct kvm_enable_cap (in)
937924
Returns: 0 on success; -1 on error
@@ -1792,6 +1779,7 @@ registers, find a list below:
17921779
PPC | KVM_REG_PPC_VPA_SLB | 128
17931780
PPC | KVM_REG_PPC_VPA_DTL | 128
17941781
PPC | KVM_REG_PPC_EPCR | 32
1782+
PPC | KVM_REG_PPC_EPR | 32
17951783

17961784
ARM registers are mapped using the lower 32 bits. The upper 16 of that
17971785
is the register group type, or coprocessor number:
@@ -2108,6 +2096,14 @@ KVM_S390_INT_VIRTIO (vm) - virtio external interrupt; external interrupt
21082096
KVM_S390_INT_SERVICE (vm) - sclp external interrupt; sclp parameter in parm
21092097
KVM_S390_INT_EMERGENCY (vcpu) - sigp emergency; source cpu in parm
21102098
KVM_S390_INT_EXTERNAL_CALL (vcpu) - sigp external call; source cpu in parm
2099+
KVM_S390_INT_IO(ai,cssid,ssid,schid) (vm) - compound value to indicate an
2100+
I/O interrupt (ai - adapter interrupt; cssid,ssid,schid - subchannel);
2101+
I/O interruption parameters in parm (subchannel) and parm64 (intparm,
2102+
interruption subclass)
2103+
KVM_S390_MCHK (vm, vcpu) - machine check interrupt; cr 14 bits in parm,
2104+
machine check interrupt code in parm64 (note that
2105+
machine checks needing further payload are not
2106+
supported by this ioctl)
21112107

21122108
Note that the vcpu ioctl is asynchronous to vcpu execution.
21132109

@@ -2359,8 +2355,8 @@ executed a memory-mapped I/O instruction which could not be satisfied
23592355
by kvm. The 'data' member contains the written data if 'is_write' is
23602356
true, and should be filled by application code otherwise.
23612357

2362-
NOTE: For KVM_EXIT_IO, KVM_EXIT_MMIO, KVM_EXIT_OSI, KVM_EXIT_DCR
2363-
and KVM_EXIT_PAPR the corresponding
2358+
NOTE: For KVM_EXIT_IO, KVM_EXIT_MMIO, KVM_EXIT_OSI, KVM_EXIT_DCR,
2359+
KVM_EXIT_PAPR and KVM_EXIT_EPR the corresponding
23642360
operations are complete (and guest state is consistent) only after userspace
23652361
has re-entered the kernel with KVM_RUN. The kernel side will first finish
23662362
incomplete operations and then check for pending signals. Userspace
@@ -2463,6 +2459,41 @@ The possible hypercalls are defined in the Power Architecture Platform
24632459
Requirements (PAPR) document available from www.power.org (free
24642460
developer registration required to access it).
24652461

2462+
/* KVM_EXIT_S390_TSCH */
2463+
struct {
2464+
__u16 subchannel_id;
2465+
__u16 subchannel_nr;
2466+
__u32 io_int_parm;
2467+
__u32 io_int_word;
2468+
__u32 ipb;
2469+
__u8 dequeued;
2470+
} s390_tsch;
2471+
2472+
s390 specific. This exit occurs when KVM_CAP_S390_CSS_SUPPORT has been enabled
2473+
and TEST SUBCHANNEL was intercepted. If dequeued is set, a pending I/O
2474+
interrupt for the target subchannel has been dequeued and subchannel_id,
2475+
subchannel_nr, io_int_parm and io_int_word contain the parameters for that
2476+
interrupt. ipb is needed for instruction parameter decoding.
2477+
2478+
/* KVM_EXIT_EPR */
2479+
struct {
2480+
__u32 epr;
2481+
} epr;
2482+
2483+
On FSL BookE PowerPC chips, the interrupt controller has a fast patch
2484+
interrupt acknowledge path to the core. When the core successfully
2485+
delivers an interrupt, it automatically populates the EPR register with
2486+
the interrupt vector number and acknowledges the interrupt inside
2487+
the interrupt controller.
2488+
2489+
In case the interrupt controller lives in user space, we need to do
2490+
the interrupt acknowledge cycle through it to fetch the next to be
2491+
delivered interrupt vector using this exit.
2492+
2493+
It gets triggered whenever both KVM_CAP_PPC_EPR are enabled and an
2494+
external interrupt has just been delivered into the guest. User space
2495+
should put the acknowledged interrupt vector into the 'epr' field.
2496+
24662497
/* Fix the size of the union. */
24672498
char padding[256];
24682499
};
@@ -2584,3 +2615,34 @@ For mmu types KVM_MMU_FSL_BOOKE_NOHV and KVM_MMU_FSL_BOOKE_HV:
25842615
where "num_sets" is the tlb_sizes[] value divided by the tlb_ways[] value.
25852616
- The tsize field of mas1 shall be set to 4K on TLB0, even though the
25862617
hardware ignores this value for TLB0.
2618+
2619+
6.4 KVM_CAP_S390_CSS_SUPPORT
2620+
2621+
Architectures: s390
2622+
Parameters: none
2623+
Returns: 0 on success; -1 on error
2624+
2625+
This capability enables support for handling of channel I/O instructions.
2626+
2627+
TEST PENDING INTERRUPTION and the interrupt portion of TEST SUBCHANNEL are
2628+
handled in-kernel, while the other I/O instructions are passed to userspace.
2629+
2630+
When this capability is enabled, KVM_EXIT_S390_TSCH will occur on TEST
2631+
SUBCHANNEL intercepts.
2632+
2633+
6.5 KVM_CAP_PPC_EPR
2634+
2635+
Architectures: ppc
2636+
Parameters: args[0] defines whether the proxy facility is active
2637+
Returns: 0 on success; -1 on error
2638+
2639+
This capability enables or disables the delivery of interrupts through the
2640+
external proxy facility.
2641+
2642+
When enabled (args[0] != 0), every time the guest gets an external interrupt
2643+
delivered, it automatically exits into user space with a KVM_EXIT_EPR exit
2644+
to receive the topmost interrupt vector.
2645+
2646+
When disabled (args[0] == 0), behavior is as if this facility is unsupported.
2647+
2648+
When this capability is enabled, KVM_EXIT_EPR can occur.

‎Documentation/virtual/kvm/mmu.txt‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,6 @@ Shadow pages contain the following information:
187187
perform a reverse map from a pte to a gfn. When role.direct is set, any
188188
element of this array can be calculated from the gfn field when used, in
189189
this case, the array of gfns is not allocated. See role.direct and gfn.
190-
slot_bitmap:
191-
A bitmap containing one bit per memory slot. If the page contains a pte
192-
mapping a page from memory slot n, then bit n of slot_bitmap will be set
193-
(if a page is aliased among several slots, then it is not guaranteed that
194-
all slots will be marked).
195-
Used during dirty logging to avoid scanning a shadow page if none if its
196-
pages need tracking.
197190
root_count:
198191
A counter keeping track of how many hardware registers (guest cr3 or
199192
pdptrs) are now pointing at the page. While this counter is nonzero, the

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@
2323
#ifndef __ASM_KVM_HOST_H
2424
#define __ASM_KVM_HOST_H
2525

26-
#define KVM_MEMORY_SLOTS 32
27-
/* memory slots that does not exposed to userspace */
28-
#define KVM_PRIVATE_MEM_SLOTS 4
26+
#define KVM_USER_MEM_SLOTS 32
2927

3028
#define KVM_COALESCED_MMIO_PAGE_OFFSET 1
3129

‎arch/ia64/kvm/kvm-ia64.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ long kvm_arch_vm_ioctl(struct file *filp,
955955
kvm_mem.guest_phys_addr;
956956
kvm_userspace_mem.memory_size = kvm_mem.memory_size;
957957
r = kvm_vm_ioctl_set_memory_region(kvm,
958-
&kvm_userspace_mem, 0);
958+
&kvm_userspace_mem, false);
959959
if (r)
960960
goto out;
961961
break;
@@ -1580,7 +1580,7 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm,
15801580
struct kvm_memory_slot *memslot,
15811581
struct kvm_memory_slot old,
15821582
struct kvm_userspace_memory_region *mem,
1583-
int user_alloc)
1583+
bool user_alloc)
15841584
{
15851585
unsigned long i;
15861586
unsigned long pfn;
@@ -1611,7 +1611,7 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm,
16111611
void kvm_arch_commit_memory_region(struct kvm *kvm,
16121612
struct kvm_userspace_memory_region *mem,
16131613
struct kvm_memory_slot old,
1614-
int user_alloc)
1614+
bool user_alloc)
16151615
{
16161616
return;
16171617
}
@@ -1834,7 +1834,7 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
18341834
mutex_lock(&kvm->slots_lock);
18351835

18361836
r = -EINVAL;
1837-
if (log->slot >= KVM_MEMORY_SLOTS)
1837+
if (log->slot >= KVM_USER_MEM_SLOTS)
18381838
goto out;
18391839

18401840
memslot = id_to_memslot(kvm->memslots, log->slot);

‎arch/ia64/kvm/lapic.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,10 @@ int kvm_apic_set_irq(struct kvm_vcpu *vcpu, struct kvm_lapic_irq *irq);
2727
#define kvm_apic_present(x) (true)
2828
#define kvm_lapic_enabled(x) (true)
2929

30+
static inline bool kvm_apic_vid_enabled(void)
31+
{
32+
/* IA64 has no apicv supporting, do nothing here */
33+
return false;
34+
}
35+
3036
#endif

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@
3737

3838
#define KVM_MAX_VCPUS NR_CPUS
3939
#define KVM_MAX_VCORES NR_CPUS
40-
#define KVM_MEMORY_SLOTS 32
41-
/* memory slots that does not exposed to userspace */
42-
#define KVM_PRIVATE_MEM_SLOTS 4
43-
#define KVM_MEM_SLOTS_NUM (KVM_MEMORY_SLOTS + KVM_PRIVATE_MEM_SLOTS)
40+
#define KVM_USER_MEM_SLOTS 32
41+
#define KVM_MEM_SLOTS_NUM KVM_USER_MEM_SLOTS
4442

4543
#ifdef CONFIG_KVM_MMIO
4644
#define KVM_COALESCED_MMIO_PAGE_OFFSET 1
@@ -523,6 +521,8 @@ struct kvm_vcpu_arch {
523521
u8 sane;
524522
u8 cpu_type;
525523
u8 hcall_needed;
524+
u8 epr_enabled;
525+
u8 epr_needed;
526526

527527
u32 cpr0_cfgaddr; /* holds the last set cpr0_cfgaddr */
528528

‎arch/powerpc/include/asm/kvm_ppc.h‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,11 @@ enum emulation_result {
4444
EMULATE_DO_DCR, /* kvm_run filled with DCR request */
4545
EMULATE_FAIL, /* can't emulate this instruction */
4646
EMULATE_AGAIN, /* something went wrong. go again */
47+
EMULATE_DO_PAPR, /* kvm_run filled with PAPR request */
4748
};
4849

4950
extern int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu);
5051
extern int __kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu);
51-
extern char kvmppc_handlers_start[];
52-
extern unsigned long kvmppc_handler_len;
5352
extern void kvmppc_handler_highmem(void);
5453

5554
extern void kvmppc_dump_vcpu(struct kvm_vcpu *vcpu);
@@ -263,6 +262,15 @@ static inline void kvm_linear_init(void)
263262
{}
264263
#endif
265264

265+
static inline void kvmppc_set_epr(struct kvm_vcpu *vcpu, u32 epr)
266+
{
267+
#ifdef CONFIG_KVM_BOOKE_HV
268+
mtspr(SPRN_GEPR, epr);
269+
#elif defined(CONFIG_BOOKE)
270+
vcpu->arch.epr = epr;
271+
#endif
272+
}
273+
266274
int kvm_vcpu_ioctl_config_tlb(struct kvm_vcpu *vcpu,
267275
struct kvm_config_tlb *cfg);
268276
int kvm_vcpu_ioctl_dirty_tlb(struct kvm_vcpu *vcpu,

‎arch/powerpc/include/asm/reg.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -956,8 +956,6 @@
956956
#define SPRN_SPRG_RSCRATCH_DBG SPRN_SPRG9
957957
#define SPRN_SPRG_WSCRATCH_DBG SPRN_SPRG9
958958
#endif
959-
#define SPRN_SPRG_RVCPU SPRN_SPRG1
960-
#define SPRN_SPRG_WVCPU SPRN_SPRG1
961959
#endif
962960

963961
#ifdef CONFIG_8xx

‎arch/powerpc/include/asm/reg_booke.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
#define SPRN_SPRG7W 0x117 /* Special Purpose Register General 7 Write */
5757
#define SPRN_EPCR 0x133 /* Embedded Processor Control Register */
5858
#define SPRN_DBCR2 0x136 /* Debug Control Register 2 */
59+
#define SPRN_DBCR4 0x233 /* Debug Control Register 4 */
5960
#define SPRN_MSRP 0x137 /* MSR Protect Register */
6061
#define SPRN_IAC3 0x13A /* Instruction Address Compare 3 */
6162
#define SPRN_IAC4 0x13B /* Instruction Address Compare 4 */

‎arch/powerpc/include/uapi/asm/kvm.h‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ struct kvm_regs {
114114
/* Embedded Floating Point (SPE) -- IVOR32-34 if KVM_SREGS_E_IVOR */
115115
#define KVM_SREGS_E_SPE (1 << 9)
116116

117-
/* External Proxy (EXP) -- EPR */
117+
/*
118+
* DEPRECATED! USE ONE_REG FOR THIS ONE!
119+
* External Proxy (EXP) -- EPR
120+
*/
118121
#define KVM_SREGS_EXP (1 << 10)
119122

120123
/* External PID (E.PD) -- EPSC/EPLC */
@@ -412,5 +415,6 @@ struct kvm_get_htab_header {
412415
#define KVM_REG_PPC_VPA_DTL (KVM_REG_PPC | KVM_REG_SIZE_U128 | 0x84)
413416

414417
#define KVM_REG_PPC_EPCR (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x85)
418+
#define KVM_REG_PPC_EPR (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x86)
415419

416420
#endif /* __LINUX_KVM_POWERPC_H */

0 commit comments

Comments
 (0)