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> 53eeb3288SAvi 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 393eeb3288SAvi Kivity static inline bool is_protmode(struct kvm_vcpu *vcpu) 403eeb3288SAvi Kivity { 413eeb3288SAvi Kivity return kvm_read_cr0_bits(vcpu, X86_CR0_PE); 423eeb3288SAvi Kivity } 433eeb3288SAvi Kivity 44*836a1b3cSAvi Kivity static inline int is_long_mode(struct kvm_vcpu *vcpu) 45*836a1b3cSAvi Kivity { 46*836a1b3cSAvi Kivity #ifdef CONFIG_X86_64 47*836a1b3cSAvi Kivity return vcpu->arch.shadow_efer & EFER_LMA; 48*836a1b3cSAvi Kivity #else 49*836a1b3cSAvi Kivity return 0; 50*836a1b3cSAvi Kivity #endif 51*836a1b3cSAvi Kivity } 52*836a1b3cSAvi Kivity 53*836a1b3cSAvi Kivity static inline int is_pae(struct kvm_vcpu *vcpu) 54*836a1b3cSAvi Kivity { 55*836a1b3cSAvi Kivity return kvm_read_cr4_bits(vcpu, X86_CR4_PAE); 56*836a1b3cSAvi Kivity } 57*836a1b3cSAvi Kivity 58*836a1b3cSAvi Kivity static inline int is_pse(struct kvm_vcpu *vcpu) 59*836a1b3cSAvi Kivity { 60*836a1b3cSAvi Kivity return kvm_read_cr4_bits(vcpu, X86_CR4_PSE); 61*836a1b3cSAvi Kivity } 62*836a1b3cSAvi Kivity 63*836a1b3cSAvi Kivity static inline int is_paging(struct kvm_vcpu *vcpu) 64*836a1b3cSAvi Kivity { 65*836a1b3cSAvi Kivity return kvm_read_cr0_bits(vcpu, X86_CR0_PG); 66*836a1b3cSAvi Kivity } 67*836a1b3cSAvi Kivity 6826eef70cSAvi Kivity #endif 69