Skip to content

Commit afd67ee

Browse files
vittyvkbonzini
authored andcommitted
KVM: x86: Don't update vcpu->arch.pv_eoi.msr_val when a bogus value was written to MSR_KVM_PV_EOI_EN
When kvm_gfn_to_hva_cache_init() call from kvm_lapic_set_pv_eoi() fails, MSR write to MSR_KVM_PV_EOI_EN results in #GP so it is reasonable to expect that the value we keep internally in KVM wasn't updated. Signed-off-by: Vitaly Kuznetsov <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 77c3323 commit afd67ee

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

arch/x86/kvm/lapic.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2857,20 +2857,25 @@ int kvm_lapic_set_pv_eoi(struct kvm_vcpu *vcpu, u64 data, unsigned long len)
28572857
u64 addr = data & ~KVM_MSR_ENABLED;
28582858
struct gfn_to_hva_cache *ghc = &vcpu->arch.pv_eoi.data;
28592859
unsigned long new_len;
2860+
int ret;
28602861

28612862
if (!IS_ALIGNED(addr, 4))
28622863
return 1;
28632864

2864-
vcpu->arch.pv_eoi.msr_val = data;
2865-
if (!pv_eoi_enabled(vcpu))
2866-
return 0;
2865+
if (data & KVM_MSR_ENABLED) {
2866+
if (addr == ghc->gpa && len <= ghc->len)
2867+
new_len = ghc->len;
2868+
else
2869+
new_len = len;
28672870

2868-
if (addr == ghc->gpa && len <= ghc->len)
2869-
new_len = ghc->len;
2870-
else
2871-
new_len = len;
2871+
ret = kvm_gfn_to_hva_cache_init(vcpu->kvm, ghc, addr, new_len);
2872+
if (ret)
2873+
return ret;
2874+
}
2875+
2876+
vcpu->arch.pv_eoi.msr_val = data;
28722877

2873-
return kvm_gfn_to_hva_cache_init(vcpu->kvm, ghc, addr, new_len);
2878+
return 0;
28742879
}
28752880

28762881
int kvm_apic_accept_events(struct kvm_vcpu *vcpu)

0 commit comments

Comments
 (0)