xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Xudong Hao <xudong.hao@intel.com>
To: xen-devel@lists.xen.org
Cc: xudong.hao@intel.com, haitao.shan@intel.com, keir@xen.org,
	xiantao.zhang@intel.com, JBeulich@suse.com
Subject: [PATCH v2 2/4] xen: add xen parameter to control A/D bits support
Date: Wed, 20 Jun 2012 09:57:45 +0800	[thread overview]
Message-ID: <1340157467-19553-3-git-send-email-xudong.hao@intel.com> (raw)
In-Reply-To: <1340157467-19553-1-git-send-email-xudong.hao@intel.com>

Add xen parameter to control A/D bits support, it on by default.

Changes from v1:
- Move hap_has_dirty_bit and hap_has_access_bit definition from patch 3 to patch2.
- define them as bool_t instead of int.

Signed-off-by: Haitao Shan<haitao.shan@intel.com>
Signed-off-by: Xudong Hao <xudong.hao@intel.com>
---
 xen/arch/x86/hvm/vmx/vmcs.c       |    1 +
 xen/arch/x86/hvm/vmx/vmx.c        |    8 ++++++++
 xen/arch/x86/mm/hap/hap.c         |    4 ++++
 xen/arch/x86/mm/p2m.c             |    3 +++
 xen/include/asm-x86/hap.h         |    3 +++
 xen/include/asm-x86/hvm/vmx/vmx.h |    3 +++
 6 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c
index 38b5d03..5a6be4c 100644
--- a/xen/arch/x86/hvm/vmx/vmcs.c
+++ b/xen/arch/x86/hvm/vmx/vmcs.c
@@ -85,6 +85,7 @@ static void __init vmx_display_features(void)
     P(cpu_has_vmx_virtualize_apic_accesses, "APIC MMIO access virtualisation");
     P(cpu_has_vmx_tpr_shadow, "APIC TPR shadow");
     P(cpu_has_vmx_ept, "Extended Page Tables (EPT)");
+    P(cpu_has_vmx_ept_ad_bits, "EPT A/D Bits");
     P(cpu_has_vmx_vpid, "Virtual-Processor Identifiers (VPID)");
     P(cpu_has_vmx_vnmi, "Virtual NMI");
     P(cpu_has_vmx_msr_bitmap, "MSR direct-access bitmap");
diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index ffb86c1..cb94226 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -37,6 +37,7 @@
 #include <asm/spinlock.h>
 #include <asm/paging.h>
 #include <asm/p2m.h>
+#include <asm/hap.h>
 #include <asm/mem_sharing.h>
 #include <asm/hvm/emulate.h>
 #include <asm/hvm/hvm.h>
@@ -89,6 +90,10 @@ static int vmx_domain_initialise(struct domain *d)
     d->arch.hvm_domain.vmx.ept_control.asr  =
         pagetable_get_pfn(p2m_get_pagetable(p2m_get_hostp2m(d)));
 
+    /* set EPT access and dirty bits support */
+    d->arch.hvm_domain.vmx.ept_control.ept_ad =
+        cpu_has_vmx_ept_ad_bits? 1 : 0;
+
     if ( !zalloc_cpumask_var(&d->arch.hvm_domain.vmx.ept_synced) )
         return -ENOMEM;
 
@@ -1574,6 +1579,9 @@ struct hvm_function_table * __init start_vmx(void)
         if ( cpu_has_vmx_ept_1gb )
             vmx_function_table.hap_capabilities |= HVM_HAP_SUPERPAGE_1GB;
 
+        if ( cpu_has_vmx_ept_ad_bits )
+            hap_has_access_bit = hap_has_dirty_bit = 1;
+
         setup_ept_dump();
     }
 
diff --git a/xen/arch/x86/mm/hap/hap.c b/xen/arch/x86/mm/hap/hap.c
index 13b4be2..8790c58 100644
--- a/xen/arch/x86/mm/hap/hap.c
+++ b/xen/arch/x86/mm/hap/hap.c
@@ -52,6 +52,10 @@
 #undef page_to_mfn
 #define page_to_mfn(_pg) _mfn(__page_to_mfn(_pg))
 
+/* Define whether HW has access and dirty bits seperately */
+bool_t hap_has_dirty_bit __read_mostly = 0;
+bool_t hap_has_access_bit __read_mostly = 0;
+
 /************************************************/
 /*          HAP VRAM TRACKING SUPPORT           */
 /************************************************/
diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
index 3cdc417..0a796f3 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -46,6 +46,9 @@ boolean_param("hap_1gb", opt_hap_1gb);
 bool_t __read_mostly opt_hap_2mb = 1;
 boolean_param("hap_2mb", opt_hap_2mb);
 
+bool_t __read_mostly opt_hap_ad_bits = 1;
+boolean_param("hap_ad_bits", opt_hap_ad_bits);
+
 /* Printouts */
 #define P2M_PRINTK(_f, _a...)                                \
     debugtrace_printk("p2m: %s(): " _f, __func__, ##_a)
diff --git a/xen/include/asm-x86/hap.h b/xen/include/asm-x86/hap.h
index a2532a4..bd5d732 100644
--- a/xen/include/asm-x86/hap.h
+++ b/xen/include/asm-x86/hap.h
@@ -64,6 +64,9 @@ int   hap_track_dirty_vram(struct domain *d,
 
 extern const struct paging_mode *hap_paging_get_mode(struct vcpu *);
 
+extern bool_t hap_has_dirty_bit __read_mostly;
+extern bool_t hap_has_access_bit __read_mostly;
+
 #endif /* XEN_HAP_H */
 
 /*
diff --git a/xen/include/asm-x86/hvm/vmx/vmx.h b/xen/include/asm-x86/hvm/vmx/vmx.h
index 416504f..f552d08 100644
--- a/xen/include/asm-x86/hvm/vmx/vmx.h
+++ b/xen/include/asm-x86/hvm/vmx/vmx.h
@@ -201,6 +201,9 @@ extern u64 vmx_ept_vpid_cap;
     (vmx_ept_vpid_cap & VMX_EPT_SUPERPAGE_2MB)
 #define cpu_has_vmx_ept_invept_single_context   \
     (vmx_ept_vpid_cap & VMX_EPT_INVEPT_SINGLE_CONTEXT)
+extern bool_t opt_hap_ad_bits;
+#define cpu_has_vmx_ept_ad_bits                 \
+    ( opt_hap_ad_bits ? (vmx_ept_vpid_cap & VMX_EPT_AD_BITS_SUPPORT) : 0 )
 
 #define EPT_2MB_SHIFT     16
 #define EPT_1GB_SHIFT     17
-- 
1.5.5

  parent reply	other threads:[~2012-06-20  1:57 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-20  1:57 [PATCH v2 0/4] xen: enable EPT A/D bit feature Xudong Hao
2012-06-20  1:57 ` [PATCH v2 1/4] xen: Add EPT A/D bits definitions Xudong Hao
2012-06-20  1:57 ` Xudong Hao [this message]
2012-06-20  1:57 ` [PATCH v2 3/4] xen: introduce new function update_dirty_bitmap Xudong Hao
2012-06-28 13:42   ` Tim Deegan
2012-06-29  8:46     ` Hao, Xudong
2012-06-20  1:57 ` [PATCH v2 4/4] xen: enable EPT dirty bit for guest live migration Xudong Hao
2012-06-28 13:52   ` Tim Deegan
2012-06-29  7:50     ` Hao, Xudong
2012-06-25  6:27 ` [PATCH v2 0/4] xen: enable EPT A/D bit feature Hao, Xudong
2012-06-25  7:22   ` Keir Fraser
2012-06-25  9:02 ` Tim Deegan
2012-06-26  5:31   ` Hao, Xudong
2012-06-28 10:30     ` Tim Deegan
2012-06-29  9:27       ` Hao, Xudong
2012-06-28 12:14     ` George Dunlap
2012-06-29  9:31       ` Hao, Xudong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1340157467-19553-3-git-send-email-xudong.hao@intel.com \
    --to=xudong.hao@intel.com \
    --cc=JBeulich@suse.com \
    --cc=haitao.shan@intel.com \
    --cc=keir@xen.org \
    --cc=xen-devel@lists.xen.org \
    --cc=xiantao.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).