diff options
Diffstat (limited to 'include/asm-x86/msr.h')
| -rw-r--r-- | include/asm-x86/msr.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/include/asm-x86/msr.h b/include/asm-x86/msr.h index eee83f783f6d..530af1f6389e 100644 --- a/include/asm-x86/msr.h +++ b/include/asm-x86/msr.h | |||
| @@ -63,6 +63,22 @@ static inline unsigned long long native_read_msr_safe(unsigned int msr, | |||
| 63 | return EAX_EDX_VAL(val, low, high); | 63 | return EAX_EDX_VAL(val, low, high); |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | static inline unsigned long long native_read_msr_amd_safe(unsigned int msr, | ||
| 67 | int *err) | ||
| 68 | { | ||
| 69 | DECLARE_ARGS(val, low, high); | ||
| 70 | |||
| 71 | asm volatile("2: rdmsr ; xor %0,%0\n" | ||
| 72 | "1:\n\t" | ||
| 73 | ".section .fixup,\"ax\"\n\t" | ||
| 74 | "3: mov %3,%0 ; jmp 1b\n\t" | ||
| 75 | ".previous\n\t" | ||
| 76 | _ASM_EXTABLE(2b, 3b) | ||
| 77 | : "=r" (*err), EAX_EDX_RET(val, low, high) | ||
| 78 | : "c" (msr), "D" (0x9c5a203a), "i" (-EFAULT)); | ||
| 79 | return EAX_EDX_VAL(val, low, high); | ||
| 80 | } | ||
| 81 | |||
| 66 | static inline void native_write_msr(unsigned int msr, | 82 | static inline void native_write_msr(unsigned int msr, |
| 67 | unsigned low, unsigned high) | 83 | unsigned low, unsigned high) |
| 68 | { | 84 | { |
| @@ -158,6 +174,13 @@ static inline int rdmsrl_safe(unsigned msr, unsigned long long *p) | |||
| 158 | *p = native_read_msr_safe(msr, &err); | 174 | *p = native_read_msr_safe(msr, &err); |
| 159 | return err; | 175 | return err; |
| 160 | } | 176 | } |
| 177 | static inline int rdmsrl_amd_safe(unsigned msr, unsigned long long *p) | ||
| 178 | { | ||
| 179 | int err; | ||
| 180 | |||
| 181 | *p = native_read_msr_amd_safe(msr, &err); | ||
| 182 | return err; | ||
| 183 | } | ||
| 161 | 184 | ||
| 162 | #define rdtscl(low) \ | 185 | #define rdtscl(low) \ |
| 163 | ((low) = (u32)native_read_tsc()) | 186 | ((low) = (u32)native_read_tsc()) |
