KVM: x86: Inject #GP if WRMSR sets reserved bits in APIC Self-IPI

commit ba5838abb05334e4abfdff1490585c7f365e0424 upstream.

Inject a #GP if the guest attempts to set reserved bits in the x2APIC-only
Self-IPI register.  Bits 7:0 hold the vector, all other bits are reserved.

Reported-by: Marc Orr <marcorr@google.com>
Cc: Ben Gardon <bgardon@google.com>
Cc: Venkatesh Srinivas <venkateshs@chromium.org>
Cc: stable@vger.kernel.org
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Link: https://lore.kernel.org/r/20230107011025.565472-2-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Sean Christopherson
2023-01-07 01:10:20 +00:00
committed by Greg Kroah-Hartman
parent 76a9886e1b
commit 018798c6fb

View File

@@ -2115,10 +2115,14 @@ int kvm_lapic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val)
break; break;
case APIC_SELF_IPI: case APIC_SELF_IPI:
if (apic_x2apic_mode(apic)) /*
kvm_apic_send_ipi(apic, APIC_DEST_SELF | (val & APIC_VECTOR_MASK), 0); * Self-IPI exists only when x2APIC is enabled. Bits 7:0 hold
else * the vector, everything else is reserved.
*/
if (!apic_x2apic_mode(apic) || (val & ~APIC_VECTOR_MASK))
ret = 1; ret = 1;
else
kvm_apic_send_ipi(apic, APIC_DEST_SELF | val, 0);
break; break;
default: default:
ret = 1; ret = 1;