x86/TSC: Use RDTSCP
Quoted 3 lines
And I had a bit of a WTF moment, as in "WTF does RDTSC have to do with a speculation protection barrier". Does it actually make sense?
It doesn't. There was too much s/lfence/barrier_nospec/ apparently.
Review
Quoted 7 lines
(quoted diff) +7
-0+ asm volatile(ALTERNATIVE_3("rdtsc", + "mfence; rdtsc", X86_FEATURE_MFENCE_RDTSC, + "lfence; rdtsc", X86_FEATURE_LFENCE_RDTSC, + "rdtscp", X86_FEATURE_RDTSCP) + : EAX_EDX_RET(val, low, high) + /* RDTSCP clobbers ECX with MSR_TSC_AUX. */ + :: "ecx");
I have a question: does alternatives ordering matter? CPU can have both features.
And other code in this file uses "c" for clobber.
Quoted 1 line · Alexey Dobriyan
I have a question: does alternatives ordering matter?
Yes.
Quoted 1 line
CPU can have both features.
The last present feature wins.
Quoted 1 line
And other code in this file uses "c" for clobber.
Ok.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Quoted 3 lines · Borislav Petkov
Quoted 1 line
And other code in this file uses "c" for clobber.
Ok.
Except that clobbers need to be full register names:
./arch/x86/include/asm/msr.h: In function ‘do_hres’:./arch/x86/include/asm/msr.h:236:2: error: unknown register name ‘c’ in ‘asm’
asm volatile(ALTERNATIVE_3("rdtsc",
^~~
...
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.