[PATCH v3 15/16] x86/msr: Reduce number of low level MSR access helpers

From: Juergen Gross

Date: Wed Feb 18 2026 - 03:24:10 EST


Some MSR access helpers are redundant now, so remove the no longer
needed ones.

Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
---
arch/x86/include/asm/msr.h | 15 ++-------------
arch/x86/xen/enlighten_pv.c | 4 ++--
2 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/arch/x86/include/asm/msr.h b/arch/x86/include/asm/msr.h
index 66f57265f2f8..84e82c0bb9b1 100644
--- a/arch/x86/include/asm/msr.h
+++ b/arch/x86/include/asm/msr.h
@@ -272,22 +272,11 @@ static __always_inline void native_wrmsr(u32 msr, u32 low, u32 high)
native_wrmsrq(msr, (u64)high << 32 | low);
}

-static inline u64 native_read_msr(u32 msr)
-{
- return native_rdmsrq(msr);
-}
-
static inline int native_read_msr_safe(u32 msr, u64 *val)
{
return __rdmsr(msr, val, EX_TYPE_RDMSR_SAFE) ? -EIO : 0;
}

-/* Can be uninlined because referenced by paravirt */
-static inline void notrace native_write_msr(u32 msr, u64 val)
-{
- native_wrmsrq(msr, val);
-}
-
/* Can be uninlined because referenced by paravirt */
static inline int notrace native_write_msr_safe(u32 msr, u64 val)
{
@@ -312,7 +301,7 @@ static inline u64 native_read_pmc(int counter)
#else
static __always_inline u64 read_msr(u32 msr)
{
- return native_read_msr(msr);
+ return native_rdmsrq(msr);
}

static __always_inline int read_msr_safe(u32 msr, u64 *p)
@@ -322,7 +311,7 @@ static __always_inline int read_msr_safe(u32 msr, u64 *p)

static __always_inline void write_msr(u32 msr, u64 val)
{
- native_write_msr(msr, val);
+ native_wrmsrq(msr, val);
}

static __always_inline int write_msr_safe(u32 msr, u64 val)
diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
index fed312a17033..612a512e2a67 100644
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -1091,7 +1091,7 @@ static u64 xen_do_read_msr(u32 msr, int *err)
if (err)
*err = native_read_msr_safe(msr, &val);
else
- val = native_read_msr(msr);
+ val = native_rdmsrq(msr);

switch (msr) {
case MSR_IA32_APICBASE:
@@ -1150,7 +1150,7 @@ static void xen_do_write_msr(u32 msr, u64 val, int *err)
if (err)
*err = native_write_msr_safe(msr, val);
else
- native_write_msr(msr, val);
+ native_wrmsrq(msr, val);
}
}

--
2.53.0