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 err
= smp_call_function_single(cpu
, __rdmsr_safe_on_cpu
,
35 err
= err
? err
: rv
.err
;
37 err
= smp_call_function_single(cpu
, __rdmsr_on_cpu
, &rv
, 1);
45 static void __wrmsr_on_cpu(void *info
)
47 struct msr_info
*rv
= info
;
49 wrmsr(rv
->msr_no
, rv
->l
, rv
->h
);
52 static void __wrmsr_safe_on_cpu(void *info
)
54 struct msr_info
*rv
= info
;
56 rv
->err
= wrmsr_safe(rv
->msr_no
, rv
->l
, rv
->h
);
59 static int _wrmsr_on_cpu(unsigned int cpu
, u32 msr_no
, u32 l
, u32 h
, int safe
)
68 err
= smp_call_function_single(cpu
, __wrmsr_safe_on_cpu
,
70 err
= err
? err
: rv
.err
;
72 err
= smp_call_function_single(cpu
, __wrmsr_on_cpu
, &rv
, 1);
78 int wrmsr_on_cpu(unsigned int cpu
, u32 msr_no
, u32 l
, u32 h
)
80 return _wrmsr_on_cpu(cpu
, msr_no
, l
, h
, 0);
83 int rdmsr_on_cpu(unsigned int cpu
, u32 msr_no
, u32
*l
, u32
*h
)
85 return _rdmsr_on_cpu(cpu
, msr_no
, l
, h
, 0);
88 /* These "safe" variants are slower and should be used when the target MSR
89 may not actually exist. */
90 int wrmsr_safe_on_cpu(unsigned int cpu
, u32 msr_no
, u32 l
, u32 h
)
92 return _wrmsr_on_cpu(cpu
, msr_no
, l
, h
, 1);
95 int rdmsr_safe_on_cpu(unsigned int cpu
, u32 msr_no
, u32
*l
, u32
*h
)
97 return _rdmsr_on_cpu(cpu
, msr_no
, l
, h
, 1);
100 EXPORT_SYMBOL(rdmsr_on_cpu
);
101 EXPORT_SYMBOL(wrmsr_on_cpu
);
102 EXPORT_SYMBOL(rdmsr_safe_on_cpu
);
103 EXPORT_SYMBOL(wrmsr_safe_on_cpu
);