From 4e9baad8f5cb2040e802eff484fad7e721b21c0b Mon Sep 17 00:00:00 2001 From: Rudolf Marek Date: Tue, 8 May 2007 17:22:01 +0200 Subject: i386: Add safe variants of rdmsr_on_cpu and wrmsr_on_cpu Add safe (exception handled) variants of rdmsr_on_cpu and wrmsr_on_cpu. You should use these when the target MSR may not actually exist, as doing so could trigger an exception which the regular functions do not handle. The safe variants are slower, though. The upcoming coretemp hardware monitoring driver will need this. Signed-off-by: Rudolf Marek Cc: Alexey Dobriyan Cc: Dave Jones Signed-off-by: Jean Delvare --- include/asm-i386/msr.h | 12 +++++++++++- include/asm-x86_64/msr.h | 11 +++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/asm-i386/msr.h b/include/asm-i386/msr.h index 9559894c765..26861df52cc 100644 --- a/include/asm-i386/msr.h +++ b/include/asm-i386/msr.h @@ -77,7 +77,7 @@ static inline unsigned long long native_read_pmc(void) #ifdef CONFIG_PARAVIRT #include #else - +#include /* * Access to machine-specific registers (available on 586 and better only) * Note: the rd* operations modify the parameters directly (without using @@ -148,6 +148,8 @@ static inline void wrmsrl (unsigned long msr, unsigned long long val) #ifdef CONFIG_SMP void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h); void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h); +int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h); +int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h); #else /* CONFIG_SMP */ static inline void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h) { @@ -157,6 +159,14 @@ static inline void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h) { wrmsr(msr_no, l, h); } +static inline int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h) +{ + return rdmsr_safe(msr_no, l, h); +} +static inline int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h) +{ + return wrmsr_safe(msr_no, l, h); +} #endif /* CONFIG_SMP */ #endif #endif diff --git a/include/asm-x86_64/msr.h b/include/asm-x86_64/msr.h index a524f032567..d5c55b80da5 100644 --- a/include/asm-x86_64/msr.h +++ b/include/asm-x86_64/msr.h @@ -4,6 +4,7 @@ #include #ifndef __ASSEMBLY__ +#include /* * Access to machine-specific registers (available on 586 and better only) * Note: the rd* operations modify the parameters directly (without using @@ -162,6 +163,8 @@ static inline unsigned int cpuid_edx(unsigned int op) #ifdef CONFIG_SMP void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h); void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h); +int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h); +int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h); #else /* CONFIG_SMP */ static inline void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h) { @@ -171,6 +174,14 @@ static inline void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h) { wrmsr(msr_no, l, h); } +static inline int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h) +{ + return rdmsr_safe(msr_no, l, h); +} +static inline int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h) +{ + return wrmsr_safe(msr_no, l, h); +} #endif /* CONFIG_SMP */ #endif /* __ASSEMBLY__ */ #endif /* X86_64_MSR_H */ -- cgit v1.2.3