x86, 32-bit: trim memory not covered by wb mtrrs
[deliverable/linux.git] / arch / x86 / kernel / paravirt_patch_64.c
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 }
This page took 0.030858 seconds and 5 git commands to generate.