]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit
KVM: nVMX: fix msr bitmaps to prevent L2 from accessing L0 x2APIC
authorRadim Krčmář <rkrcmar@redhat.com>
Mon, 8 Aug 2016 18:16:22 +0000 (20:16 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 18 Aug 2016 10:19:07 +0000 (12:19 +0200)
commitd048c098218e91ed0e10dfa1f0f80e2567fe4ef7
tree6a15a3f3637fe6cea4c4dd6004541141aed5361d
parent184ca823481c99dadd7d946e5afd4bb921eab30d
KVM: nVMX: fix msr bitmaps to prevent L2 from accessing L0 x2APIC

msr bitmap can be used to avoid a VM exit (interception) on guest MSR
accesses.  In some configurations of VMX controls, the guest can even
directly access host's x2APIC MSRs.  See SDM 29.5 VIRTUALIZING MSR-BASED
APIC ACCESSES.

L2 could read all L0's x2APIC MSRs and write TPR, EOI, and SELF_IPI.
To do so, L1 would first trick KVM to disable all possible interceptions
by enabling APICv features and then would turn those features off;
nested_vmx_merge_msr_bitmap() only disabled interceptions, so VMX would
not intercept previously enabled MSRs even though they were not safe
with the new configuration.

Correctly re-enabling interceptions is not enough as a second bug would
still allow L1+L2 to access host's MSRs: msr bitmap was shared for all
VMCSs, so L1 could trigger a race to get the desired combination of msr
bitmap and VMX controls.

This fix allocates a msr bitmap for every L1 VCPU, allows only safe
x2APIC MSRs from L1's msr bitmap, and disables msr bitmaps if they would
have to intercept everything anyway.

Fixes: 3af18d9c5fe9 ("KVM: nVMX: Prepare for using hardware MSR bitmap")
Reported-by: Jim Mattson <jmattson@google.com>
Suggested-by: Wincy Van <fanwenyi0529@gmail.com>
Reviewed-by: Wanpeng Li <wanpeng.li@hotmail.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
arch/x86/kvm/vmx.c