aboutsummaryrefslogtreecommitdiffstats
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
commit53fd13cff04ce27ff3e8d3eb7e5ad4f56b580f2f (patch)
tree3ccca4b41a17c4c34c41455f07ef0f422ba389d2
parent2f485ef568372af4680c4e2f8490efb9f2523b05 (diff)
x86: patching functions on 64-bit
Like i386, x86_64 also need to include its own patching function. (Well, if you're not in a hurry, and don't care about speed, you don't really _need_ ;-)) So here they are. Not much different in essence from i386 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>
-rw-r--r--arch/x86/kernel/Makefile_641
-rw-r--r--arch/x86/kernel/paravirt_patch_64.c56
2 files changed, 57 insertions, 0 deletions
diff --git a/arch/x86/kernel/Makefile_64 b/arch/x86/kernel/Makefile_64
index 7fcf972aa5d6..b8f9d13eb5e3 100644
--- a/arch/x86/kernel/Makefile_64
+++ b/arch/x86/kernel/Makefile_64
@@ -41,6 +41,7 @@ obj-$(CONFIG_X86_VSMP) += vsmp_64.o
41obj-$(CONFIG_K8_NB) += k8.o 41obj-$(CONFIG_K8_NB) += k8.o
42obj-$(CONFIG_AUDIT) += audit_64.o 42obj-$(CONFIG_AUDIT) += audit_64.o
43obj-$(CONFIG_EFI) += efi.o efi_64.o efi_stub_64.o 43obj-$(CONFIG_EFI) += efi.o efi_64.o efi_stub_64.o
44obj-$(CONFIG_PARAVIRT) += paravirt.o paravirt_patch_64.o
44 45
45obj-$(CONFIG_MODULES) += module_64.o 46obj-$(CONFIG_MODULES) += module_64.o
46obj-$(CONFIG_PCI) += early-quirks.o 47obj-$(CONFIG_PCI) += early-quirks.o
diff --git a/arch/x86/kernel/paravirt_patch_64.c b/arch/x86/kernel/paravirt_patch_64.c
new file mode 100644
index 000000000000..cbfc4f3069e3
--- /dev/null
+++ b/arch/x86/kernel/paravirt_patch_64.c
@@ -0,0 +1,56 @@
1#include <asm/paravirt.h>
2#include <asm/asm-offsets.h>
3
4DEF_NATIVE(pv_irq_ops, irq_disable, "cli");
5DEF_NATIVE(pv_irq_ops, irq_enable, "sti");
6DEF_NATIVE(pv_irq_ops, restore_fl, "pushq %rdi; popfq");
7DEF_NATIVE(pv_irq_ops, save_fl, "pushfq; popq %rax");
8DEF_NATIVE(pv_cpu_ops, iret, "iretq");
9DEF_NATIVE(pv_mmu_ops, read_cr2, "movq %cr2, %rax");
10DEF_NATIVE(pv_mmu_ops, read_cr3, "movq %cr3, %rax");
11DEF_NATIVE(pv_mmu_ops, write_cr3, "movq %rdi, %cr3");
12DEF_NATIVE(pv_mmu_ops, flush_tlb_single, "invlpg (%rdi)");
13DEF_NATIVE(pv_cpu_ops, clts, "clts");
14DEF_NATIVE(pv_cpu_ops, wbinvd, "wbinvd");
15
16/* the three commands give us more control to how to return from a syscall */
17DEF_NATIVE(pv_cpu_ops, irq_enable_syscall_ret, "movq %gs:" __stringify(pda_oldrsp) ", %rsp; swapgs; sysretq;");
18DEF_NATIVE(pv_cpu_ops, swapgs, "swapgs");
19
20unsigned native_patch(u8 type, u16 clobbers, void *ibuf,
21 unsigned long addr, unsigned len)
22{
23 const unsigned char *start, *end;
24 unsigned ret;
25
26#define PATCH_SITE(ops, x) \
27 case PARAVIRT_PATCH(ops.x): \
28 start = start_##ops##_##x; \
29 end = end_##ops##_##x; \
30 goto patch_site
31 switch(type) {
32 PATCH_SITE(pv_irq_ops, restore_fl);
33 PATCH_SITE(pv_irq_ops, save_fl);
34 PATCH_SITE(pv_irq_ops, irq_enable);
35 PATCH_SITE(pv_irq_ops, irq_disable);
36 PATCH_SITE(pv_cpu_ops, iret);
37 PATCH_SITE(pv_cpu_ops, irq_enable_syscall_ret);
38 PATCH_SITE(pv_cpu_ops, swapgs);
39 PATCH_SITE(pv_mmu_ops, read_cr2);
40 PATCH_SITE(pv_mmu_ops, read_cr3);
41 PATCH_SITE(pv_mmu_ops, write_cr3);
42 PATCH_SITE(pv_cpu_ops, clts);
43 PATCH_SITE(pv_mmu_ops, flush_tlb_single);
44 PATCH_SITE(pv_cpu_ops, wbinvd);
45
46 patch_site:
47 ret = paravirt_patch_insns(ibuf, len, start, end);
48 break;
49
50 default:
51 ret = paravirt_patch_default(type, clobbers, ibuf, addr, len);
52 break;
53 }
54#undef PATCH_SITE
55 return ret;
56}