diff options
author | Glauber de Oliveira Costa <gcosta@redhat.com> | 2008-01-30 07:32:10 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-01-30 07:32:10 -0500 |
commit | 53fd13cff04ce27ff3e8d3eb7e5ad4f56b580f2f (patch) | |
tree | 3ccca4b41a17c4c34c41455f07ef0f422ba389d2 | |
parent | 2f485ef568372af4680c4e2f8490efb9f2523b05 (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_64 | 1 | ||||
-rw-r--r-- | arch/x86/kernel/paravirt_patch_64.c | 56 |
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 | |||
41 | obj-$(CONFIG_K8_NB) += k8.o | 41 | obj-$(CONFIG_K8_NB) += k8.o |
42 | obj-$(CONFIG_AUDIT) += audit_64.o | 42 | obj-$(CONFIG_AUDIT) += audit_64.o |
43 | obj-$(CONFIG_EFI) += efi.o efi_64.o efi_stub_64.o | 43 | obj-$(CONFIG_EFI) += efi.o efi_64.o efi_stub_64.o |
44 | obj-$(CONFIG_PARAVIRT) += paravirt.o paravirt_patch_64.o | ||
44 | 45 | ||
45 | obj-$(CONFIG_MODULES) += module_64.o | 46 | obj-$(CONFIG_MODULES) += module_64.o |
46 | obj-$(CONFIG_PCI) += early-quirks.o | 47 | obj-$(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 | |||
4 | DEF_NATIVE(pv_irq_ops, irq_disable, "cli"); | ||
5 | DEF_NATIVE(pv_irq_ops, irq_enable, "sti"); | ||
6 | DEF_NATIVE(pv_irq_ops, restore_fl, "pushq %rdi; popfq"); | ||
7 | DEF_NATIVE(pv_irq_ops, save_fl, "pushfq; popq %rax"); | ||
8 | DEF_NATIVE(pv_cpu_ops, iret, "iretq"); | ||
9 | DEF_NATIVE(pv_mmu_ops, read_cr2, "movq %cr2, %rax"); | ||
10 | DEF_NATIVE(pv_mmu_ops, read_cr3, "movq %cr3, %rax"); | ||
11 | DEF_NATIVE(pv_mmu_ops, write_cr3, "movq %rdi, %cr3"); | ||
12 | DEF_NATIVE(pv_mmu_ops, flush_tlb_single, "invlpg (%rdi)"); | ||
13 | DEF_NATIVE(pv_cpu_ops, clts, "clts"); | ||
14 | DEF_NATIVE(pv_cpu_ops, wbinvd, "wbinvd"); | ||
15 | |||
16 | /* the three commands give us more control to how to return from a syscall */ | ||
17 | DEF_NATIVE(pv_cpu_ops, irq_enable_syscall_ret, "movq %gs:" __stringify(pda_oldrsp) ", %rsp; swapgs; sysretq;"); | ||
18 | DEF_NATIVE(pv_cpu_ops, swapgs, "swapgs"); | ||
19 | |||
20 | unsigned 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 | } | ||