@@ -739,6 +739,23 @@ struct kvm_queued_exception {
739
739
bool has_payload ;
740
740
};
741
741
742
+ /*
743
+ * Hardware-defined CPUID leafs that are either scattered by the kernel or are
744
+ * unknown to the kernel, but need to be directly used by KVM. Note, these
745
+ * word values conflict with the kernel's "bug" caps, but KVM doesn't use those.
746
+ */
747
+ enum kvm_only_cpuid_leafs {
748
+ CPUID_12_EAX = NCAPINTS ,
749
+ CPUID_7_1_EDX ,
750
+ CPUID_8000_0007_EDX ,
751
+ CPUID_8000_0022_EAX ,
752
+ CPUID_7_2_EDX ,
753
+ CPUID_24_0_EBX ,
754
+ NR_KVM_CPU_CAPS ,
755
+
756
+ NKVMCAPINTS = NR_KVM_CPU_CAPS - NCAPINTS ,
757
+ };
758
+
742
759
struct kvm_vcpu_arch {
743
760
/*
744
761
* rip and regs accesses must go through
@@ -854,27 +871,23 @@ struct kvm_vcpu_arch {
854
871
855
872
int cpuid_nent ;
856
873
struct kvm_cpuid_entry2 * cpuid_entries ;
857
- struct kvm_hypervisor_cpuid kvm_cpuid ;
858
874
bool is_amd_compatible ;
859
875
860
876
/*
861
- * FIXME: Drop this macro and use KVM_NR_GOVERNED_FEATURES directly
862
- * when "struct kvm_vcpu_arch" is no longer defined in an
863
- * arch/x86/include/asm header. The max is mostly arbitrary, i.e.
864
- * can be increased as necessary.
865
- */
866
- #define KVM_MAX_NR_GOVERNED_FEATURES BITS_PER_LONG
867
-
868
- /*
869
- * Track whether or not the guest is allowed to use features that are
870
- * governed by KVM, where "governed" means KVM needs to manage state
871
- * and/or explicitly enable the feature in hardware. Typically, but
872
- * not always, governed features can be used by the guest if and only
873
- * if both KVM and userspace want to expose the feature to the guest.
877
+ * cpu_caps holds the effective guest capabilities, i.e. the features
878
+ * the vCPU is allowed to use. Typically, but not always, features can
879
+ * be used by the guest if and only if both KVM and userspace want to
880
+ * expose the feature to the guest.
881
+ *
882
+ * A common exception is for virtualization holes, i.e. when KVM can't
883
+ * prevent the guest from using a feature, in which case the vCPU "has"
884
+ * the feature regardless of what KVM or userspace desires.
885
+ *
886
+ * Note, features that don't require KVM involvement in any way are
887
+ * NOT enforced/sanitized by KVM, i.e. are taken verbatim from the
888
+ * guest CPUID provided by userspace.
874
889
*/
875
- struct {
876
- DECLARE_BITMAP (enabled , KVM_MAX_NR_GOVERNED_FEATURES );
877
- } governed_features ;
890
+ u32 cpu_caps [NR_KVM_CPU_CAPS ];
878
891
879
892
u64 reserved_gpa_bits ;
880
893
int maxphyaddr ;
@@ -1756,12 +1769,15 @@ struct kvm_x86_ops {
1756
1769
void (* write_tsc_multiplier )(struct kvm_vcpu * vcpu );
1757
1770
1758
1771
/*
1759
- * Retrieve somewhat arbitrary exit information. Intended to
1772
+ * Retrieve somewhat arbitrary exit/entry information. Intended to
1760
1773
* be used only from within tracepoints or error paths.
1761
1774
*/
1762
1775
void (* get_exit_info )(struct kvm_vcpu * vcpu , u32 * reason ,
1763
1776
u64 * info1 , u64 * info2 ,
1764
- u32 * exit_int_info , u32 * exit_int_info_err_code );
1777
+ u32 * intr_info , u32 * error_code );
1778
+
1779
+ void (* get_entry_info )(struct kvm_vcpu * vcpu ,
1780
+ u32 * intr_info , u32 * error_code );
1765
1781
1766
1782
int (* check_intercept )(struct kvm_vcpu * vcpu ,
1767
1783
struct x86_instruction_info * info ,
@@ -2018,8 +2034,8 @@ u64 vcpu_tsc_khz(struct kvm_vcpu *vcpu);
2018
2034
* VMware backdoor emulation handles select instructions
2019
2035
* and reinjects the #GP for all other cases.
2020
2036
*
2021
- * EMULTYPE_PF - Set when emulating MMIO by way of an intercepted #PF, in which
2022
- * case the CR2/GPA value pass on the stack is valid.
2037
+ * EMULTYPE_PF - Set when an intercepted #PF triggers the emulation , in which case
2038
+ * the CR2/GPA value pass on the stack is valid.
2023
2039
*
2024
2040
* EMULTYPE_COMPLETE_USER_EXIT - Set when the emulator should update interruptibility
2025
2041
* state and inject single-step #DBs after skipping
@@ -2054,13 +2070,20 @@ u64 vcpu_tsc_khz(struct kvm_vcpu *vcpu);
2054
2070
#define EMULTYPE_COMPLETE_USER_EXIT (1 << 7)
2055
2071
#define EMULTYPE_WRITE_PF_TO_SP (1 << 8)
2056
2072
2073
+ static inline bool kvm_can_emulate_event_vectoring (int emul_type )
2074
+ {
2075
+ return !(emul_type & EMULTYPE_PF );
2076
+ }
2077
+
2057
2078
int kvm_emulate_instruction (struct kvm_vcpu * vcpu , int emulation_type );
2058
2079
int kvm_emulate_instruction_from_buffer (struct kvm_vcpu * vcpu ,
2059
2080
void * insn , int insn_len );
2060
2081
void __kvm_prepare_emulation_failure_exit (struct kvm_vcpu * vcpu ,
2061
2082
u64 * data , u8 ndata );
2062
2083
void kvm_prepare_emulation_failure_exit (struct kvm_vcpu * vcpu );
2063
2084
2085
+ void kvm_prepare_event_vectoring_exit (struct kvm_vcpu * vcpu , gpa_t gpa );
2086
+
2064
2087
void kvm_enable_efer_bits (u64 );
2065
2088
bool kvm_valid_efer (struct kvm_vcpu * vcpu , u64 efer );
2066
2089
int kvm_get_msr_with_filter (struct kvm_vcpu * vcpu , u32 index , u64 * data );
0 commit comments