diff options
author | Paul Mackerras <paulus@samba.org> | 2008-01-30 19:25:51 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2008-01-30 19:25:51 -0500 |
commit | bd45ac0c5daae35e7c71138172e63df5cf644cf6 (patch) | |
tree | 5eb5a599bf6a9d7a8a34e802db932aa9e9555de4 /arch/x86/kernel/paravirt_patch_64.c | |
parent | 4eece4ccf997c0e6d8fdad3d842e37b16b8d705f (diff) | |
parent | 5bdeae46be6dfe9efa44a548bd622af325f4bdb4 (diff) |
Merge branch 'linux-2.6'
Diffstat (limited to 'arch/x86/kernel/paravirt_patch_64.c')
-rw-r--r-- | arch/x86/kernel/paravirt_patch_64.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/arch/x86/kernel/paravirt_patch_64.c b/arch/x86/kernel/paravirt_patch_64.c new file mode 100644 index 000000000000..7d904e138d7e --- /dev/null +++ b/arch/x86/kernel/paravirt_patch_64.c | |||
@@ -0,0 +1,57 @@ | |||
1 | #include <asm/paravirt.h> | ||
2 | #include <asm/asm-offsets.h> | ||
3 | #include <linux/stringify.h> | ||
4 | |||
5 | DEF_NATIVE(pv_irq_ops, irq_disable, "cli"); | ||
6 | DEF_NATIVE(pv_irq_ops, irq_enable, "sti"); | ||
7 | DEF_NATIVE(pv_irq_ops, restore_fl, "pushq %rdi; popfq"); | ||
8 | DEF_NATIVE(pv_irq_ops, save_fl, "pushfq; popq %rax"); | ||
9 | DEF_NATIVE(pv_cpu_ops, iret, "iretq"); | ||
10 | DEF_NATIVE(pv_mmu_ops, read_cr2, "movq %cr2, %rax"); | ||
11 | DEF_NATIVE(pv_mmu_ops, read_cr3, "movq %cr3, %rax"); | ||
12 | DEF_NATIVE(pv_mmu_ops, write_cr3, "movq %rdi, %cr3"); | ||
13 | DEF_NATIVE(pv_mmu_ops, flush_tlb_single, "invlpg (%rdi)"); | ||
14 | DEF_NATIVE(pv_cpu_ops, clts, "clts"); | ||
15 | DEF_NATIVE(pv_cpu_ops, wbinvd, "wbinvd"); | ||
16 | |||
17 | /* the three commands give us more control to how to return from a syscall */ | ||
18 | DEF_NATIVE(pv_cpu_ops, irq_enable_syscall_ret, "movq %gs:" __stringify(pda_oldrsp) ", %rsp; swapgs; sysretq;"); | ||
19 | DEF_NATIVE(pv_cpu_ops, swapgs, "swapgs"); | ||
20 | |||
21 | unsigned native_patch(u8 type, u16 clobbers, void *ibuf, | ||
22 | unsigned long addr, unsigned len) | ||
23 | { | ||
24 | const unsigned char *start, *end; | ||
25 | unsigned ret; | ||
26 | |||
27 | #define PATCH_SITE(ops, x) \ | ||
28 | case PARAVIRT_PATCH(ops.x): \ | ||
29 | start = start_##ops##_##x; \ | ||
30 | end = end_##ops##_##x; \ | ||
31 | goto patch_site | ||
32 | switch(type) { | ||
33 | PATCH_SITE(pv_irq_ops, restore_fl); | ||
34 | PATCH_SITE(pv_irq_ops, save_fl); | ||
35 | PATCH_SITE(pv_irq_ops, irq_enable); | ||
36 | PATCH_SITE(pv_irq_ops, irq_disable); | ||
37 | PATCH_SITE(pv_cpu_ops, iret); | ||
38 | PATCH_SITE(pv_cpu_ops, irq_enable_syscall_ret); | ||
39 | PATCH_SITE(pv_cpu_ops, swapgs); | ||
40 | PATCH_SITE(pv_mmu_ops, read_cr2); | ||
41 | PATCH_SITE(pv_mmu_ops, read_cr3); | ||
42 | PATCH_SITE(pv_mmu_ops, write_cr3); | ||
43 | PATCH_SITE(pv_cpu_ops, clts); | ||
44 | PATCH_SITE(pv_mmu_ops, flush_tlb_single); | ||
45 | PATCH_SITE(pv_cpu_ops, wbinvd); | ||
46 | |||
47 | patch_site: | ||
48 | ret = paravirt_patch_insns(ibuf, len, start, end); | ||
49 | break; | ||
50 | |||
51 | default: | ||
52 | ret = paravirt_patch_default(type, clobbers, ibuf, addr, len); | ||
53 | break; | ||
54 | } | ||
55 | #undef PATCH_SITE | ||
56 | return ret; | ||
57 | } | ||