KVM: SVM: Add support for CR0 write traps for an SEV-ES guest
[linux-2.6-microblaze.git] / arch / x86 / include / asm / kvm_host.h
index 15e5134..f04d4c6 100644 (file)
@@ -133,7 +133,7 @@ static inline gfn_t gfn_to_index(gfn_t gfn, gfn_t base_gfn, int level)
 #define KVM_NUM_MMU_PAGES (1 << KVM_MMU_HASH_SHIFT)
 #define KVM_MIN_FREE_MMU_PAGES 5
 #define KVM_REFILL_PAGES 25
-#define KVM_MAX_CPUID_ENTRIES 80
+#define KVM_MAX_CPUID_ENTRIES 256
 #define KVM_NR_FIXED_MTRR_REGION 88
 #define KVM_NR_VAR_MTRR 8
 
@@ -614,6 +614,7 @@ struct kvm_vcpu_arch {
 
        struct kvm_pio_request pio;
        void *pio_data;
+       void *guest_ins_data;
 
        u8 event_exit_inst_len;
 
@@ -637,8 +638,9 @@ struct kvm_vcpu_arch {
        int halt_request; /* real mode on Intel only */
 
        int cpuid_nent;
-       struct kvm_cpuid_entry2 cpuid_entries[KVM_MAX_CPUID_ENTRIES];
+       struct kvm_cpuid_entry2 *cpuid_entries;
 
+       unsigned long cr3_lm_rsvd_bits;
        int maxphyaddr;
        int max_tdp_level;
 
@@ -804,6 +806,9 @@ struct kvm_vcpu_arch {
                 */
                bool enforce;
        } pv_cpuid;
+
+       /* Protected Guests */
+       bool guest_state_protected;
 };
 
 struct kvm_lpage_info {
@@ -995,6 +1000,20 @@ struct kvm_arch {
 
        struct kvm_pmu_event_filter *pmu_event_filter;
        struct task_struct *nx_lpage_recovery_thread;
+
+       /*
+        * Whether the TDP MMU is enabled for this VM. This contains a
+        * snapshot of the TDP MMU module parameter from when the VM was
+        * created and remains unchanged for the life of the VM. If this is
+        * true, TDP MMU handler functions will run for various MMU
+        * operations.
+        */
+       bool tdp_mmu_enabled;
+
+       /* List of struct tdp_mmu_pages being used as roots */
+       struct list_head tdp_mmu_roots;
+       /* List of struct tdp_mmu_pages not being used as roots */
+       struct list_head tdp_mmu_pages;
 };
 
 struct kvm_vm_stat {
@@ -1100,8 +1119,9 @@ struct kvm_x86_ops {
                            struct kvm_segment *var, int seg);
        void (*get_cs_db_l_bits)(struct kvm_vcpu *vcpu, int *db, int *l);
        void (*set_cr0)(struct kvm_vcpu *vcpu, unsigned long cr0);
-       int (*set_cr4)(struct kvm_vcpu *vcpu, unsigned long cr4);
-       void (*set_efer)(struct kvm_vcpu *vcpu, u64 efer);
+       bool (*is_valid_cr4)(struct kvm_vcpu *vcpu, unsigned long cr0);
+       void (*set_cr4)(struct kvm_vcpu *vcpu, unsigned long cr4);
+       int (*set_efer)(struct kvm_vcpu *vcpu, u64 efer);
        void (*get_idt)(struct kvm_vcpu *vcpu, struct desc_ptr *dt);
        void (*set_idt)(struct kvm_vcpu *vcpu, struct desc_ptr *dt);
        void (*get_gdt)(struct kvm_vcpu *vcpu, struct desc_ptr *dt);
@@ -1216,6 +1236,7 @@ struct kvm_x86_ops {
        void (*enable_log_dirty_pt_masked)(struct kvm *kvm,
                                           struct kvm_memory_slot *slot,
                                           gfn_t offset, unsigned long mask);
+       int (*cpu_dirty_log_size)(void);
 
        /* pmu operations of sub-arch */
        const struct kvm_pmu_ops *pmu_ops;
@@ -1265,6 +1286,7 @@ struct kvm_x86_ops {
 
        void (*migrate_timers)(struct kvm_vcpu *vcpu);
        void (*msr_filter_changed)(struct kvm_vcpu *vcpu);
+       int (*complete_emulated_msr)(struct kvm_vcpu *vcpu, int err);
 };
 
 struct kvm_x86_nested_ops {
@@ -1455,6 +1477,7 @@ void kvm_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu, u8 vector);
 int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int idt_index,
                    int reason, bool has_error_code, u32 error_code);
 
+void kvm_post_set_cr0(struct kvm_vcpu *vcpu, unsigned long old_cr0, unsigned long cr0);
 int kvm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0);
 int kvm_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3);
 int kvm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4);
@@ -1680,7 +1703,8 @@ void __kvm_request_immediate_exit(struct kvm_vcpu *vcpu);
 
 int kvm_is_in_guest(void);
 
-int __x86_set_memory_region(struct kvm *kvm, int id, gpa_t gpa, u32 size);
+void __user *__x86_set_memory_region(struct kvm *kvm, int id, gpa_t gpa,
+                                    u32 size);
 bool kvm_vcpu_is_reset_bsp(struct kvm_vcpu *vcpu);
 bool kvm_vcpu_is_bsp(struct kvm_vcpu *vcpu);
 
@@ -1727,4 +1751,6 @@ static inline int kvm_cpu_get_apicid(int mps_cpu)
 #define GET_SMSTATE(type, buf, offset)         \
        (*(type *)((buf) + (offset) - 0x7e00))
 
+int kvm_cpu_dirty_log_size(void);
+
 #endif /* _ASM_X86_KVM_HOST_H */