1 #ifndef ARCH_X86_KVM_X86_H
2 #define ARCH_X86_KVM_X86_H
4 #include <linux/kvm_host.h>
6 static inline void kvm_clear_exception_queue(struct kvm_vcpu *vcpu)
8 vcpu->arch.exception.pending = false;
11 static inline void kvm_queue_interrupt(struct kvm_vcpu *vcpu, u8 vector)
13 vcpu->arch.interrupt.pending = true;
14 vcpu->arch.interrupt.nr = vector;
17 static inline void kvm_clear_interrupt_queue(struct kvm_vcpu *vcpu)
19 vcpu->arch.interrupt.pending = false;
22 static inline u8 kvm_pop_irq(struct kvm_vcpu *vcpu)
24 int word_index = __ffs(vcpu->arch.irq_summary);
25 int bit_index = __ffs(vcpu->arch.irq_pending[word_index]);
26 int irq = word_index * BITS_PER_LONG + bit_index;
28 clear_bit(bit_index, &vcpu->arch.irq_pending[word_index]);
29 if (!vcpu->arch.irq_pending[word_index])
30 clear_bit(word_index, &vcpu->arch.irq_summary);
34 static inline void kvm_push_irq(struct kvm_vcpu *vcpu, u8 irq)
36 set_bit(irq, vcpu->arch.irq_pending);
37 set_bit(irq / BITS_PER_LONG, &vcpu->arch.irq_summary);