Skip to content

Commit 22d0bc0

Browse files
committed
Merge tag 'kvm-x86-fixes-6.8-rcN' of https://github.com/kvm-x86/linux into HEAD
KVM x86 fixes for 6.8: - Make a KVM_REQ_NMI request while handling KVM_SET_VCPU_EVENTS if and only if the incoming events->nmi.pending is non-zero. If the target vCPU is in the UNITIALIZED state, the spurious request will result in KVM exiting to userspace, which in turn causes QEMU to constantly acquire and release QEMU's global mutex, to the point where the BSP is unable to make forward progress. - Fix a type (u8 versus u64) goof that results in pmu->fixed_ctr_ctrl being incorrectly truncated, and ultimately causes KVM to think a fixed counter has already been disabled (KVM thinks the old value is '0'). - Fix a stack leak in KVM_GET_MSRS where a failed MSR read from userspace that is ultimately ignored due to ignore_msrs=true doesn't zero the output as intended.
2 parents 841c351 + 3376ca3 commit 22d0bc0

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

arch/x86/kvm/vmx/pmu_intel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static int fixed_pmc_events[] = {
7171
static void reprogram_fixed_counters(struct kvm_pmu *pmu, u64 data)
7272
{
7373
struct kvm_pmc *pmc;
74-
u8 old_fixed_ctr_ctrl = pmu->fixed_ctr_ctrl;
74+
u64 old_fixed_ctr_ctrl = pmu->fixed_ctr_ctrl;
7575
int i;
7676

7777
pmu->fixed_ctr_ctrl = data;

arch/x86/kvm/x86.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,22 +1704,17 @@ static int do_get_msr_feature(struct kvm_vcpu *vcpu, unsigned index, u64 *data)
17041704
struct kvm_msr_entry msr;
17051705
int r;
17061706

1707+
/* Unconditionally clear the output for simplicity */
1708+
msr.data = 0;
17071709
msr.index = index;
17081710
r = kvm_get_msr_feature(&msr);
17091711

1710-
if (r == KVM_MSR_RET_INVALID) {
1711-
/* Unconditionally clear the output for simplicity */
1712-
*data = 0;
1713-
if (kvm_msr_ignored_check(index, 0, false))
1714-
r = 0;
1715-
}
1716-
1717-
if (r)
1718-
return r;
1712+
if (r == KVM_MSR_RET_INVALID && kvm_msr_ignored_check(index, 0, false))
1713+
r = 0;
17191714

17201715
*data = msr.data;
17211716

1722-
return 0;
1717+
return r;
17231718
}
17241719

17251720
static bool __kvm_valid_efer(struct kvm_vcpu *vcpu, u64 efer)
@@ -5458,7 +5453,8 @@ static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu,
54585453
if (events->flags & KVM_VCPUEVENT_VALID_NMI_PENDING) {
54595454
vcpu->arch.nmi_pending = 0;
54605455
atomic_set(&vcpu->arch.nmi_queued, events->nmi.pending);
5461-
kvm_make_request(KVM_REQ_NMI, vcpu);
5456+
if (events->nmi.pending)
5457+
kvm_make_request(KVM_REQ_NMI, vcpu);
54625458
}
54635459
static_call(kvm_x86_set_nmi_mask)(vcpu, events->nmi.masked);
54645460

0 commit comments

Comments
 (0)