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> 5*3eeb3288SAvi Kivity #include "kvm_cache_regs.h" 626eef70cSAvi Kivity 726eef70cSAvi Kivity static inline void kvm_clear_exception_queue(struct kvm_vcpu *vcpu) 826eef70cSAvi Kivity { 926eef70cSAvi Kivity vcpu->arch.exception.pending = false; 1026eef70cSAvi Kivity } 1126eef70cSAvi Kivity 1266fd3f7fSGleb Natapov static inline void kvm_queue_interrupt(struct kvm_vcpu *vcpu, u8 vector, 1366fd3f7fSGleb Natapov bool soft) 14937a7eaeSAvi Kivity { 15937a7eaeSAvi Kivity vcpu->arch.interrupt.pending = true; 1666fd3f7fSGleb Natapov vcpu->arch.interrupt.soft = soft; 17937a7eaeSAvi Kivity vcpu->arch.interrupt.nr = vector; 18937a7eaeSAvi Kivity } 19937a7eaeSAvi Kivity 20937a7eaeSAvi Kivity static inline void kvm_clear_interrupt_queue(struct kvm_vcpu *vcpu) 21937a7eaeSAvi Kivity { 22937a7eaeSAvi Kivity vcpu->arch.interrupt.pending = false; 23937a7eaeSAvi Kivity } 24937a7eaeSAvi Kivity 253298b75cSGleb Natapov static inline bool kvm_event_needs_reinjection(struct kvm_vcpu *vcpu) 263298b75cSGleb Natapov { 273298b75cSGleb Natapov return vcpu->arch.exception.pending || vcpu->arch.interrupt.pending || 283298b75cSGleb Natapov vcpu->arch.nmi_injected; 293298b75cSGleb Natapov } 3066fd3f7fSGleb Natapov 3166fd3f7fSGleb Natapov static inline bool kvm_exception_is_soft(unsigned int nr) 3266fd3f7fSGleb Natapov { 3366fd3f7fSGleb Natapov return (nr == BP_VECTOR) || (nr == OF_VECTOR); 3466fd3f7fSGleb Natapov } 35fc61b800SGleb Natapov 36fc61b800SGleb Natapov struct kvm_cpuid_entry2 *kvm_find_cpuid_entry(struct kvm_vcpu *vcpu, 37fc61b800SGleb Natapov u32 function, u32 index); 38fc61b800SGleb Natapov 39*3eeb3288SAvi Kivity static inline bool is_protmode(struct kvm_vcpu *vcpu) 40*3eeb3288SAvi Kivity { 41*3eeb3288SAvi Kivity return kvm_read_cr0_bits(vcpu, X86_CR0_PE); 42*3eeb3288SAvi Kivity } 43*3eeb3288SAvi Kivity 4426eef70cSAvi Kivity #endif 45