]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blobdiff - arch/x86/include/asm/kvm_host.h
KVM: MMU: Implement nested gva_to_gpa functions
[mirror_ubuntu-hirsute-kernel.git] / arch / x86 / include / asm / kvm_host.h
index a215153f1ff637b1fe9e7af222d7bcceba7a26f1..8ec3547c433d80cc38edbaa249dd0d609860f287 100644 (file)
@@ -236,10 +236,14 @@ struct kvm_pio_request {
  */
 struct kvm_mmu {
        void (*new_cr3)(struct kvm_vcpu *vcpu);
+       void (*set_cr3)(struct kvm_vcpu *vcpu, unsigned long root);
+       unsigned long (*get_cr3)(struct kvm_vcpu *vcpu);
        int (*page_fault)(struct kvm_vcpu *vcpu, gva_t gva, u32 err);
+       void (*inject_page_fault)(struct kvm_vcpu *vcpu);
        void (*free)(struct kvm_vcpu *vcpu);
        gpa_t (*gva_to_gpa)(struct kvm_vcpu *vcpu, gva_t gva, u32 access,
                            u32 *error);
+       gpa_t (*translate_gpa)(struct kvm_vcpu *vcpu, gpa_t gpa, u32 access);
        void (*prefetch_page)(struct kvm_vcpu *vcpu,
                              struct kvm_mmu_page *page);
        int (*sync_page)(struct kvm_vcpu *vcpu,
@@ -249,13 +253,13 @@ struct kvm_mmu {
        int root_level;
        int shadow_root_level;
        union kvm_mmu_page_role base_role;
+       bool direct_map;
 
        u64 *pae_root;
        u64 rsvd_bits_mask[2][4];
 };
 
 struct kvm_vcpu_arch {
-       u64 host_tsc;
        /*
         * rip and regs accesses must go through
         * kvm_{register,rip}_{read,write} functions.
@@ -282,7 +286,40 @@ struct kvm_vcpu_arch {
        u64 ia32_misc_enable_msr;
        bool tpr_access_reporting;
 
+       /*
+        * Paging state of the vcpu
+        *
+        * If the vcpu runs in guest mode with two level paging this still saves
+        * the paging mode of the l1 guest. This context is always used to
+        * handle faults.
+        */
        struct kvm_mmu mmu;
+
+       /*
+        * Paging state of an L2 guest (used for nested npt)
+        *
+        * This context will save all necessary information to walk page tables
+        * of the an L2 guest. This context is only initialized for page table
+        * walking and not for faulting since we never handle l2 page faults on
+        * the host.
+        */
+       struct kvm_mmu nested_mmu;
+
+       /*
+        * Pointer to the mmu context currently used for
+        * gva_to_gpa translations.
+        */
+       struct kvm_mmu *walk_mmu;
+
+       /*
+        * This struct is filled with the necessary information to propagate a
+        * page fault into the guest
+        */
+       struct {
+               u64      address;
+               unsigned error_code;
+       } fault;
+
        /* only needed in kvm_pv_mmu_op() path, but it's hot so
         * put it here to avoid allocation */
        struct kvm_pv_mmu_op_buffer mmu_op_buffer;
@@ -336,9 +373,12 @@ struct kvm_vcpu_arch {
 
        gpa_t time;
        struct pvclock_vcpu_time_info hv_clock;
-       unsigned int hv_clock_tsc_khz;
+       unsigned int hw_tsc_khz;
        unsigned int time_offset;
        struct page *time_page;
+       u64 last_host_tsc;
+       u64 last_guest_tsc;
+       u64 last_kernel_ns;
 
        bool nmi_pending;
        bool nmi_injected;
@@ -396,6 +436,9 @@ struct kvm_arch {
        unsigned long irq_sources_bitmap;
        s64 kvmclock_offset;
        spinlock_t tsc_write_lock;
+       u64 last_tsc_nsec;
+       u64 last_tsc_offset;
+       u64 last_tsc_write;
 
        struct kvm_xen_hvm_config xen_hvm_config;
 
@@ -517,6 +560,9 @@ struct kvm_x86_ops {
        u64 (*get_mt_mask)(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio);
        int (*get_lpage_level)(void);
        bool (*rdtscp_supported)(void);
+       void (*adjust_tsc_offset)(struct kvm_vcpu *vcpu, s64 adjustment);
+
+       void (*set_tdp_cr3)(struct kvm_vcpu *vcpu, unsigned long cr3);
 
        void (*set_supported_cpuid)(u32 func, struct kvm_cpuid_entry2 *entry);
 
@@ -610,8 +656,7 @@ void kvm_queue_exception(struct kvm_vcpu *vcpu, unsigned nr);
 void kvm_queue_exception_e(struct kvm_vcpu *vcpu, unsigned nr, u32 error_code);
 void kvm_requeue_exception(struct kvm_vcpu *vcpu, unsigned nr);
 void kvm_requeue_exception_e(struct kvm_vcpu *vcpu, unsigned nr, u32 error_code);
-void kvm_inject_page_fault(struct kvm_vcpu *vcpu, unsigned long cr2,
-                          u32 error_code);
+void kvm_inject_page_fault(struct kvm_vcpu *vcpu);
 bool kvm_require_cpl(struct kvm_vcpu *vcpu, int required_cpl);
 
 int kvm_pic_set_irq(void *opaque, int irq, int level);