irq.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // SPDX-License-Identifier: GPL-2.0
  2. #include <linux/hardirq.h>
  3. #include <asm/x86_init.h>
  4. #include <xen/interface/xen.h>
  5. #include <xen/interface/sched.h>
  6. #include <xen/interface/vcpu.h>
  7. #include <xen/features.h>
  8. #include <xen/events.h>
  9. #include <asm/xen/hypercall.h>
  10. #include <asm/xen/hypervisor.h>
  11. #include "xen-ops.h"
  12. /*
  13. * Force a proper event-channel callback from Xen after clearing the
  14. * callback mask. We do this in a very simple manner, by making a call
  15. * down into Xen. The pending flag will be checked by Xen on return.
  16. */
  17. noinstr void xen_force_evtchn_callback(void)
  18. {
  19. (void)HYPERVISOR_xen_version(0, NULL);
  20. }
  21. static void xen_safe_halt(void)
  22. {
  23. /* Blocking includes an implicit local_irq_enable(). */
  24. if (HYPERVISOR_sched_op(SCHEDOP_block, NULL) != 0)
  25. BUG();
  26. }
  27. static void xen_halt(void)
  28. {
  29. if (irqs_disabled())
  30. HYPERVISOR_vcpu_op(VCPUOP_down,
  31. xen_vcpu_nr(smp_processor_id()), NULL);
  32. else
  33. xen_safe_halt();
  34. }
  35. static const typeof(pv_ops) xen_irq_ops __initconst = {
  36. .irq = {
  37. /* Initial interrupt flag handling only called while interrupts off. */
  38. .save_fl = __PV_IS_CALLEE_SAVE(paravirt_ret0),
  39. .irq_disable = __PV_IS_CALLEE_SAVE(paravirt_nop),
  40. .irq_enable = __PV_IS_CALLEE_SAVE(paravirt_BUG),
  41. .safe_halt = xen_safe_halt,
  42. .halt = xen_halt,
  43. },
  44. };
  45. void __init xen_init_irq_ops(void)
  46. {
  47. pv_ops.irq = xen_irq_ops.irq;
  48. x86_init.irqs.intr_init = xen_init_IRQ;
  49. }