aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel
diff options
context:
space:
mode:
authorGlauber de Oliveira Costa <gcosta@redhat.com>2008-01-30 07:32:10 -0500
committerIngo Molnar <mingo@elte.hu>2008-01-30 07:32:10 -0500
commit2f485ef568372af4680c4e2f8490efb9f2523b05 (patch)
treed1a244d31333524d2636affe4a862b8058ae4f92 /arch/x86/kernel
parent21438f7c138f0b893a32df3cc77434e39a2145f8 (diff)
x86: move patching code to arch-specific file.
The core patching code for paravirt is sufficiently different among i386 and x86_64, and we move them to specific files. Signed-off-by: Glauber de Oliveira Costa <gcosta@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r--arch/x86/kernel/Makefile_322
-rw-r--r--arch/x86/kernel/paravirt.c50
-rw-r--r--arch/x86/kernel/paravirt_patch_32.c49
3 files changed, 50 insertions, 51 deletions
diff --git a/arch/x86/kernel/Makefile_32 b/arch/x86/kernel/Makefile_32
index cfb71a5deb19..86c6327798b2 100644
--- a/arch/x86/kernel/Makefile_32
+++ b/arch/x86/kernel/Makefile_32
@@ -48,7 +48,7 @@ obj-$(CONFIG_K8_NB) += k8.o
48obj-$(CONFIG_MGEODE_LX) += geode_32.o mfgpt_32.o 48obj-$(CONFIG_MGEODE_LX) += geode_32.o mfgpt_32.o
49 49
50obj-$(CONFIG_VMI) += vmi_32.o vmiclock_32.o 50obj-$(CONFIG_VMI) += vmi_32.o vmiclock_32.o
51obj-$(CONFIG_PARAVIRT) += paravirt.o 51obj-$(CONFIG_PARAVIRT) += paravirt.o paravirt_patch_32.o
52obj-y += pcspeaker.o 52obj-y += pcspeaker.o
53 53
54obj-$(CONFIG_SCx200) += scx200_32.o 54obj-$(CONFIG_SCx200) += scx200_32.o
diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
index e7c17cc4a99e..864be0498a32 100644
--- a/arch/x86/kernel/paravirt.c
+++ b/arch/x86/kernel/paravirt.c
@@ -58,59 +58,9 @@ char *memory_setup(void)
58 extern const char start_##ops##_##name[], end_##ops##_##name[]; \ 58 extern const char start_##ops##_##name[], end_##ops##_##name[]; \
59 asm("start_" #ops "_" #name ": " code "; end_" #ops "_" #name ":") 59 asm("start_" #ops "_" #name ": " code "; end_" #ops "_" #name ":")
60 60
61DEF_NATIVE(pv_irq_ops, irq_disable, "cli");
62DEF_NATIVE(pv_irq_ops, irq_enable, "sti");
63DEF_NATIVE(pv_irq_ops, restore_fl, "push %eax; popf");
64DEF_NATIVE(pv_irq_ops, save_fl, "pushf; pop %eax");
65DEF_NATIVE(pv_cpu_ops, iret, "iret");
66DEF_NATIVE(pv_cpu_ops, irq_enable_syscall_ret, "sti; sysexit");
67DEF_NATIVE(pv_mmu_ops, read_cr2, "mov %cr2, %eax");
68DEF_NATIVE(pv_mmu_ops, write_cr3, "mov %eax, %cr3");
69DEF_NATIVE(pv_mmu_ops, read_cr3, "mov %cr3, %eax");
70DEF_NATIVE(pv_cpu_ops, clts, "clts");
71DEF_NATIVE(pv_cpu_ops, read_tsc, "rdtsc");
72
73/* Undefined instruction for dealing with missing ops pointers. */ 61/* Undefined instruction for dealing with missing ops pointers. */
74static const unsigned char ud2a[] = { 0x0f, 0x0b }; 62static const unsigned char ud2a[] = { 0x0f, 0x0b };
75 63
76static unsigned native_patch(u8 type, u16 clobbers, void *ibuf,
77 unsigned long addr, unsigned len)
78{
79 const unsigned char *start, *end;
80 unsigned ret;
81
82 switch(type) {
83#define SITE(ops, x) \
84 case PARAVIRT_PATCH(ops.x): \
85 start = start_##ops##_##x; \
86 end = end_##ops##_##x; \
87 goto patch_site
88
89 SITE(pv_irq_ops, irq_disable);
90 SITE(pv_irq_ops, irq_enable);
91 SITE(pv_irq_ops, restore_fl);
92 SITE(pv_irq_ops, save_fl);
93 SITE(pv_cpu_ops, iret);
94 SITE(pv_cpu_ops, irq_enable_syscall_ret);
95 SITE(pv_mmu_ops, read_cr2);
96 SITE(pv_mmu_ops, read_cr3);
97 SITE(pv_mmu_ops, write_cr3);
98 SITE(pv_cpu_ops, clts);
99 SITE(pv_cpu_ops, read_tsc);
100#undef SITE
101
102 patch_site:
103 ret = paravirt_patch_insns(ibuf, len, start, end);
104 break;
105
106 default:
107 ret = paravirt_patch_default(type, clobbers, ibuf, addr, len);
108 break;
109 }
110
111 return ret;
112}
113
114unsigned paravirt_patch_nop(void) 64unsigned paravirt_patch_nop(void)
115{ 65{
116 return 0; 66 return 0;
diff --git a/arch/x86/kernel/paravirt_patch_32.c b/arch/x86/kernel/paravirt_patch_32.c
new file mode 100644
index 000000000000..82fc5fcab4f4
--- /dev/null
+++ b/arch/x86/kernel/paravirt_patch_32.c
@@ -0,0 +1,49 @@
1#include <asm/paravirt.h>
2
3DEF_NATIVE(pv_irq_ops, irq_disable, "cli");
4DEF_NATIVE(pv_irq_ops, irq_enable, "sti");
5DEF_NATIVE(pv_irq_ops, restore_fl, "push %eax; popf");
6DEF_NATIVE(pv_irq_ops, save_fl, "pushf; pop %eax");
7DEF_NATIVE(pv_cpu_ops, iret, "iret");
8DEF_NATIVE(pv_cpu_ops, irq_enable_syscall_ret, "sti; sysexit");
9DEF_NATIVE(pv_mmu_ops, read_cr2, "mov %cr2, %eax");
10DEF_NATIVE(pv_mmu_ops, write_cr3, "mov %eax, %cr3");
11DEF_NATIVE(pv_mmu_ops, read_cr3, "mov %cr3, %eax");
12DEF_NATIVE(pv_cpu_ops, clts, "clts");
13DEF_NATIVE(pv_cpu_ops, read_tsc, "rdtsc");
14
15unsigned native_patch(u8 type, u16 clobbers, void *ibuf,
16 unsigned long addr, unsigned len)
17{
18 const unsigned char *start, *end;
19 unsigned ret;
20
21#define PATCH_SITE(ops, x) \
22 case PARAVIRT_PATCH(ops.x): \
23 start = start_##ops##_##x; \
24 end = end_##ops##_##x; \
25 goto patch_site
26 switch(type) {
27 PATCH_SITE(pv_irq_ops, irq_disable);
28 PATCH_SITE(pv_irq_ops, irq_enable);
29 PATCH_SITE(pv_irq_ops, restore_fl);
30 PATCH_SITE(pv_irq_ops, save_fl);
31 PATCH_SITE(pv_cpu_ops, iret);
32 PATCH_SITE(pv_cpu_ops, irq_enable_syscall_ret);
33 PATCH_SITE(pv_mmu_ops, read_cr2);
34 PATCH_SITE(pv_mmu_ops, read_cr3);
35 PATCH_SITE(pv_mmu_ops, write_cr3);
36 PATCH_SITE(pv_cpu_ops, clts);
37 PATCH_SITE(pv_cpu_ops, read_tsc);
38
39 patch_site:
40 ret = paravirt_patch_insns(ibuf, len, start, end);
41 break;
42
43 default:
44 ret = paravirt_patch_default(type, clobbers, ibuf, addr, len);
45 break;
46 }
47#undef PATCH_SITE
48 return ret;
49}