xref: /linux/arch/x86/kvm/x86.h (revision fc61b800f9506ca47bf1439342a79847f2353562)
126eef70cSAvi Kivity #ifndef ARCH_X86_KVM_X86_H
226eef70cSAvi Kivity #define ARCH_X86_KVM_X86_H
326eef70cSAvi Kivity 
426eef70cSAvi Kivity #include <linux/kvm_host.h>
526eef70cSAvi Kivity 
626eef70cSAvi Kivity static inline void kvm_clear_exception_queue(struct kvm_vcpu *vcpu)
726eef70cSAvi Kivity {
826eef70cSAvi Kivity 	vcpu->arch.exception.pending = false;
926eef70cSAvi Kivity }
1026eef70cSAvi Kivity 
1166fd3f7fSGleb Natapov static inline void kvm_queue_interrupt(struct kvm_vcpu *vcpu, u8 vector,
1266fd3f7fSGleb Natapov 	bool soft)
13937a7eaeSAvi Kivity {
14937a7eaeSAvi Kivity 	vcpu->arch.interrupt.pending = true;
1566fd3f7fSGleb Natapov 	vcpu->arch.interrupt.soft = soft;
16937a7eaeSAvi Kivity 	vcpu->arch.interrupt.nr = vector;
17937a7eaeSAvi Kivity }
18937a7eaeSAvi Kivity 
19937a7eaeSAvi Kivity static inline void kvm_clear_interrupt_queue(struct kvm_vcpu *vcpu)
20937a7eaeSAvi Kivity {
21937a7eaeSAvi Kivity 	vcpu->arch.interrupt.pending = false;
22937a7eaeSAvi Kivity }
23937a7eaeSAvi Kivity 
243298b75cSGleb Natapov static inline bool kvm_event_needs_reinjection(struct kvm_vcpu *vcpu)
253298b75cSGleb Natapov {
263298b75cSGleb Natapov 	return vcpu->arch.exception.pending || vcpu->arch.interrupt.pending ||
273298b75cSGleb Natapov 		vcpu->arch.nmi_injected;
283298b75cSGleb Natapov }
2966fd3f7fSGleb Natapov 
3066fd3f7fSGleb Natapov static inline bool kvm_exception_is_soft(unsigned int nr)
3166fd3f7fSGleb Natapov {
3266fd3f7fSGleb Natapov 	return (nr == BP_VECTOR) || (nr == OF_VECTOR);
3366fd3f7fSGleb Natapov }
34*fc61b800SGleb Natapov 
35*fc61b800SGleb Natapov struct kvm_cpuid_entry2 *kvm_find_cpuid_entry(struct kvm_vcpu *vcpu,
36*fc61b800SGleb Natapov                                              u32 function, u32 index);
37*fc61b800SGleb Natapov 
3826eef70cSAvi Kivity #endif
39