[kvm-unit-tests PATCH 2/2] x86: Mark RDPID asm volatile to avoid dropping instructions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

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 <gthelen@xxxxxxxxxx>
Suggested-by: Greg Thelen <gthelen@xxxxxxxxxx>
Signed-off-by: David Matlack <dmatlack@xxxxxxxxxx>
---
 x86/tsc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/x86/tsc.c b/x86/tsc.c
index bc403fc78461..b3bb120291ec 100644
--- a/x86/tsc.c
+++ b/x86/tsc.c
@@ -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));
+       asm volatile (".byte 0xf3, 0x0f, 0xc7, 0xf8" : "=a" (eax));
        report(eax == aux, "Test rdpid %%eax %" PRId64, aux);
 }
 
-- 
2.40.0.rc0.216.gc4246ad0f0-goog




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux