Skip to content

Commit 63623fd

Browse files
committed
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Pull kvm fixes from Paolo Bonzini: "Bugfixes, including the fix for CVE-2020-2732 and a few issues found by 'make W=1'" * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: KVM: s390: rstify new ioctls in api.rst KVM: nVMX: Check IO instruction VM-exit conditions KVM: nVMX: Refactor IO bitmap checks into helper function KVM: nVMX: Don't emulate instructions in guest mode KVM: nVMX: Emulate MTF when performing instruction emulation KVM: fix error handling in svm_hardware_setup KVM: SVM: Fix potential memory leak in svm_cpu_init() KVM: apic: avoid calculating pending eoi from an uninitialized val KVM: nVMX: clear PIN_BASED_POSTED_INTR from nested pinbased_ctls only when apicv is globally disabled KVM: nVMX: handle nested posted interrupts when apicv is disabled for L1 kvm: x86: svm: Fix NULL pointer dereference when AVIC not enabled KVM: VMX: Add VMX_FEATURE_USR_WAIT_PAUSE KVM: nVMX: Hold KVM's srcu lock when syncing vmcs12->shadow KVM: x86: don't notify userspace IOAPIC on edge-triggered interrupt EOI kvm/emulate: fix a -Werror=cast-function-type KVM: x86: fix incorrect comparison in trace event KVM: nVMX: Fix some obsolete comments and grammar error KVM: x86: fix missing prototypes KVM: x86: enable -Werror
2 parents 7031ecf + a93236f commit 63623fd

File tree

19 files changed

+284
-121
lines changed

19 files changed

+284
-121
lines changed

Documentation/virt/kvm/api.rst

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4611,35 +4611,38 @@ unpins the VPA pages and releases all the device pages that are used to
46114611
track the secure pages by hypervisor.
46124612

46134613
4.122 KVM_S390_NORMAL_RESET
4614+
---------------------------
46144615

4615-
Capability: KVM_CAP_S390_VCPU_RESETS
4616-
Architectures: s390
4617-
Type: vcpu ioctl
4618-
Parameters: none
4619-
Returns: 0
4616+
:Capability: KVM_CAP_S390_VCPU_RESETS
4617+
:Architectures: s390
4618+
:Type: vcpu ioctl
4619+
:Parameters: none
4620+
:Returns: 0
46204621

46214622
This ioctl resets VCPU registers and control structures according to
46224623
the cpu reset definition in the POP (Principles Of Operation).
46234624

46244625
4.123 KVM_S390_INITIAL_RESET
4626+
----------------------------
46254627

4626-
Capability: none
4627-
Architectures: s390
4628-
Type: vcpu ioctl
4629-
Parameters: none
4630-
Returns: 0
4628+
:Capability: none
4629+
:Architectures: s390
4630+
:Type: vcpu ioctl
4631+
:Parameters: none
4632+
:Returns: 0
46314633

46324634
This ioctl resets VCPU registers and control structures according to
46334635
the initial cpu reset definition in the POP. However, the cpu is not
46344636
put into ESA mode. This reset is a superset of the normal reset.
46354637

46364638
4.124 KVM_S390_CLEAR_RESET
4639+
--------------------------
46374640

4638-
Capability: KVM_CAP_S390_VCPU_RESETS
4639-
Architectures: s390
4640-
Type: vcpu ioctl
4641-
Parameters: none
4642-
Returns: 0
4641+
:Capability: KVM_CAP_S390_VCPU_RESETS
4642+
:Architectures: s390
4643+
:Type: vcpu ioctl
4644+
:Parameters: none
4645+
:Returns: 0
46434646

46444647
This ioctl resets VCPU registers and control structures according to
46454648
the clear cpu reset definition in the POP. However, the cpu is not put

arch/x86/include/asm/kvm_emulate.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,14 @@ enum x86emul_mode {
292292
#define X86EMUL_SMM_MASK (1 << 6)
293293
#define X86EMUL_SMM_INSIDE_NMI_MASK (1 << 7)
294294

295+
/*
296+
* fastop functions are declared as taking a never-defined fastop parameter,
297+
* so they can't be called from C directly.
298+
*/
299+
struct fastop;
300+
301+
typedef void (*fastop_t)(struct fastop *);
302+
295303
struct x86_emulate_ctxt {
296304
const struct x86_emulate_ops *ops;
297305

@@ -324,7 +332,10 @@ struct x86_emulate_ctxt {
324332
struct operand src;
325333
struct operand src2;
326334
struct operand dst;
327-
int (*execute)(struct x86_emulate_ctxt *ctxt);
335+
union {
336+
int (*execute)(struct x86_emulate_ctxt *ctxt);
337+
fastop_t fop;
338+
};
328339
int (*check_perm)(struct x86_emulate_ctxt *ctxt);
329340
/*
330341
* The following six fields are cleared together,

arch/x86/include/asm/kvm_host.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1122,6 +1122,7 @@ struct kvm_x86_ops {
11221122
int (*handle_exit)(struct kvm_vcpu *vcpu,
11231123
enum exit_fastpath_completion exit_fastpath);
11241124
int (*skip_emulated_instruction)(struct kvm_vcpu *vcpu);
1125+
void (*update_emulated_instruction)(struct kvm_vcpu *vcpu);
11251126
void (*set_interrupt_shadow)(struct kvm_vcpu *vcpu, int mask);
11261127
u32 (*get_interrupt_shadow)(struct kvm_vcpu *vcpu);
11271128
void (*patch_hypercall)(struct kvm_vcpu *vcpu,
@@ -1146,7 +1147,7 @@ struct kvm_x86_ops {
11461147
void (*load_eoi_exitmap)(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap);
11471148
void (*set_virtual_apic_mode)(struct kvm_vcpu *vcpu);
11481149
void (*set_apic_access_page_addr)(struct kvm_vcpu *vcpu, hpa_t hpa);
1149-
void (*deliver_posted_interrupt)(struct kvm_vcpu *vcpu, int vector);
1150+
int (*deliver_posted_interrupt)(struct kvm_vcpu *vcpu, int vector);
11501151
int (*sync_pir_to_irr)(struct kvm_vcpu *vcpu);
11511152
int (*set_tss_addr)(struct kvm *kvm, unsigned int addr);
11521153
int (*set_identity_map_addr)(struct kvm *kvm, u64 ident_addr);

arch/x86/include/asm/vmx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
#define SECONDARY_EXEC_MODE_BASED_EPT_EXEC VMCS_CONTROL_BIT(MODE_BASED_EPT_EXEC)
7373
#define SECONDARY_EXEC_PT_USE_GPA VMCS_CONTROL_BIT(PT_USE_GPA)
7474
#define SECONDARY_EXEC_TSC_SCALING VMCS_CONTROL_BIT(TSC_SCALING)
75-
#define SECONDARY_EXEC_ENABLE_USR_WAIT_PAUSE 0x04000000
75+
#define SECONDARY_EXEC_ENABLE_USR_WAIT_PAUSE VMCS_CONTROL_BIT(USR_WAIT_PAUSE)
7676

7777
#define PIN_BASED_EXT_INTR_MASK VMCS_CONTROL_BIT(INTR_EXITING)
7878
#define PIN_BASED_NMI_EXITING VMCS_CONTROL_BIT(NMI_EXITING)

arch/x86/include/asm/vmxfeatures.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
#define VMX_FEATURE_MODE_BASED_EPT_EXEC ( 2*32+ 22) /* "ept_mode_based_exec" Enable separate EPT EXEC bits for supervisor vs. user */
8282
#define VMX_FEATURE_PT_USE_GPA ( 2*32+ 24) /* "" Processor Trace logs GPAs */
8383
#define VMX_FEATURE_TSC_SCALING ( 2*32+ 25) /* Scale hardware TSC when read in guest */
84+
#define VMX_FEATURE_USR_WAIT_PAUSE ( 2*32+ 26) /* Enable TPAUSE, UMONITOR, UMWAIT in guest */
8485
#define VMX_FEATURE_ENCLV_EXITING ( 2*32+ 28) /* "" VM-Exit on ENCLV (leaf dependent) */
8586

8687
#endif /* _ASM_X86_VMXFEATURES_H */

arch/x86/include/uapi/asm/kvm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ struct kvm_sync_regs {
390390
#define KVM_STATE_NESTED_GUEST_MODE 0x00000001
391391
#define KVM_STATE_NESTED_RUN_PENDING 0x00000002
392392
#define KVM_STATE_NESTED_EVMCS 0x00000004
393+
#define KVM_STATE_NESTED_MTF_PENDING 0x00000008
393394

394395
#define KVM_STATE_NESTED_SMM_GUEST_MODE 0x00000001
395396
#define KVM_STATE_NESTED_SMM_VMXON 0x00000002

arch/x86/kvm/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0
22

33
ccflags-y += -Iarch/x86/kvm
4+
ccflags-y += -Werror
45

56
KVM := ../../../virt/kvm
67

arch/x86/kvm/emulate.c

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -191,25 +191,6 @@
191191
#define NR_FASTOP (ilog2(sizeof(ulong)) + 1)
192192
#define FASTOP_SIZE 8
193193

194-
/*
195-
* fastop functions have a special calling convention:
196-
*
197-
* dst: rax (in/out)
198-
* src: rdx (in/out)
199-
* src2: rcx (in)
200-
* flags: rflags (in/out)
201-
* ex: rsi (in:fastop pointer, out:zero if exception)
202-
*
203-
* Moreover, they are all exactly FASTOP_SIZE bytes long, so functions for
204-
* different operand sizes can be reached by calculation, rather than a jump
205-
* table (which would be bigger than the code).
206-
*
207-
* fastop functions are declared as taking a never-defined fastop parameter,
208-
* so they can't be called from C directly.
209-
*/
210-
211-
struct fastop;
212-
213194
struct opcode {
214195
u64 flags : 56;
215196
u64 intercept : 8;
@@ -311,8 +292,19 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
311292
#define ON64(x)
312293
#endif
313294

314-
typedef void (*fastop_t)(struct fastop *);
315-
295+
/*
296+
* fastop functions have a special calling convention:
297+
*
298+
* dst: rax (in/out)
299+
* src: rdx (in/out)
300+
* src2: rcx (in)
301+
* flags: rflags (in/out)
302+
* ex: rsi (in:fastop pointer, out:zero if exception)
303+
*
304+
* Moreover, they are all exactly FASTOP_SIZE bytes long, so functions for
305+
* different operand sizes can be reached by calculation, rather than a jump
306+
* table (which would be bigger than the code).
307+
*/
316308
static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop);
317309

318310
#define __FOP_FUNC(name) \
@@ -5683,7 +5675,7 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt)
56835675

56845676
if (ctxt->execute) {
56855677
if (ctxt->d & Fastop)
5686-
rc = fastop(ctxt, (fastop_t)ctxt->execute);
5678+
rc = fastop(ctxt, ctxt->fop);
56875679
else
56885680
rc = ctxt->execute(ctxt);
56895681
if (rc != X86EMUL_CONTINUE)

arch/x86/kvm/irq_comm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ void kvm_scan_ioapic_routes(struct kvm_vcpu *vcpu,
417417

418418
kvm_set_msi_irq(vcpu->kvm, entry, &irq);
419419

420-
if (irq.level &&
420+
if (irq.trig_mode &&
421421
kvm_apic_match_dest(vcpu, NULL, APIC_DEST_NOSHORT,
422422
irq.dest_id, irq.dest_mode))
423423
__set_bit(irq.vector, ioapic_handled_vectors);

arch/x86/kvm/lapic.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -627,9 +627,11 @@ static inline bool pv_eoi_enabled(struct kvm_vcpu *vcpu)
627627
static bool pv_eoi_get_pending(struct kvm_vcpu *vcpu)
628628
{
629629
u8 val;
630-
if (pv_eoi_get_user(vcpu, &val) < 0)
630+
if (pv_eoi_get_user(vcpu, &val) < 0) {
631631
printk(KERN_WARNING "Can't read EOI MSR value: 0x%llx\n",
632632
(unsigned long long)vcpu->arch.pv_eoi.msr_val);
633+
return false;
634+
}
633635
return val & 0x1;
634636
}
635637

@@ -1046,11 +1048,8 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
10461048
apic->regs + APIC_TMR);
10471049
}
10481050

1049-
if (vcpu->arch.apicv_active)
1050-
kvm_x86_ops->deliver_posted_interrupt(vcpu, vector);
1051-
else {
1051+
if (kvm_x86_ops->deliver_posted_interrupt(vcpu, vector)) {
10521052
kvm_lapic_set_irr(vector, apic);
1053-
10541053
kvm_make_request(KVM_REQ_EVENT, vcpu);
10551054
kvm_vcpu_kick(vcpu);
10561055
}

0 commit comments

Comments
 (0)