x86: Fixes for rdpid test
cover x86: Fixes for rdpid test
Fix 2 small issues with the rdpid test that is a part of x86/tsc.c. Notably, the test is not currently running since qemu is not configured to advertise RDPID support and fixing that uncovers a bug in the test when compiling with Clang.
David Matlack (2):
x86: Run the tsc test with -cpu max
x86: Mark RDPID asm volatile to avoid dropping instructions
x86/tsc.c | 2 +- x86/unittests.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
base-commit: e3c5c3ef2524c58023073c0fadde2e8ae3c04ec6
Signature · 1 line
2.40.0.rc0.216.gc4246ad0f0-goog
PATCH 1/2 x86: Run the tsc test with -cpu max
Run the tsc test with -cpu max to enable RDPID testing. The current configuration (-cpu kvm64,+rdtscp) does not include RDPID even if the host supports. In effect, test_rdpid() never runs.
Use max instead of adding +rdpid to the existing configuration to avoid this biting someone in the future if they add a test for a new feature.
--- x86/unittests.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
x86/unittests.cfg +1 -1
@@ -247,7 +247,7 @@ extra_params = -cpu Opteron_G1,vendor=AuthenticAMD [tsc] file = tsc.flat -extra_params = -cpu kvm64,+rdtscp +extra_params = -cpu max [tsc_adjust] file = tsc_adjust.flat
Signature · 1 line
2.40.0.rc0.216.gc4246ad0f0-goog
PATCH 2/2 x86: Mark RDPID asm volatile to avoid dropping instructions
In reply to David MatlackMark the asm statement that generates the RDPID instruction volatile. The compiler within its rights to drop subsequent RDPID asm statements (after the first) since the inputs never change.
This fixes the tsc test on hardware that supports rdpid when built with the latest Clang compiler.
--- x86/tsc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
x86/tsc.c +1 -1
@@ -24,7 +24,7 @@ static void test_rdpid(u64 aux)u32 eax;wrmsr (MSR_TSC_AUX , aux); - asm (".byte 0xf3, 0x0f, 0xc7, 0xf8" :"=a" (eax)); + asmvolatile (".byte 0xf3, 0x0f, 0xc7, 0xf8" :"=a" (eax));report (eax == aux,"Test rdpid %%eax %" PRId64, aux); }
Signature · 1 line
2.40.0.rc0.216.gc4246ad0f0-goog
Re: [kvm-unit-tests PATCH 2/2] x86: Mark RDPID asm volatile to avoid dropping instructions
Quoted 5 lines · David Matlack
Mark the asm statement that generates the RDPID instruction volatile. The compiler within its rights to drop subsequent RDPID asm statements (after the first) since the inputs never change.
Quoted 7 lines
This fixes the tsc test on hardware that supports rdpid when built with the latest Clang compiler.
Fixes 10631a5bebd8 ("x86: tsc: add rdpid test")Reported-by Greg Thelen <[email protected]>Suggested-by Greg Thelen <[email protected]>Signed-off-by David Matlack <[email protected]>
Quoted 9 lines · David Matlack
Fix 2 small issues with the rdpid test that is a part of
x86/tsc.c. Notably, the test is not currently running since qemu is not configured to advertise RDPID support and fixing that uncovers a bug in the test when compiling with Clang.David Matlack (2):
x86: Run the tsc test with -cpu max
x86: Mark RDPID asm volatile to avoid dropping instructions
Quoted 6 lines
x86/tsc.c | 2 +- x86/unittests.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)base-commit:
e3c5c3ef2524c58023073c0fadde2e8ae3c04ec6
Queued, thanks.
Paolo
Quoted 10 lines · David Matlack
Fix 2 small issues with the rdpid test that is a part of
x86/tsc.c. Notably, the test is not currently running since qemu is not configured to advertise RDPID support and fixing that uncovers a bug in the test when compiling with Clang.David Matlack (2):
x86: Run the tsc test with -cpu max
x86: Mark RDPID asm volatile to avoid dropping instructions[...]
Applied to kvm-x86 next, thanks! Paolo's "Queued, thanks" showed up, but I don't see these in upstream.
[1/2] x86: Run the tsc test with -cpu max
https://github.com/kvm-x86/kvm-unit-tests/commit/572fb7097fa7 [2/2] x86: Mark RDPID asm volatile to avoid dropping instructions https://github.com/kvm-x86/kvm-unit-tests/commit/a467f7679c7f