Skip to content

Commit 5ed2803

Browse files
sean-jcjfvogel
authored andcommitted
KVM: x86: Bug the VM if an accelerated x2APIC trap occurs on a "bad" reg
Bug the VM if retrieving the x2APIC MSR/register while processing an accelerated vAPIC trap VM-Exit fails. In theory it's impossible for the lookup to fail as hardware has already validated the register, but bugs happen, and not checking the result of kvm_lapic_msr_read() would result in consuming the uninitialized "val" if a KVM or hardware bug occurs. Fixes: 1bd9dfe ("KVM: x86: Do not block APIC write for non ICR registers") Reported-by: Dan Carpenter <[email protected]> Cc: Suravee Suthikulpanit <[email protected]> Signed-off-by: Sean Christopherson <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]> (cherry picked from commit 70c8327) Orabug: 34817119 Signed-off-by: Alejandro Jimenez <[email protected]> Reviewed-by: Boris Ostrovsky <[email protected]> (cherry picked from commit c5ed4c333d7f6fab0451f6524033aa4153ed125c) Signed-off-by: Jack Vogel <[email protected]>
1 parent af0d6c5 commit 5ed2803

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

arch/x86/kvm/lapic.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2260,10 +2260,12 @@ void kvm_apic_write_nodecode(struct kvm_vcpu *vcpu, u32 offset)
22602260
struct kvm_lapic *apic = vcpu->arch.apic;
22612261
u64 val;
22622262

2263-
if (apic_x2apic_mode(apic))
2264-
kvm_lapic_msr_read(apic, offset, &val);
2265-
else
2263+
if (apic_x2apic_mode(apic)) {
2264+
if (KVM_BUG_ON(kvm_lapic_msr_read(apic, offset, &val), vcpu->kvm))
2265+
return;
2266+
} else {
22662267
val = kvm_lapic_get_reg(apic, offset);
2268+
}
22672269

22682270
/*
22692271
* ICR is a single 64-bit register when x2APIC is enabled. For legacy

0 commit comments

Comments
 (0)