Linux 3.8-rc7
[cris-mirror.git] / arch / x86 / kernel / paravirt_patch_32.c
blobd9f32e6d6ab65476be60c34d06c522215b83a26b
1 #include <asm/paravirt.h>
3 DEF_NATIVE(pv_irq_ops, irq_disable, "cli");
4 DEF_NATIVE(pv_irq_ops, irq_enable, "sti");
5 DEF_NATIVE(pv_irq_ops, restore_fl, "push %eax; popf");
6 DEF_NATIVE(pv_irq_ops, save_fl, "pushf; pop %eax");
7 DEF_NATIVE(pv_cpu_ops, iret, "iret");
8 DEF_NATIVE(pv_cpu_ops, irq_enable_sysexit, "sti; sysexit");
9 DEF_NATIVE(pv_mmu_ops, read_cr2, "mov %cr2, %eax");
10 DEF_NATIVE(pv_mmu_ops, write_cr3, "mov %eax, %cr3");
11 DEF_NATIVE(pv_mmu_ops, read_cr3, "mov %cr3, %eax");
12 DEF_NATIVE(pv_cpu_ops, clts, "clts");
13 DEF_NATIVE(pv_cpu_ops, read_tsc, "rdtsc");
15 unsigned paravirt_patch_ident_32(void *insnbuf, unsigned len)
17 /* arg in %eax, return in %eax */
18 return 0;
21 unsigned paravirt_patch_ident_64(void *insnbuf, unsigned len)
23 /* arg in %edx:%eax, return in %edx:%eax */
24 return 0;
27 unsigned native_patch(u8 type, u16 clobbers, void *ibuf,
28 unsigned long addr, unsigned len)
30 const unsigned char *start, *end;
31 unsigned ret;
33 #define PATCH_SITE(ops, x) \
34 case PARAVIRT_PATCH(ops.x): \
35 start = start_##ops##_##x; \
36 end = end_##ops##_##x; \
37 goto patch_site
38 switch (type) {
39 PATCH_SITE(pv_irq_ops, irq_disable);
40 PATCH_SITE(pv_irq_ops, irq_enable);
41 PATCH_SITE(pv_irq_ops, restore_fl);
42 PATCH_SITE(pv_irq_ops, save_fl);
43 PATCH_SITE(pv_cpu_ops, iret);
44 PATCH_SITE(pv_cpu_ops, irq_enable_sysexit);
45 PATCH_SITE(pv_mmu_ops, read_cr2);
46 PATCH_SITE(pv_mmu_ops, read_cr3);
47 PATCH_SITE(pv_mmu_ops, write_cr3);
48 PATCH_SITE(pv_cpu_ops, clts);
49 PATCH_SITE(pv_cpu_ops, read_tsc);
51 patch_site:
52 ret = paravirt_patch_insns(ibuf, len, start, end);
53 break;
55 default:
56 ret = paravirt_patch_default(type, clobbers, ibuf, addr, len);
57 break;
59 #undef PATCH_SITE
60 return ret;