[PATCH 20/20] x86/msr: Use alternative_2_io() in rdtsc_ordered()

From: Josh Poimboeuf
Date: Fri Mar 14 2025 - 17:51:13 EST


Use the standard alternative_2_io() interface.

Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
---
arch/x86/include/asm/msr.h | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/x86/include/asm/msr.h b/arch/x86/include/asm/msr.h
index 001853541f1e..996e3b5857c6 100644
--- a/arch/x86/include/asm/msr.h
+++ b/arch/x86/include/asm/msr.h
@@ -214,12 +214,13 @@ static __always_inline unsigned long long rdtsc_ordered(void)
* Thus, use the preferred barrier on the respective CPU, aiming for
* RDTSCP as the default.
*/
- asm volatile(ALTERNATIVE_2("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");
+ alternative_2_io("rdtsc",
+ "lfence; rdtsc", X86_FEATURE_LFENCE_RDTSC,
+ "rdtscp", X86_FEATURE_RDTSCP,
+ ARG(EAX_EDX_RET(val, low, high)),
+ ARG(),
+ /* RDTSCP clobbers ECX with MSR_TSC_AUX. */
+ ARG("ecx"));

return EAX_EDX_VAL(val, low, high);
}
--
2.48.1