2 * Asm versions of Xen pv-ops, suitable for direct use.
4 * We only bother with direct forms (ie, vcpu in percpu data) of the
5 * operations here; the indirect forms are better handled in C.
8 #include <asm/asm-offsets.h>
9 #include <asm/percpu.h>
10 #include <asm/processor-flags.h>
11 #include <asm/frame.h>
13 #include <linux/linkage.h>
16 * Enable events. This clears the event mask and tests the pending
17 * event status with one and operation. If there are pending events,
18 * then enter the hypervisor to get them handled.
20 ENTRY(xen_irq_enable_direct)
23 movb $0, PER_CPU_VAR(xen_vcpu_info) + XEN_vcpu_info_mask
26 * Preempt here doesn't matter because that will deal with any
27 * pending interrupts. The pending check may end up being run
28 * on the wrong CPU, but that doesn't hurt.
31 /* Test for pending */
32 testb $0xff, PER_CPU_VAR(xen_vcpu_info) + XEN_vcpu_info_pending
39 ENDPROC(xen_irq_enable_direct)
43 * Disabling events is simply a matter of making the event mask
46 ENTRY(xen_irq_disable_direct)
47 movb $1, PER_CPU_VAR(xen_vcpu_info) + XEN_vcpu_info_mask
49 ENDPROC(xen_irq_disable_direct)
52 * (xen_)save_fl is used to get the current interrupt enable status.
53 * Callers expect the status to be in X86_EFLAGS_IF, and other bits
54 * may be set in the return value. We take advantage of this by
55 * making sure that X86_EFLAGS_IF has the right value (and other bits
56 * in that byte are 0), but other bits in the return value are
57 * undefined. We need to toggle the state of the bit, because Xen and
58 * x86 use opposite senses (mask vs enable).
60 ENTRY(xen_save_fl_direct)
61 testb $0xff, PER_CPU_VAR(xen_vcpu_info) + XEN_vcpu_info_mask
65 ENDPROC(xen_save_fl_direct)
69 * In principle the caller should be passing us a value return from
70 * xen_save_fl_direct, but for robustness sake we test only the
71 * X86_EFLAGS_IF flag rather than the whole byte. After setting the
72 * interrupt mask state, it checks for unmasked pending events and
73 * enters the hypervisor to get them delivered if so.
75 ENTRY(xen_restore_fl_direct)
78 testw $X86_EFLAGS_IF, %di
80 testb $X86_EFLAGS_IF>>8, %ah
82 setz PER_CPU_VAR(xen_vcpu_info) + XEN_vcpu_info_mask
84 * Preempt here doesn't matter because that will deal with any
85 * pending interrupts. The pending check may end up being run
86 * on the wrong CPU, but that doesn't hurt.
89 /* check for unmasked and pending */
90 cmpw $0x0001, PER_CPU_VAR(xen_vcpu_info) + XEN_vcpu_info_pending
96 ENDPROC(xen_restore_fl_direct)
100 * Force an event check by making a hypercall, but preserve regs
101 * before making the call.
109 call xen_force_evtchn_callback
123 call xen_force_evtchn_callback
136 ENDPROC(check_events)