Skip to contentSkip to conversation

x86/msr: Disable PMU for MSR tests

PATCH Applied Jeremiah McReynolds 2 participants 3 messages Sep 17 – Sep 25 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/msr: Disable PMU for MSR tests

QEMUv11 introduced a check when PMU is enabled to ensure that the virtualized CPU is the same as the underlying host CPU[1]. The MSR test always runs under GenuineIntel with the max CPU model, so PMU is implicitly enabled. However, when run on AMD, this new check in QEMU causes the test to fail with the log: "host doesn't support requested
feature: vPMU".

Explicitly disable PMU on the MSR test to avoid this failure.

[1]: https://gitlab.com/qemu-project/qemu/-/commit/4c7f05232cd1db5db114d36be2b210d24f1b9ad3

---
 x86/unittests.cfg | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
x86/unittests.cfg +3 -2
index ae731a93..06fe92f9 100644
@@ -174,9 +174,10 @@ arch = x86_64
 # Use GenuineIntel to ensure SYSENTER MSRs are fully preserved, and to test
 # SVM emulation of Intel CPU behavior.  Use the max CPU model so that 64-bit
 # support follows the host kernel.  Running a 32-bit guest on a 64-bit host
-# will fail due to shortcomings in KVM.
+# will fail due to shortcomings in KVM.  The max CPU model turns on PMU, but
+# Intel PMU registers cannot be virtualized on AMD, so turn it off.
 file = msr.flat
-qemu_params = -cpu max,vendor=GenuineIntel
+qemu_params = -cpu max,vendor=GenuineIntel,pmu=off
 
 [msr64]
 # Same as above, but with a minimal 64-bit CPU model to validate cases where an
Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
#1 lore raw
Quoted 21 lines · Jeremiah McReynolds

QEMUv11 introduced a check when PMU is enabled to ensure that the virtualized CPU is the same as the underlying host CPU[1]. The MSR test always runs under GenuineIntel with the max CPU model, so PMU is implicitly enabled. However, when run on AMD, this new check in QEMU causes the test to fail with the log: "host doesn't support requested
feature: vPMU".

Explicitly disable PMU on the MSR test to avoid this failure.

[1]: https://gitlab.com/qemu-project/qemu/-/commit/4c7f05232cd1db5db114d36be2b210d24f1b9ad3

---
 x86/unittests.cfg | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
x86/unittests.cfg +0 -0
index ae731a93..06fe92f9 100644

x86/unittests.cfg arch = x86_64 · line 180

Quoted 9 lines
x86/unittests.cfg +3 -2
@@ -174,9 +174,10 @@ arch = x86_64
 # Use GenuineIntel to ensure SYSENTER MSRs are fully preserved, and to test
 # SVM emulation of Intel CPU behavior.  Use the max CPU model so that 64-bit
 # support follows the host kernel.  Running a 32-bit guest on a 64-bit host
-# will fail due to shortcomings in KVM.
+# will fail due to shortcomings in KVM.  The max CPU model turns on PMU, but
+# Intel PMU registers cannot be virtualized on AMD, so turn it off.
 file = msr.flat
-qemu_params = -cpu max,vendor=GenuineIntel
+qemu_params = -cpu max,vendor=GenuineIntel,pmu=off

I double checked that "pmu" has existed for a while; it goes back all the way to QEMU v1.6.0, so we should be good on that front.

Quoted 6 lines
x86/unittests.cfg +0 -0
 [msr64]
 # Same as above, but with a minimal 64-bit CPU model to validate cases where an
Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
reviewer Applied
#2 lore raw
In reply to Jeremiah McReynolds
Quoted 8 lines · Jeremiah McReynolds

QEMUv11 introduced a check when PMU is enabled to ensure that the virtualized CPU is the same as the underlying host CPU[1]. The MSR test always runs under GenuineIntel with the max CPU model, so PMU is implicitly enabled. However, when run on AMD, this new check in QEMU causes the test to fail with the log: "host doesn't support requested
feature: vPMU".

[...]

Applied to kvm-x86 next, thanks!

[1/1] x86/msr: Disable PMU for MSR tests

      https://github.com/kvm-x86/kvm-unit-tests/commit/8a6e3be3745f

--
https://github.com/kvm-x86/kvm-unit-tests/tree/next