From: Dave Hansen <[email protected]>

The paravirt and native code define very similar rdmsr()
implementations. Move the non-paravirt one out to common code where
both the "native" and "paravirt" implementations can use it.

Remove the now duplicate paravirt rdmsr().

Signed-off-by: Dave Hansen <[email protected]>
---

 b/arch/x86/include/asm/msr.h      |   17 ++++++++++-------
 b/arch/x86/include/asm/paravirt.h |    7 -------
 2 files changed, 10 insertions(+), 14 deletions(-)

diff -puN arch/x86/include/asm/msr.h~rdmsr-dups-2 arch/x86/include/asm/msr.h
--- a/arch/x86/include/asm/msr.h~rdmsr-dups-2   2026-04-01 14:32:56.105435948 
-0700
+++ b/arch/x86/include/asm/msr.h        2026-04-01 14:32:56.112436210 -0700
@@ -186,13 +186,6 @@ static inline u64 native_read_pmc(int co
  * pointer indirection), this allows gcc to optimize better
  */
 
-#define rdmsr(msr, low, high)                                  \
-do {                                                           \
-       u64 __val = paravirt_read_msr((msr));                   \
-       (void)((low) = (u32)__val);                             \
-       (void)((high) = (u32)(__val >> 32));                    \
-} while (0)
-
 static inline void wrmsr(u32 msr, u32 low, u32 high)
 {
        paravirt_write_msr(msr, (u64)high << 32 | low);
@@ -234,6 +227,16 @@ static __always_inline u64 rdpmc(int cou
 
 #endif /* !CONFIG_PARAVIRT_XXL */
 
+/*
+ * Common paravirt and native helpers:
+ */
+#define rdmsr(msr, low, high)                                  \
+do {                                                           \
+       u64 __val = paravirt_read_msr((msr));                   \
+       (void)((low) = (u32)__val);                             \
+       (void)((high) = (u32)(__val >> 32));                    \
+} while (0)
+
 /* Instruction opcode for WRMSRNS supported in binutils >= 2.40 */
 #define ASM_WRMSRNS _ASM_BYTES(0x0f,0x01,0xc6)
 
diff -puN arch/x86/include/asm/paravirt.h~rdmsr-dups-2 
arch/x86/include/asm/paravirt.h
--- a/arch/x86/include/asm/paravirt.h~rdmsr-dups-2      2026-04-01 
14:32:56.109436097 -0700
+++ b/arch/x86/include/asm/paravirt.h   2026-04-01 14:32:56.112436210 -0700
@@ -161,13 +161,6 @@ static inline int paravirt_write_msr_saf
        return PVOP_CALL2(int, pv_ops, cpu.write_msr_safe, msr, val);
 }
 
-#define rdmsr(msr, val1, val2)                 \
-do {                                           \
-       u64 _l = paravirt_read_msr(msr);        \
-       val1 = (u32)_l;                         \
-       val2 = _l >> 32;                        \
-} while (0)
-
 static __always_inline void wrmsr(u32 msr, u32 low, u32 high)
 {
        paravirt_write_msr(msr, (u64)high << 32 | low);
_

Reply via email to