1 #include <linux/module.h>
3 #include <asm/irqflags.h>
4 #include <asm/hypervisor.h>
6 /* interrupt control.. */
9 * The use of 'barrier' in the following reflects their use as local-lock
10 * operations. Reentrancy must be prevented (e.g., __cli()) /before/ following
11 * critical operations are executed. All critical operations must complete
12 * /before/ reentrancy is permitted (e.g., __sti()). Alpha architecture also
13 * includes these barriers, for example.
16 unsigned long __raw_local_save_flags(void)
18 struct vcpu_info *_vcpu;
22 _vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id];
23 flags = _vcpu->evtchn_upcall_mask;
28 EXPORT_SYMBOL(__raw_local_save_flags);
30 void raw_local_irq_restore(unsigned long flags)
32 struct vcpu_info *_vcpu;
35 _vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id];
36 if ((_vcpu->evtchn_upcall_mask = flags) == 0) {
37 barrier(); /* unmask then check (avoid races) */
38 if (unlikely(_vcpu->evtchn_upcall_pending))
39 force_evtchn_callback();
42 preempt_enable_no_resched();
44 EXPORT_SYMBOL(raw_local_irq_restore);
46 void raw_local_irq_disable(void)
48 struct vcpu_info *_vcpu;
51 _vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id];
52 _vcpu->evtchn_upcall_mask = 1;
53 preempt_enable_no_resched();
55 EXPORT_SYMBOL(raw_local_irq_disable);
57 void raw_local_irq_enable(void)
59 struct vcpu_info *_vcpu;
62 _vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id];
63 _vcpu->evtchn_upcall_mask = 0;
64 barrier(); /* unmask then check (avoid races) */
65 if (unlikely(_vcpu->evtchn_upcall_pending))
66 force_evtchn_callback();
69 EXPORT_SYMBOL(raw_local_irq_enable);
72 * For spinlocks, etc.:
75 unsigned long __raw_local_irq_save(void)
77 struct vcpu_info *_vcpu;
81 _vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id];
82 flags = _vcpu->evtchn_upcall_mask;
83 _vcpu->evtchn_upcall_mask = 1;
84 preempt_enable_no_resched();
88 EXPORT_SYMBOL(__raw_local_irq_save);
90 /* Cannot use preempt_enable() here as we would recurse in preempt_sched(). */
91 int raw_irqs_disabled(void)
93 struct vcpu_info *_vcpu;
97 _vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id];
98 disabled = (_vcpu->evtchn_upcall_mask != 0);
99 preempt_enable_no_resched();
103 EXPORT_SYMBOL(raw_irqs_disabled);