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 __wrmsr_on_cpu(void *info)
21 struct msr_info *rv = info;
23 wrmsr(rv->msr_no, rv->l, rv->h);
26 int rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)
32 err = smp_call_function_single(cpu, __rdmsr_on_cpu, &rv, 1);
39 int wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
47 err = smp_call_function_single(cpu, __wrmsr_on_cpu, &rv, 1);
52 /* These "safe" variants are slower and should be used when the target MSR
53 may not actually exist. */
54 static void __rdmsr_safe_on_cpu(void *info)
56 struct msr_info *rv = info;
58 rv->err = rdmsr_safe(rv->msr_no, &rv->l, &rv->h);
61 static void __wrmsr_safe_on_cpu(void *info)
63 struct msr_info *rv = info;
65 rv->err = wrmsr_safe(rv->msr_no, rv->l, rv->h);
68 int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)
74 err = smp_call_function_single(cpu, __rdmsr_safe_on_cpu, &rv, 1);
78 return err ? err : rv.err;
81 int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
89 err = smp_call_function_single(cpu, __wrmsr_safe_on_cpu, &rv, 1);
91 return err ? err : rv.err;
94 EXPORT_SYMBOL(rdmsr_on_cpu);
95 EXPORT_SYMBOL(wrmsr_on_cpu);
96 EXPORT_SYMBOL(rdmsr_safe_on_cpu);
97 EXPORT_SYMBOL(wrmsr_safe_on_cpu);