]> git.baikalelectronics.ru Git - kernel.git/commit
Revert "KVM: nVMX: Expose RDPMC-exiting only when guest supports PMU"
authorSean Christopherson <sean.j.christopherson@intel.com>
Wed, 8 May 2019 16:08:19 +0000 (09:08 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 15 May 2019 21:19:19 +0000 (23:19 +0200)
commit4da2f308d4a50eb776f2d2ebe34c205c7e132f49
tree2fa96b9bec29a50b1edc559370267539943bcc19
parent1f51cec2320df2c5e31e0c1c323be707c118771b
Revert "KVM: nVMX: Expose RDPMC-exiting only when guest supports PMU"

The RDPMC-exiting control is dependent on the existence of the RDPMC
instruction itself, i.e. is not tied to the "Architectural Performance
Monitoring" feature.  For all intents and purposes, the control exists
on all CPUs with VMX support since RDPMC also exists on all VCPUs with
VMX supported.  Per Intel's SDM:

  The RDPMC instruction was introduced into the IA-32 Architecture in
  the Pentium Pro processor and the Pentium processor with MMX technology.
  The earlier Pentium processors have performance-monitoring counters, but
  they must be read with the RDMSR instruction.

Because RDPMC-exiting always exists, KVM requires the control and refuses
to load if it's not available.  As a result, hiding the PMU from a guest
breaks nested virtualization if the guest attemts to use KVM.

While it's not explicitly stated in the RDPMC pseudocode, the VM-Exit
check for RDPMC-exiting follows standard fault vs. VM-Exit prioritization
for privileged instructions, e.g. occurs after the CPL/CR0.PE/CR4.PCE
checks, but before the counter referenced in ECX is checked for validity.

In other words, the original KVM behavior of injecting a #GP was correct,
and the KVM unit test needs to be adjusted accordingly, e.g. eat the #GP
when the unit test guest (L3 in this case) executes RDPMC without
RDPMC-exiting set in the unit test host (L2).

This reverts commit 8bf081fb883e0b59fcd3b5dad5c8b345c40f869d.

Fixes: 8bf081fb883e ("KVM: nVMX: Expose RDPMC-exiting only when guest supports PMU")
Reported-by: David Hill <hilld@binarystorm.net>
Cc: Saar Amar <saaramar@microsoft.com>
Cc: Mihai Carabas <mihai.carabas@oracle.com>
Cc: Jim Mattson <jmattson@google.com>
Cc: Liran Alon <liran.alon@oracle.com>
Cc: stable@vger.kernel.org
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/vmx/vmx.c