aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/i386/lib/Makefile2
-rw-r--r--arch/i386/lib/msr-on-cpu.c70
-rw-r--r--arch/x86_64/lib/Makefile2
-rw-r--r--arch/x86_64/lib/msr-on-cpu.c1
-rw-r--r--include/asm-i386/msr.h3
-rw-r--r--include/asm-x86_64/msr.h2
6 files changed, 79 insertions, 1 deletions
diff --git a/arch/i386/lib/Makefile b/arch/i386/lib/Makefile
index d86a548b8d54..0d41223472c2 100644
--- a/arch/i386/lib/Makefile
+++ b/arch/i386/lib/Makefile
@@ -7,3 +7,5 @@ lib-y = checksum.o delay.o usercopy.o getuser.o putuser.o memcpy.o strstr.o \
7 bitops.o semaphore.o 7 bitops.o semaphore.o
8 8
9lib-$(CONFIG_X86_USE_3DNOW) += mmx.o 9lib-$(CONFIG_X86_USE_3DNOW) += mmx.o
10
11obj-y = msr-on-cpu.o
diff --git a/arch/i386/lib/msr-on-cpu.c b/arch/i386/lib/msr-on-cpu.c
new file mode 100644
index 000000000000..2092ea15ba85
--- /dev/null
+++ b/arch/i386/lib/msr-on-cpu.c
@@ -0,0 +1,70 @@
1#include <linux/module.h>
2#include <linux/preempt.h>
3#include <linux/smp.h>
4#include <asm/msr.h>
5
6#ifdef CONFIG_SMP
7struct msr_info {
8 u32 msr_no;
9 u32 l, h;
10};
11
12static void __rdmsr_on_cpu(void *info)
13{
14 struct msr_info *rv = info;
15
16 rdmsr(rv->msr_no, rv->l, rv->h);
17}
18
19void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)
20{
21 preempt_disable();
22 if (smp_processor_id() == cpu)
23 rdmsr(msr_no, *l, *h);
24 else {
25 struct msr_info rv;
26
27 rv.msr_no = msr_no;
28 smp_call_function_single(cpu, __rdmsr_on_cpu, &rv, 0, 1);
29 *l = rv.l;
30 *h = rv.h;
31 }
32 preempt_enable();
33}
34
35static void __wrmsr_on_cpu(void *info)
36{
37 struct msr_info *rv = info;
38
39 wrmsr(rv->msr_no, rv->l, rv->h);
40}
41
42void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
43{
44 preempt_disable();
45 if (smp_processor_id() == cpu)
46 wrmsr(msr_no, l, h);
47 else {
48 struct msr_info rv;
49
50 rv.msr_no = msr_no;
51 rv.l = l;
52 rv.h = h;
53 smp_call_function_single(cpu, __wrmsr_on_cpu, &rv, 0, 1);
54 }
55 preempt_enable();
56}
57#else
58void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)
59{
60 rdmsr(msr_no, *l, *h);
61}
62
63void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
64{
65 wrmsr(msr_no, l, h);
66}
67#endif
68
69EXPORT_SYMBOL(rdmsr_on_cpu);
70EXPORT_SYMBOL(wrmsr_on_cpu);
diff --git a/arch/x86_64/lib/Makefile b/arch/x86_64/lib/Makefile
index b78d4170fce2..0a43f07b0290 100644
--- a/arch/x86_64/lib/Makefile
+++ b/arch/x86_64/lib/Makefile
@@ -4,7 +4,7 @@
4 4
5CFLAGS_csum-partial.o := -funroll-loops 5CFLAGS_csum-partial.o := -funroll-loops
6 6
7obj-y := io.o iomap_copy.o 7obj-y := io.o iomap_copy.o msr-on-cpu.o
8 8
9lib-y := csum-partial.o csum-copy.o csum-wrappers.o delay.o \ 9lib-y := csum-partial.o csum-copy.o csum-wrappers.o delay.o \
10 usercopy.o getuser.o putuser.o \ 10 usercopy.o getuser.o putuser.o \
diff --git a/arch/x86_64/lib/msr-on-cpu.c b/arch/x86_64/lib/msr-on-cpu.c
new file mode 100644
index 000000000000..47e0ec47c376
--- /dev/null
+++ b/arch/x86_64/lib/msr-on-cpu.c
@@ -0,0 +1 @@
#include "../../i386/lib/msr-on-cpu.c"
diff --git a/include/asm-i386/msr.h b/include/asm-i386/msr.h
index 609a3899475c..3516a1fb38e0 100644
--- a/include/asm-i386/msr.h
+++ b/include/asm-i386/msr.h
@@ -83,6 +83,9 @@ static inline void wrmsrl (unsigned long msr, unsigned long long val)
83 : "c" (counter)) 83 : "c" (counter))
84#endif /* !CONFIG_PARAVIRT */ 84#endif /* !CONFIG_PARAVIRT */
85 85
86void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h);
87void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h);
88
86/* symbolic names for some interesting MSRs */ 89/* symbolic names for some interesting MSRs */
87/* Intel defined MSRs. */ 90/* Intel defined MSRs. */
88#define MSR_IA32_P5_MC_ADDR 0 91#define MSR_IA32_P5_MC_ADDR 0
diff --git a/include/asm-x86_64/msr.h b/include/asm-x86_64/msr.h
index 3227bc93d69b..995a2b5fb26b 100644
--- a/include/asm-x86_64/msr.h
+++ b/include/asm-x86_64/msr.h
@@ -160,6 +160,8 @@ static inline unsigned int cpuid_edx(unsigned int op)
160#define MSR_IA32_UCODE_WRITE 0x79 160#define MSR_IA32_UCODE_WRITE 0x79
161#define MSR_IA32_UCODE_REV 0x8b 161#define MSR_IA32_UCODE_REV 0x8b
162 162
163void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h);
164void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h);
163 165
164#endif 166#endif
165 167