KVM: x86: optimize steal time calculation
[linux-2.6-block.git] / arch / x86 / include / asm / kvm_host.h
index 01c8b501cb6d5afbdd5eb1c5dfaba366ea158cf8..c66e26280707a9c5d24914a41a6cd22b62d461c3 100644 (file)
@@ -43,7 +43,7 @@
 
 #define KVM_PIO_PAGE_OFFSET 1
 #define KVM_COALESCED_MMIO_PAGE_OFFSET 2
-#define KVM_HALT_POLL_NS_DEFAULT 500000
+#define KVM_HALT_POLL_NS_DEFAULT 400000
 
 #define KVM_IRQCHIP_NUM_PINS  KVM_IOAPIC_NUM_PINS
 
@@ -84,7 +84,8 @@
                          | X86_CR4_PSE | X86_CR4_PAE | X86_CR4_MCE     \
                          | X86_CR4_PGE | X86_CR4_PCE | X86_CR4_OSFXSR | X86_CR4_PCIDE \
                          | X86_CR4_OSXSAVE | X86_CR4_SMEP | X86_CR4_FSGSBASE \
-                         | X86_CR4_OSXMMEXCPT | X86_CR4_VMXE | X86_CR4_SMAP))
+                         | X86_CR4_OSXMMEXCPT | X86_CR4_VMXE | X86_CR4_SMAP \
+                         | X86_CR4_PKE))
 
 #define CR8_RESERVED_BITS (~(unsigned long)X86_CR8_TPR)
 
@@ -187,12 +188,14 @@ enum {
 #define PFERR_USER_BIT 2
 #define PFERR_RSVD_BIT 3
 #define PFERR_FETCH_BIT 4
+#define PFERR_PK_BIT 5
 
 #define PFERR_PRESENT_MASK (1U << PFERR_PRESENT_BIT)
 #define PFERR_WRITE_MASK (1U << PFERR_WRITE_BIT)
 #define PFERR_USER_MASK (1U << PFERR_USER_BIT)
 #define PFERR_RSVD_MASK (1U << PFERR_RSVD_BIT)
 #define PFERR_FETCH_MASK (1U << PFERR_FETCH_BIT)
+#define PFERR_PK_MASK (1U << PFERR_PK_BIT)
 
 /* apic attention bits */
 #define KVM_APIC_CHECK_VAPIC   0
@@ -335,6 +338,14 @@ struct kvm_mmu {
         */
        u8 permissions[16];
 
+       /*
+       * The pkru_mask indicates if protection key checks are needed.  It
+       * consists of 16 domains indexed by page fault error code bits [4:1],
+       * with PFEC.RSVD replaced by ACC_USER_MASK from the page tables.
+       * Each domain has 2 bits which are ANDed with AD and WD from PKRU.
+       */
+       u32 pkru_mask;
+
        u64 *pae_root;
        u64 *lm_root;
 
@@ -551,7 +562,6 @@ struct kvm_vcpu_arch {
        struct {
                u64 msr_val;
                u64 last_steal;
-               u64 accum_steal;
                struct gfn_to_hva_cache stime;
                struct kvm_steal_time steal;
        } st;
@@ -874,6 +884,7 @@ struct kvm_x86_ops {
        void (*cache_reg)(struct kvm_vcpu *vcpu, enum kvm_reg reg);
        unsigned long (*get_rflags)(struct kvm_vcpu *vcpu);
        void (*set_rflags)(struct kvm_vcpu *vcpu, unsigned long rflags);
+       u32 (*get_pkru)(struct kvm_vcpu *vcpu);
        void (*fpu_activate)(struct kvm_vcpu *vcpu);
        void (*fpu_deactivate)(struct kvm_vcpu *vcpu);