]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - arch/x86/include/asm/kvm_host.h
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/gerg/m68knommu
[karo-tx-linux.git] / arch / x86 / include / asm / kvm_host.h
index 5ab1c3fb34eff3f9de29e0ccc80a33e0ff25eb7c..9e6fe391094e545eb41b9fa295df93a827c1fa30 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,9 +253,15 @@ struct kvm_mmu {
        int root_level;
        int shadow_root_level;
        union kvm_mmu_page_role base_role;
+       bool direct_map;
 
        u64 *pae_root;
+       u64 *lm_root;
        u64 rsvd_bits_mask[2][4];
+
+       bool nx;
+
+       u64 pdptrs[4]; /* pae */
 };
 
 struct kvm_vcpu_arch {
@@ -271,7 +281,6 @@ struct kvm_vcpu_arch {
        unsigned long cr4_guest_owned_bits;
        unsigned long cr8;
        u32 hflags;
-       u64 pdptrs[4]; /* pae */
        u64 efer;
        u64 apic_base;
        struct kvm_lapic *apic;    /* kernel irqchip context */
@@ -281,7 +290,41 @@ 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;
+               bool     nested;
+       } 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;
@@ -339,6 +382,11 @@ struct kvm_vcpu_arch {
        unsigned int time_offset;
        struct page *time_page;
        u64 last_host_tsc;
+       u64 last_guest_tsc;
+       u64 last_kernel_ns;
+       u64 last_tsc_nsec;
+       u64 last_tsc_write;
+       bool tsc_catchup;
 
        bool nmi_pending;
        bool nmi_injected;
@@ -399,6 +447,9 @@ struct kvm_arch {
        u64 last_tsc_nsec;
        u64 last_tsc_offset;
        u64 last_tsc_write;
+       u32 virtual_tsc_khz;
+       u32 virtual_tsc_mult;
+       s8 virtual_tsc_shift;
 
        struct kvm_xen_hvm_config xen_hvm_config;
 
@@ -508,6 +559,7 @@ struct kvm_x86_ops {
        void (*queue_exception)(struct kvm_vcpu *vcpu, unsigned nr,
                                bool has_error_code, u32 error_code,
                                bool reinject);
+       void (*cancel_injection)(struct kvm_vcpu *vcpu);
        int (*interrupt_allowed)(struct kvm_vcpu *vcpu);
        int (*nmi_allowed)(struct kvm_vcpu *vcpu);
        bool (*get_nmi_mask)(struct kvm_vcpu *vcpu);
@@ -522,6 +574,8 @@ struct kvm_x86_ops {
        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);
 
        bool (*has_wbinvd_exit)(void);
@@ -550,7 +604,7 @@ void kvm_mmu_zap_all(struct kvm *kvm);
 unsigned int kvm_mmu_calculate_mmu_pages(struct kvm *kvm);
 void kvm_mmu_change_mmu_pages(struct kvm *kvm, unsigned int kvm_nr_mmu_pages);
 
-int load_pdptrs(struct kvm_vcpu *vcpu, unsigned long cr3);
+int load_pdptrs(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu, unsigned long cr3);
 
 int emulator_write_phys(struct kvm_vcpu *vcpu, gpa_t gpa,
                          const void *val, int bytes);
@@ -614,8 +668,11 @@ 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);
+int kvm_read_guest_page_mmu(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu,
+                           gfn_t gfn, void *data, int offset, int len,
+                           u32 access);
+void kvm_propagate_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);