H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 1 | #ifndef _ASM_X86_MSR_H |
| 2 | #define _ASM_X86_MSR_H |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 3 | |
| 4 | #include <asm/msr-index.h> |
| 5 | |
Glauber de Oliveira Costa | 8f12dea | 2008-01-30 13:31:06 +0100 | [diff] [blame] | 6 | #ifndef __ASSEMBLY__ |
Glauber de Oliveira Costa | c210d24 | 2008-01-30 13:31:07 +0100 | [diff] [blame] | 7 | |
Jaswinder Singh Rajput | 8fa62ad | 2009-06-17 14:11:10 +0530 | [diff] [blame] | 8 | #include <linux/types.h> |
H. Peter Anvin | ff55df5 | 2009-08-31 14:16:57 -0700 | [diff] [blame] | 9 | #include <linux/ioctl.h> |
| 10 | |
| 11 | #define X86_IOC_RDMSR_REGS _IOWR('c', 0xA0, __u32[8]) |
| 12 | #define X86_IOC_WRMSR_REGS _IOWR('c', 0xA1, __u32[8]) |
| 13 | |
| 14 | #ifdef __KERNEL__ |
| 15 | |
Glauber de Oliveira Costa | c210d24 | 2008-01-30 13:31:07 +0100 | [diff] [blame] | 16 | #include <asm/asm.h> |
| 17 | #include <asm/errno.h> |
Borislav Petkov | 6bc1096 | 2009-05-22 12:12:01 +0200 | [diff] [blame] | 18 | #include <asm/cpumask.h> |
| 19 | |
| 20 | struct msr { |
| 21 | union { |
| 22 | struct { |
| 23 | u32 l; |
| 24 | u32 h; |
| 25 | }; |
| 26 | u64 q; |
| 27 | }; |
| 28 | }; |
Glauber de Oliveira Costa | c210d24 | 2008-01-30 13:31:07 +0100 | [diff] [blame] | 29 | |
Andrew Morton | 1e160cc | 2008-01-30 13:31:17 +0100 | [diff] [blame] | 30 | static inline unsigned long long native_read_tscp(unsigned int *aux) |
Glauber de Oliveira Costa | 8f12dea | 2008-01-30 13:31:06 +0100 | [diff] [blame] | 31 | { |
| 32 | unsigned long low, high; |
Joe Perches | abb0ade | 2008-03-23 01:02:51 -0700 | [diff] [blame] | 33 | asm volatile(".byte 0x0f,0x01,0xf9" |
| 34 | : "=a" (low), "=d" (high), "=c" (*aux)); |
Max Asbock | 41aefdc | 2008-06-25 14:45:28 -0700 | [diff] [blame] | 35 | return low | ((u64)high << 32); |
Glauber de Oliveira Costa | 8f12dea | 2008-01-30 13:31:06 +0100 | [diff] [blame] | 36 | } |
| 37 | |
Glauber de Oliveira Costa | c210d24 | 2008-01-30 13:31:07 +0100 | [diff] [blame] | 38 | /* |
Jike Song | d4f1b10 | 2008-10-17 13:25:07 +0800 | [diff] [blame] | 39 | * both i386 and x86_64 returns 64-bit value in edx:eax, but gcc's "A" |
| 40 | * constraint has different meanings. For i386, "A" means exactly |
| 41 | * edx:eax, while for x86_64 it doesn't mean rdx:rax or edx:eax. Instead, |
| 42 | * it means rax *or* rdx. |
Glauber de Oliveira Costa | c210d24 | 2008-01-30 13:31:07 +0100 | [diff] [blame] | 43 | */ |
| 44 | #ifdef CONFIG_X86_64 |
| 45 | #define DECLARE_ARGS(val, low, high) unsigned low, high |
Joe Perches | abb0ade | 2008-03-23 01:02:51 -0700 | [diff] [blame] | 46 | #define EAX_EDX_VAL(val, low, high) ((low) | ((u64)(high) << 32)) |
Glauber de Oliveira Costa | c210d24 | 2008-01-30 13:31:07 +0100 | [diff] [blame] | 47 | #define EAX_EDX_ARGS(val, low, high) "a" (low), "d" (high) |
| 48 | #define EAX_EDX_RET(val, low, high) "=a" (low), "=d" (high) |
| 49 | #else |
| 50 | #define DECLARE_ARGS(val, low, high) unsigned long long val |
| 51 | #define EAX_EDX_VAL(val, low, high) (val) |
| 52 | #define EAX_EDX_ARGS(val, low, high) "A" (val) |
| 53 | #define EAX_EDX_RET(val, low, high) "=A" (val) |
Glauber de Oliveira Costa | 8f12dea | 2008-01-30 13:31:06 +0100 | [diff] [blame] | 54 | #endif |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 55 | |
| 56 | static inline unsigned long long native_read_msr(unsigned int msr) |
| 57 | { |
Glauber de Oliveira Costa | c210d24 | 2008-01-30 13:31:07 +0100 | [diff] [blame] | 58 | DECLARE_ARGS(val, low, high); |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 59 | |
Glauber de Oliveira Costa | c210d24 | 2008-01-30 13:31:07 +0100 | [diff] [blame] | 60 | asm volatile("rdmsr" : EAX_EDX_RET(val, low, high) : "c" (msr)); |
| 61 | return EAX_EDX_VAL(val, low, high); |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | static inline unsigned long long native_read_msr_safe(unsigned int msr, |
| 65 | int *err) |
| 66 | { |
Glauber de Oliveira Costa | c210d24 | 2008-01-30 13:31:07 +0100 | [diff] [blame] | 67 | DECLARE_ARGS(val, low, high); |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 68 | |
H. Peter Anvin | 08970fc | 2008-08-25 22:39:15 -0700 | [diff] [blame] | 69 | asm volatile("2: rdmsr ; xor %[err],%[err]\n" |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 70 | "1:\n\t" |
| 71 | ".section .fixup,\"ax\"\n\t" |
H. Peter Anvin | 08970fc | 2008-08-25 22:39:15 -0700 | [diff] [blame] | 72 | "3: mov %[fault],%[err] ; jmp 1b\n\t" |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 73 | ".previous\n\t" |
Joe Perches | abb0ade | 2008-03-23 01:02:51 -0700 | [diff] [blame] | 74 | _ASM_EXTABLE(2b, 3b) |
H. Peter Anvin | 08970fc | 2008-08-25 22:39:15 -0700 | [diff] [blame] | 75 | : [err] "=r" (*err), EAX_EDX_RET(val, low, high) |
H. Peter Anvin | 0cc0213 | 2009-08-31 14:23:29 -0700 | [diff] [blame] | 76 | : "c" (msr), [fault] "i" (-EIO)); |
Glauber de Oliveira Costa | c210d24 | 2008-01-30 13:31:07 +0100 | [diff] [blame] | 77 | return EAX_EDX_VAL(val, low, high); |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 78 | } |
| 79 | |
Glauber de Oliveira Costa | c9dcda5 | 2008-01-30 13:31:07 +0100 | [diff] [blame] | 80 | static inline void native_write_msr(unsigned int msr, |
| 81 | unsigned low, unsigned high) |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 82 | { |
Jeremy Fitzhardinge | af2b1c6 | 2008-06-25 00:18:59 -0400 | [diff] [blame] | 83 | asm volatile("wrmsr" : : "c" (msr), "a"(low), "d" (high) : "memory"); |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 84 | } |
| 85 | |
Frederic Weisbecker | 0ca59dd | 2008-12-24 23:30:02 +0100 | [diff] [blame] | 86 | /* Can be uninlined because referenced by paravirt */ |
| 87 | notrace static inline int native_write_msr_safe(unsigned int msr, |
Glauber de Oliveira Costa | c9dcda5 | 2008-01-30 13:31:07 +0100 | [diff] [blame] | 88 | unsigned low, unsigned high) |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 89 | { |
| 90 | int err; |
H. Peter Anvin | 08970fc | 2008-08-25 22:39:15 -0700 | [diff] [blame] | 91 | asm volatile("2: wrmsr ; xor %[err],%[err]\n" |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 92 | "1:\n\t" |
| 93 | ".section .fixup,\"ax\"\n\t" |
H. Peter Anvin | 08970fc | 2008-08-25 22:39:15 -0700 | [diff] [blame] | 94 | "3: mov %[fault],%[err] ; jmp 1b\n\t" |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 95 | ".previous\n\t" |
Joe Perches | abb0ade | 2008-03-23 01:02:51 -0700 | [diff] [blame] | 96 | _ASM_EXTABLE(2b, 3b) |
H. Peter Anvin | 08970fc | 2008-08-25 22:39:15 -0700 | [diff] [blame] | 97 | : [err] "=a" (err) |
Glauber de Oliveira Costa | c9dcda5 | 2008-01-30 13:31:07 +0100 | [diff] [blame] | 98 | : "c" (msr), "0" (low), "d" (high), |
H. Peter Anvin | 0cc0213 | 2009-08-31 14:23:29 -0700 | [diff] [blame] | 99 | [fault] "i" (-EIO) |
Jeremy Fitzhardinge | af2b1c6 | 2008-06-25 00:18:59 -0400 | [diff] [blame] | 100 | : "memory"); |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 101 | return err; |
| 102 | } |
| 103 | |
Ingo Molnar | cdc7957 | 2008-01-30 13:32:39 +0100 | [diff] [blame] | 104 | extern unsigned long long native_read_tsc(void); |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 105 | |
H. Peter Anvin | 8b956bf | 2009-08-31 14:13:48 -0700 | [diff] [blame] | 106 | extern int native_rdmsr_safe_regs(u32 regs[8]); |
| 107 | extern int native_wrmsr_safe_regs(u32 regs[8]); |
Borislav Petkov | 132ec92 | 2009-08-31 09:50:09 +0200 | [diff] [blame] | 108 | |
Ingo Molnar | 92767af | 2008-01-30 13:32:40 +0100 | [diff] [blame] | 109 | static __always_inline unsigned long long __native_read_tsc(void) |
| 110 | { |
| 111 | DECLARE_ARGS(val, low, high); |
| 112 | |
Ingo Molnar | 92767af | 2008-01-30 13:32:40 +0100 | [diff] [blame] | 113 | asm volatile("rdtsc" : EAX_EDX_RET(val, low, high)); |
Ingo Molnar | 92767af | 2008-01-30 13:32:40 +0100 | [diff] [blame] | 114 | |
| 115 | return EAX_EDX_VAL(val, low, high); |
| 116 | } |
| 117 | |
Glauber de Oliveira Costa | b8d1fae | 2008-01-30 13:31:07 +0100 | [diff] [blame] | 118 | static inline unsigned long long native_read_pmc(int counter) |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 119 | { |
Glauber de Oliveira Costa | c210d24 | 2008-01-30 13:31:07 +0100 | [diff] [blame] | 120 | DECLARE_ARGS(val, low, high); |
| 121 | |
| 122 | asm volatile("rdpmc" : EAX_EDX_RET(val, low, high) : "c" (counter)); |
| 123 | return EAX_EDX_VAL(val, low, high); |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | #ifdef CONFIG_PARAVIRT |
| 127 | #include <asm/paravirt.h> |
Thomas Gleixner | 96a388d | 2007-10-11 11:20:03 +0200 | [diff] [blame] | 128 | #else |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 129 | #include <linux/errno.h> |
| 130 | /* |
| 131 | * Access to machine-specific registers (available on 586 and better only) |
| 132 | * Note: the rd* operations modify the parameters directly (without using |
| 133 | * pointer indirection), this allows gcc to optimize better |
| 134 | */ |
| 135 | |
Joe Perches | abb0ade | 2008-03-23 01:02:51 -0700 | [diff] [blame] | 136 | #define rdmsr(msr, val1, val2) \ |
| 137 | do { \ |
| 138 | u64 __val = native_read_msr((msr)); \ |
| 139 | (val1) = (u32)__val; \ |
| 140 | (val2) = (u32)(__val >> 32); \ |
| 141 | } while (0) |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 142 | |
Glauber de Oliveira Costa | c9dcda5 | 2008-01-30 13:31:07 +0100 | [diff] [blame] | 143 | static inline void wrmsr(unsigned msr, unsigned low, unsigned high) |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 144 | { |
Glauber de Oliveira Costa | c9dcda5 | 2008-01-30 13:31:07 +0100 | [diff] [blame] | 145 | native_write_msr(msr, low, high); |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 146 | } |
| 147 | |
Joe Perches | abb0ade | 2008-03-23 01:02:51 -0700 | [diff] [blame] | 148 | #define rdmsrl(msr, val) \ |
| 149 | ((val) = native_read_msr((msr))) |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 150 | |
Glauber de Oliveira Costa | c210d24 | 2008-01-30 13:31:07 +0100 | [diff] [blame] | 151 | #define wrmsrl(msr, val) \ |
Joe Perches | abb0ade | 2008-03-23 01:02:51 -0700 | [diff] [blame] | 152 | native_write_msr((msr), (u32)((u64)(val)), (u32)((u64)(val) >> 32)) |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 153 | |
| 154 | /* wrmsr with exception handling */ |
Glauber de Oliveira Costa | c9dcda5 | 2008-01-30 13:31:07 +0100 | [diff] [blame] | 155 | static inline int wrmsr_safe(unsigned msr, unsigned low, unsigned high) |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 156 | { |
Glauber de Oliveira Costa | c9dcda5 | 2008-01-30 13:31:07 +0100 | [diff] [blame] | 157 | return native_write_msr_safe(msr, low, high); |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | /* rdmsr with exception handling */ |
Joe Perches | abb0ade | 2008-03-23 01:02:51 -0700 | [diff] [blame] | 161 | #define rdmsr_safe(msr, p1, p2) \ |
| 162 | ({ \ |
| 163 | int __err; \ |
| 164 | u64 __val = native_read_msr_safe((msr), &__err); \ |
| 165 | (*p1) = (u32)__val; \ |
| 166 | (*p2) = (u32)(__val >> 32); \ |
| 167 | __err; \ |
| 168 | }) |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 169 | |
Andi Kleen | 1de87bd | 2008-03-22 10:59:28 +0100 | [diff] [blame] | 170 | static inline int rdmsrl_safe(unsigned msr, unsigned long long *p) |
| 171 | { |
| 172 | int err; |
| 173 | |
| 174 | *p = native_read_msr_safe(msr, &err); |
| 175 | return err; |
| 176 | } |
Borislav Petkov | 177fed1 | 2009-08-31 09:50:10 +0200 | [diff] [blame] | 177 | |
Yinghai Lu | b05f78f | 2008-08-22 01:32:50 -0700 | [diff] [blame] | 178 | static inline int rdmsrl_amd_safe(unsigned msr, unsigned long long *p) |
| 179 | { |
Borislav Petkov | 177fed1 | 2009-08-31 09:50:10 +0200 | [diff] [blame] | 180 | u32 gprs[8] = { 0 }; |
Yinghai Lu | b05f78f | 2008-08-22 01:32:50 -0700 | [diff] [blame] | 181 | int err; |
| 182 | |
Borislav Petkov | 177fed1 | 2009-08-31 09:50:10 +0200 | [diff] [blame] | 183 | gprs[1] = msr; |
| 184 | gprs[7] = 0x9c5a203a; |
| 185 | |
| 186 | err = native_rdmsr_safe_regs(gprs); |
| 187 | |
| 188 | *p = gprs[0] | ((u64)gprs[2] << 32); |
| 189 | |
Yinghai Lu | b05f78f | 2008-08-22 01:32:50 -0700 | [diff] [blame] | 190 | return err; |
| 191 | } |
Andi Kleen | 1de87bd | 2008-03-22 10:59:28 +0100 | [diff] [blame] | 192 | |
Borislav Petkov | 177fed1 | 2009-08-31 09:50:10 +0200 | [diff] [blame] | 193 | static inline int wrmsrl_amd_safe(unsigned msr, unsigned long long val) |
| 194 | { |
| 195 | u32 gprs[8] = { 0 }; |
| 196 | |
| 197 | gprs[0] = (u32)val; |
| 198 | gprs[1] = msr; |
| 199 | gprs[2] = val >> 32; |
| 200 | gprs[7] = 0x9c5a203a; |
| 201 | |
| 202 | return native_wrmsr_safe_regs(gprs); |
| 203 | } |
| 204 | |
H. Peter Anvin | 8b956bf | 2009-08-31 14:13:48 -0700 | [diff] [blame] | 205 | static inline int rdmsr_safe_regs(u32 regs[8]) |
Borislav Petkov | 132ec92 | 2009-08-31 09:50:09 +0200 | [diff] [blame] | 206 | { |
| 207 | return native_rdmsr_safe_regs(regs); |
| 208 | } |
| 209 | |
H. Peter Anvin | 8b956bf | 2009-08-31 14:13:48 -0700 | [diff] [blame] | 210 | static inline int wrmsr_safe_regs(u32 regs[8]) |
Borislav Petkov | 132ec92 | 2009-08-31 09:50:09 +0200 | [diff] [blame] | 211 | { |
| 212 | return native_wrmsr_safe_regs(regs); |
| 213 | } |
| 214 | |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 215 | #define rdtscl(low) \ |
Ken Chen | 205516c | 2008-12-16 00:32:21 -0800 | [diff] [blame] | 216 | ((low) = (u32)__native_read_tsc()) |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 217 | |
| 218 | #define rdtscll(val) \ |
Ken Chen | 205516c | 2008-12-16 00:32:21 -0800 | [diff] [blame] | 219 | ((val) = __native_read_tsc()) |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 220 | |
Joe Perches | abb0ade | 2008-03-23 01:02:51 -0700 | [diff] [blame] | 221 | #define rdpmc(counter, low, high) \ |
| 222 | do { \ |
| 223 | u64 _l = native_read_pmc((counter)); \ |
| 224 | (low) = (u32)_l; \ |
| 225 | (high) = (u32)(_l >> 32); \ |
| 226 | } while (0) |
Glauber de Oliveira Costa | c210d24 | 2008-01-30 13:31:07 +0100 | [diff] [blame] | 227 | |
Joe Perches | abb0ade | 2008-03-23 01:02:51 -0700 | [diff] [blame] | 228 | #define rdtscp(low, high, aux) \ |
| 229 | do { \ |
| 230 | unsigned long long _val = native_read_tscp(&(aux)); \ |
| 231 | (low) = (u32)_val; \ |
| 232 | (high) = (u32)(_val >> 32); \ |
| 233 | } while (0) |
Glauber de Oliveira Costa | c210d24 | 2008-01-30 13:31:07 +0100 | [diff] [blame] | 234 | |
| 235 | #define rdtscpll(val, aux) (val) = native_read_tscp(&(aux)) |
| 236 | |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 237 | #endif /* !CONFIG_PARAVIRT */ |
| 238 | |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 239 | |
Joe Perches | abb0ade | 2008-03-23 01:02:51 -0700 | [diff] [blame] | 240 | #define checking_wrmsrl(msr, val) wrmsr_safe((msr), (u32)(val), \ |
| 241 | (u32)((val) >> 32)) |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 242 | |
Sheng Yang | 5df9740 | 2009-12-16 13:48:04 +0800 | [diff] [blame^] | 243 | #define write_tsc(val1, val2) wrmsr(MSR_IA32_TSC, (val1), (val2)) |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 244 | |
Sheng Yang | 5df9740 | 2009-12-16 13:48:04 +0800 | [diff] [blame^] | 245 | #define write_rdtscp_aux(val) wrmsr(MSR_TSC_AUX, (val), 0) |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 246 | |
Borislav Petkov | 5054225 | 2009-12-11 18:14:40 +0100 | [diff] [blame] | 247 | struct msr *msrs_alloc(void); |
| 248 | void msrs_free(struct msr *msrs); |
| 249 | |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 250 | #ifdef CONFIG_SMP |
H. Peter Anvin | c6f3193 | 2008-08-25 17:27:21 -0700 | [diff] [blame] | 251 | int rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h); |
| 252 | int wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h); |
Borislav Petkov | b8a4754 | 2009-07-30 11:10:02 +0200 | [diff] [blame] | 253 | void rdmsr_on_cpus(const struct cpumask *mask, u32 msr_no, struct msr *msrs); |
| 254 | void wrmsr_on_cpus(const struct cpumask *mask, u32 msr_no, struct msr *msrs); |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 255 | int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h); |
| 256 | int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h); |
H. Peter Anvin | 8b956bf | 2009-08-31 14:13:48 -0700 | [diff] [blame] | 257 | int rdmsr_safe_regs_on_cpu(unsigned int cpu, u32 regs[8]); |
| 258 | int wrmsr_safe_regs_on_cpu(unsigned int cpu, u32 regs[8]); |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 259 | #else /* CONFIG_SMP */ |
H. Peter Anvin | c6f3193 | 2008-08-25 17:27:21 -0700 | [diff] [blame] | 260 | static inline int rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h) |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 261 | { |
| 262 | rdmsr(msr_no, *l, *h); |
H. Peter Anvin | c6f3193 | 2008-08-25 17:27:21 -0700 | [diff] [blame] | 263 | return 0; |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 264 | } |
H. Peter Anvin | c6f3193 | 2008-08-25 17:27:21 -0700 | [diff] [blame] | 265 | static inline int wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h) |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 266 | { |
| 267 | wrmsr(msr_no, l, h); |
H. Peter Anvin | c6f3193 | 2008-08-25 17:27:21 -0700 | [diff] [blame] | 268 | return 0; |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 269 | } |
Rusty Russell | 0d0fbbd | 2009-11-05 22:45:41 +1030 | [diff] [blame] | 270 | static inline void rdmsr_on_cpus(const struct cpumask *m, u32 msr_no, |
Borislav Petkov | b034c19 | 2009-05-22 13:52:19 +0200 | [diff] [blame] | 271 | struct msr *msrs) |
| 272 | { |
| 273 | rdmsr_on_cpu(0, msr_no, &(msrs[0].l), &(msrs[0].h)); |
| 274 | } |
Rusty Russell | 0d0fbbd | 2009-11-05 22:45:41 +1030 | [diff] [blame] | 275 | static inline void wrmsr_on_cpus(const struct cpumask *m, u32 msr_no, |
Borislav Petkov | b034c19 | 2009-05-22 13:52:19 +0200 | [diff] [blame] | 276 | struct msr *msrs) |
| 277 | { |
| 278 | wrmsr_on_cpu(0, msr_no, msrs[0].l, msrs[0].h); |
| 279 | } |
Joe Perches | abb0ade | 2008-03-23 01:02:51 -0700 | [diff] [blame] | 280 | static inline int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, |
| 281 | u32 *l, u32 *h) |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 282 | { |
| 283 | return rdmsr_safe(msr_no, l, h); |
| 284 | } |
| 285 | static inline int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h) |
| 286 | { |
| 287 | return wrmsr_safe(msr_no, l, h); |
| 288 | } |
H. Peter Anvin | 8b956bf | 2009-08-31 14:13:48 -0700 | [diff] [blame] | 289 | static inline int rdmsr_safe_regs_on_cpu(unsigned int cpu, u32 regs[8]) |
| 290 | { |
| 291 | return rdmsr_safe_regs(regs); |
| 292 | } |
| 293 | static inline int wrmsr_safe_regs_on_cpu(unsigned int cpu, u32 regs[8]) |
| 294 | { |
| 295 | return wrmsr_safe_regs(regs); |
| 296 | } |
Thomas Gleixner | be7baf8 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 297 | #endif /* CONFIG_SMP */ |
Glauber de Oliveira Costa | c210d24 | 2008-01-30 13:31:07 +0100 | [diff] [blame] | 298 | #endif /* __KERNEL__ */ |
H. Peter Anvin | ff55df5 | 2009-08-31 14:16:57 -0700 | [diff] [blame] | 299 | #endif /* __ASSEMBLY__ */ |
H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 300 | #endif /* _ASM_X86_MSR_H */ |