paravirt_patch_32.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #include <asm/paravirt.h>
  2. DEF_NATIVE(pv_irq_ops, irq_disable, "cli");
  3. DEF_NATIVE(pv_irq_ops, irq_enable, "sti");
  4. DEF_NATIVE(pv_irq_ops, restore_fl, "push %eax; popf");
  5. DEF_NATIVE(pv_irq_ops, save_fl, "pushf; pop %eax");
  6. DEF_NATIVE(pv_cpu_ops, iret, "iret");
  7. DEF_NATIVE(pv_cpu_ops, irq_enable_sysexit, "sti; sysexit");
  8. DEF_NATIVE(pv_mmu_ops, read_cr2, "mov %cr2, %eax");
  9. DEF_NATIVE(pv_mmu_ops, write_cr3, "mov %eax, %cr3");
  10. DEF_NATIVE(pv_mmu_ops, read_cr3, "mov %cr3, %eax");
  11. DEF_NATIVE(pv_cpu_ops, clts, "clts");
  12. DEF_NATIVE(pv_cpu_ops, read_tsc, "rdtsc");
  13. unsigned paravirt_patch_ident_32(void *insnbuf, unsigned len)
  14. {
  15. /* arg in %eax, return in %eax */
  16. return 0;
  17. }
  18. unsigned paravirt_patch_ident_64(void *insnbuf, unsigned len)
  19. {
  20. /* arg in %edx:%eax, return in %edx:%eax */
  21. return 0;
  22. }
  23. unsigned native_patch(u8 type, u16 clobbers, void *ibuf,
  24. unsigned long addr, unsigned len)
  25. {
  26. const unsigned char *start, *end;
  27. unsigned ret;
  28. #define PATCH_SITE(ops, x) \
  29. case PARAVIRT_PATCH(ops.x): \
  30. start = start_##ops##_##x; \
  31. end = end_##ops##_##x; \
  32. goto patch_site
  33. switch (type) {
  34. PATCH_SITE(pv_irq_ops, irq_disable);
  35. PATCH_SITE(pv_irq_ops, irq_enable);
  36. PATCH_SITE(pv_irq_ops, restore_fl);
  37. PATCH_SITE(pv_irq_ops, save_fl);
  38. PATCH_SITE(pv_cpu_ops, iret);
  39. PATCH_SITE(pv_cpu_ops, irq_enable_sysexit);
  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_cpu_ops, read_tsc);
  45. patch_site:
  46. ret = paravirt_patch_insns(ibuf, len, start, end);
  47. break;
  48. default:
  49. ret = paravirt_patch_default(type, clobbers, ibuf, addr, len);
  50. break;
  51. }
  52. #undef PATCH_SITE
  53. return ret;
  54. }