1 #include <linux/module.h>
3 #include <asm/irqflags.h>
4 #include <asm/hypervisor.h>
7 * The use of 'barrier' in the following reflects their use as local-lock
8 * operations. Reentrancy must be prevented (e.g., __cli()) /before/ following
9 * critical operations are executed. All critical operations must complete
10 * /before/ reentrancy is permitted (e.g., __sti()). Alpha architecture also
11 * includes these barriers, for example.
14 unsigned long __raw_local_save_flags(void)
16 struct vcpu_info *_vcpu;
20 _vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id];
21 flags = _vcpu->evtchn_upcall_mask;
26 EXPORT_SYMBOL(__raw_local_save_flags);
28 void raw_local_irq_restore(unsigned long flags)
30 struct vcpu_info *_vcpu;
32 _vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id];
33 if ((_vcpu->evtchn_upcall_mask = flags) == 0) {
34 barrier(); /* unmask then check (avoid races) */
35 if ( unlikely(_vcpu->evtchn_upcall_pending) )
36 force_evtchn_callback();
39 preempt_enable_no_resched();
41 EXPORT_SYMBOL(raw_local_irq_restore);
43 void raw_local_irq_disable(void)
45 struct vcpu_info *_vcpu;
48 _vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id];
49 _vcpu->evtchn_upcall_mask = 1;
50 preempt_enable_no_resched();
52 EXPORT_SYMBOL(raw_local_irq_disable);
54 void raw_local_irq_enable(void)
56 struct vcpu_info *_vcpu;
59 _vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id];
60 _vcpu->evtchn_upcall_mask = 0;
61 barrier(); /* unmask then check (avoid races) */
62 if ( unlikely(_vcpu->evtchn_upcall_pending) )
63 force_evtchn_callback();
66 EXPORT_SYMBOL(raw_local_irq_enable);
69 * For spinlocks, etc.:
72 unsigned long __raw_local_irq_save(void)
74 struct vcpu_info *_vcpu;
78 _vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id];
79 flags = _vcpu->evtchn_upcall_mask;
80 _vcpu->evtchn_upcall_mask = 1;
81 preempt_enable_no_resched();
85 EXPORT_SYMBOL(__raw_local_irq_save);
87 /* Cannot use preempt_enable() here as we would recurse in preempt_sched(). */
88 int raw_irqs_disabled(void)
90 struct vcpu_info *_vcpu;
94 _vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id];
95 disabled = (_vcpu->evtchn_upcall_mask != 0);
96 preempt_enable_no_resched();
100 EXPORT_SYMBOL(raw_irqs_disabled);