1 #include <linux/module.h>
2 #include <linux/preempt.h>
12 static void __rdmsr_on_cpu(void *info
)
14 struct msr_info
*rv
= info
;
16 rdmsr(rv
->msr_no
, rv
->l
, rv
->h
);
19 static void __rdmsr_safe_on_cpu(void *info
)
21 struct msr_info
*rv
= info
;
23 rv
->err
= rdmsr_safe(rv
->msr_no
, &rv
->l
, &rv
->h
);
26 static int _rdmsr_on_cpu(unsigned int cpu
, u32 msr_no
, u32
*l
, u32
*h
, int safe
)
33 smp_call_function_single(cpu
, __rdmsr_safe_on_cpu
, &rv
, 1);
36 smp_call_function_single(cpu
, __rdmsr_on_cpu
, &rv
, 1);
44 static void __wrmsr_on_cpu(void *info
)
46 struct msr_info
*rv
= info
;
48 wrmsr(rv
->msr_no
, rv
->l
, rv
->h
);
51 static void __wrmsr_safe_on_cpu(void *info
)
53 struct msr_info
*rv
= info
;
55 rv
->err
= wrmsr_safe(rv
->msr_no
, rv
->l
, rv
->h
);
58 static int _wrmsr_on_cpu(unsigned int cpu
, u32 msr_no
, u32 l
, u32 h
, int safe
)
67 smp_call_function_single(cpu
, __wrmsr_safe_on_cpu
, &rv
, 1);
70 smp_call_function_single(cpu
, __wrmsr_on_cpu
, &rv
, 1);
76 void wrmsr_on_cpu(unsigned int cpu
, u32 msr_no
, u32 l
, u32 h
)
78 _wrmsr_on_cpu(cpu
, msr_no
, l
, h
, 0);
81 void rdmsr_on_cpu(unsigned int cpu
, u32 msr_no
, u32
*l
, u32
*h
)
83 _rdmsr_on_cpu(cpu
, msr_no
, l
, h
, 0);
86 /* These "safe" variants are slower and should be used when the target MSR
87 may not actually exist. */
88 int wrmsr_safe_on_cpu(unsigned int cpu
, u32 msr_no
, u32 l
, u32 h
)
90 return _wrmsr_on_cpu(cpu
, msr_no
, l
, h
, 1);
93 int rdmsr_safe_on_cpu(unsigned int cpu
, u32 msr_no
, u32
*l
, u32
*h
)
95 return _rdmsr_on_cpu(cpu
, msr_no
, l
, h
, 1);
98 EXPORT_SYMBOL(rdmsr_on_cpu
);
99 EXPORT_SYMBOL(wrmsr_on_cpu
);
100 EXPORT_SYMBOL(rdmsr_safe_on_cpu
);
101 EXPORT_SYMBOL(wrmsr_safe_on_cpu
);