fallback.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #include <linux/kernel.h>
  2. #include <linux/string.h>
  3. #include <linux/bug.h>
  4. #include <linux/export.h>
  5. #include <asm/hypervisor.h>
  6. #include <asm/xen/hypercall.h>
  7. int xen_event_channel_op_compat(int cmd, void *arg)
  8. {
  9. struct evtchn_op op;
  10. int rc;
  11. op.cmd = cmd;
  12. memcpy(&op.u, arg, sizeof(op.u));
  13. rc = _hypercall1(int, event_channel_op_compat, &op);
  14. switch (cmd) {
  15. case EVTCHNOP_close:
  16. case EVTCHNOP_send:
  17. case EVTCHNOP_bind_vcpu:
  18. case EVTCHNOP_unmask:
  19. /* no output */
  20. break;
  21. #define COPY_BACK(eop) \
  22. case EVTCHNOP_##eop: \
  23. memcpy(arg, &op.u.eop, sizeof(op.u.eop)); \
  24. break
  25. COPY_BACK(bind_interdomain);
  26. COPY_BACK(bind_virq);
  27. COPY_BACK(bind_pirq);
  28. COPY_BACK(status);
  29. COPY_BACK(alloc_unbound);
  30. COPY_BACK(bind_ipi);
  31. #undef COPY_BACK
  32. default:
  33. WARN_ON(rc != -ENOSYS);
  34. break;
  35. }
  36. return rc;
  37. }
  38. EXPORT_SYMBOL_GPL(xen_event_channel_op_compat);
  39. int xen_physdev_op_compat(int cmd, void *arg)
  40. {
  41. struct physdev_op op;
  42. int rc;
  43. op.cmd = cmd;
  44. memcpy(&op.u, arg, sizeof(op.u));
  45. rc = _hypercall1(int, physdev_op_compat, &op);
  46. switch (cmd) {
  47. case PHYSDEVOP_IRQ_UNMASK_NOTIFY:
  48. case PHYSDEVOP_set_iopl:
  49. case PHYSDEVOP_set_iobitmap:
  50. case PHYSDEVOP_apic_write:
  51. /* no output */
  52. break;
  53. #define COPY_BACK(pop, fld) \
  54. case PHYSDEVOP_##pop: \
  55. memcpy(arg, &op.u.fld, sizeof(op.u.fld)); \
  56. break
  57. COPY_BACK(irq_status_query, irq_status_query);
  58. COPY_BACK(apic_read, apic_op);
  59. COPY_BACK(ASSIGN_VECTOR, irq_op);
  60. #undef COPY_BACK
  61. default:
  62. WARN_ON(rc != -ENOSYS);
  63. break;
  64. }
  65. return rc;
  66. }
  67. EXPORT_SYMBOL_GPL(xen_physdev_op_compat);