[PATCH] Readd rdmsrl_safe v2



Readd rdmsrl_safe v2

RDMSR for 64bit values with exception handling.

Makes it easier to deal with 64bit valued MSRs. The old 64bit code
base had that too as checking_rdmsrl(), but it got dropped somehow.

Needed for followup patch.

v2: switch to inline

Signed-off-by: Andi Kleen <ak@xxxxxxx>
Signed-off-by: Andi Kleen <andi@xxxxxxxxxxxxxx>

---
include/asm-x86/msr.h | 3 +++
include/asm-x86/paravirt.h | 4 ++++
2 files changed, 7 insertions(+)

Index: linux/include/asm-x86/msr.h
===================================================================
--- linux.orig/include/asm-x86/msr.h
+++ linux/include/asm-x86/msr.h
@@ -150,6 +150,13 @@ static inline int wrmsr_safe(unsigned ms
__err; \
})

+static inline int rdmsrl_safe(unsigned msr, unsigned long long *p)
+{
+ int err;
+ *p = native_read_msr_safe(msr, &err);
+ return err;
+}
+
#define rdtscl(low) \
((low) = (u32)native_read_tsc())

Index: linux/include/asm-x86/paravirt.h
===================================================================
--- linux.orig/include/asm-x86/paravirt.h
+++ linux/include/asm-x86/paravirt.h
@@ -687,6 +687,12 @@ static inline int paravirt_write_msr(uns
(*b) = _l >> 32; \
_err; })

+static inline int rdmsrl_safe(unsigned msr, unsigned long long *p)
+{
+ int err;
+ *p = paravirt_read_msr(msr, &err);
+ return err;
+}

static inline u64 paravirt_read_tsc(void)
{
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • [PATCH 7/7] consolidate msr.h
    ... code for tsc reading, msr reading/writing, etc. ... inline int check_tsc_unstable ... static inline unsigned long long native_read_msr_safe(unsigned int msr, ... -static inline void native_write_msr ...
    (Linux-Kernel)
  • [PATCH 7/24] consolidate msr.h
    ... code for tsc reading, msr reading/writing, etc. ... inline int check_tsc_unstable ... static inline unsigned long long native_read_msr_safe(unsigned int msr, ... -static inline void native_write_msr ...
    (Linux-Kernel)
  • [PATCH 076/148] include/asm-x86/msr.h: checkpatch cleanups - formatting only
    ... static inline unsigned long long native_read_tscp(unsigned int *aux) ... static inline int wrmsr_safe(unsigned msr, unsigned low, unsigned high) ...
    (Linux-Kernel)
  • [tip:x86/cpu] x86, msr: Rewrite AMD rd/wrmsr variants
    ... static inline void native_write_msr(unsigned int msr, ... return err; ... +static inline int wrmsrl_amd_safe ... static inline int paravirt_write_msr(unsigned msr, unsigned low, unsigned high) ...
    (Linux-Kernel)
  • [PATCH 2/3] x86, msr: rewrite AMD rd/wrmsr variants
    ... return err; ... static inline int rdmsrl_amd_safe(unsigned msr, ... +static inline int wrmsr_amd_safe(unsigned msr, unsigned low, unsigned high) ...
    (Linux-Kernel)