Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 #include <linux/hardirq.h>
0003 
0004 #include <asm/x86_init.h>
0005 
0006 #include <xen/interface/xen.h>
0007 #include <xen/interface/sched.h>
0008 #include <xen/interface/vcpu.h>
0009 #include <xen/features.h>
0010 #include <xen/events.h>
0011 
0012 #include <asm/xen/hypercall.h>
0013 #include <asm/xen/hypervisor.h>
0014 
0015 #include "xen-ops.h"
0016 
0017 /*
0018  * Force a proper event-channel callback from Xen after clearing the
0019  * callback mask. We do this in a very simple manner, by making a call
0020  * down into Xen. The pending flag will be checked by Xen on return.
0021  */
0022 noinstr void xen_force_evtchn_callback(void)
0023 {
0024     (void)HYPERVISOR_xen_version(0, NULL);
0025 }
0026 
0027 static void xen_safe_halt(void)
0028 {
0029     /* Blocking includes an implicit local_irq_enable(). */
0030     if (HYPERVISOR_sched_op(SCHEDOP_block, NULL) != 0)
0031         BUG();
0032 }
0033 
0034 static void xen_halt(void)
0035 {
0036     if (irqs_disabled())
0037         HYPERVISOR_vcpu_op(VCPUOP_down,
0038                    xen_vcpu_nr(smp_processor_id()), NULL);
0039     else
0040         xen_safe_halt();
0041 }
0042 
0043 static const typeof(pv_ops) xen_irq_ops __initconst = {
0044     .irq = {
0045         /* Initial interrupt flag handling only called while interrupts off. */
0046         .save_fl = __PV_IS_CALLEE_SAVE(paravirt_ret0),
0047         .irq_disable = __PV_IS_CALLEE_SAVE(paravirt_nop),
0048         .irq_enable = __PV_IS_CALLEE_SAVE(paravirt_BUG),
0049 
0050         .safe_halt = xen_safe_halt,
0051         .halt = xen_halt,
0052     },
0053 };
0054 
0055 void __init xen_init_irq_ops(void)
0056 {
0057     pv_ops.irq = xen_irq_ops.irq;
0058     x86_init.irqs.intr_init = xen_init_IRQ;
0059 }