xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][3/3] 1GB Page Table Support for HVM Guest
@ 2010-03-12 18:40 Wei Huang
  0 siblings, 0 replies; 2+ messages in thread
From: Wei Huang @ 2010-03-12 18:40 UTC (permalink / raw)
  To: 'xen-devel@lists.xensource.com', Keir Fraser, Tim Deegan,
	Xu, Dongxiao

[-- Attachment #1: Type: text/plain, Size: 417 bytes --]

This patch adds a new field in hvm to indicate 1gb is supported by CPU. 
In addition, users can turn 1GB feature on/off using a Xen option 
("hap_1gb", default is off). Per Tim's suggestion, I also add an 
assertion check in shadow/common.c file to prevent affecting shadow code.

Signed-off-by: Wei Huang <wei.huang2@amd.com>
Acked-by: Dongxiao Xu <dongxiao.xu@amd.com>
Acked-by: Tim Deegan <tim.deegan@citrix.com>


[-- Attachment #2: 3-Xen-hap-1gb-host-page-option.patch --]
[-- Type: text/x-patch, Size: 2975 bytes --]

diff -r 9353d671b092 -r 67876984de4e xen/arch/x86/hvm/svm/svm.c
--- a/xen/arch/x86/hvm/svm/svm.c	Fri Mar 12 11:14:35 2010 -0600
+++ b/xen/arch/x86/hvm/svm/svm.c	Fri Mar 12 11:35:10 2010 -0600
@@ -883,6 +883,8 @@
                          cpuid_edx(0x8000000A) : 0);
 
     svm_function_table.hap_supported = cpu_has_svm_npt;
+    svm_function_table.hap_1gb_pgtb = 
+        (CONFIG_PAGING_LEVELS == 4)? !!(cpuid_edx(0x80000001) & 0x04000000):0;
 
     hvm_enable(&svm_function_table);
 }
diff -r 9353d671b092 -r 67876984de4e xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c	Fri Mar 12 11:14:35 2010 -0600
+++ b/xen/arch/x86/hvm/vmx/vmx.c	Fri Mar 12 11:35:10 2010 -0600
@@ -1443,6 +1443,8 @@
 
     if ( cpu_has_vmx_ept )
         vmx_function_table.hap_supported = 1;
+    
+    vmx_function_table.hap_1gb_pgtb = 0;
 
     setup_vmcs_dump();
 
diff -r 9353d671b092 -r 67876984de4e xen/arch/x86/mm/p2m.c
--- a/xen/arch/x86/mm/p2m.c	Fri Mar 12 11:14:35 2010 -0600
+++ b/xen/arch/x86/mm/p2m.c	Fri Mar 12 11:35:10 2010 -0600
@@ -38,6 +38,10 @@
 /* Debugging and auditing of the P2M code? */
 #define P2M_AUDIT     0
 #define P2M_DEBUGGING 0
+
+/* turn on/off 1GB host page table support for hap */
+static int opt_hap_1gb = 0;
+boolean_param("hap_1gb", opt_hap_1gb);
 
 /* Printouts */
 #define P2M_PRINTK(_f, _a...)                                \
@@ -1740,9 +1744,9 @@
     while ( todo )
     {
         if ( is_hvm_domain(d) && d->arch.hvm_domain.hap_enabled )
-            order = ( (((gfn | mfn_x(mfn) | todo) & ((1ul << 18) - 1)) == 0) ) ?
-                    18 :
-                    (((gfn | mfn_x(mfn) | todo) & ((1ul << 9) - 1)) == 0) ? 9 : 0;
+            order = ( (((gfn | mfn_x(mfn) | todo) & ((1ul << 18) - 1)) == 0) &&
+                      hvm_funcs.hap_1gb_pgtb && opt_hap_1gb ) ? 18 :
+                (((gfn | mfn_x(mfn) | todo) & ((1ul << 9) - 1)) == 0) ? 9 : 0;
 
         else
             order = 0;
diff -r 9353d671b092 -r 67876984de4e xen/arch/x86/mm/shadow/common.c
--- a/xen/arch/x86/mm/shadow/common.c	Fri Mar 12 11:14:35 2010 -0600
+++ b/xen/arch/x86/mm/shadow/common.c	Fri Mar 12 11:35:10 2010 -0600
@@ -3449,6 +3449,11 @@
 {
     struct domain *d = v->domain;
 
+    /* The following assertion is to make sure we don't step on 1GB host
+     * page support of HVM guest. */
+    ASSERT(!(level > 2 && (l1e_get_flags(*p) & _PAGE_PRESENT) &&
+             (l1e_get_flags(*p) & _PAGE_PSE)));
+
     /* If we're removing an MFN from the p2m, remove it from the shadows too */
     if ( level == 1 )
     {
diff -r 9353d671b092 -r 67876984de4e xen/include/asm-x86/hvm/hvm.h
--- a/xen/include/asm-x86/hvm/hvm.h	Fri Mar 12 11:14:35 2010 -0600
+++ b/xen/include/asm-x86/hvm/hvm.h	Fri Mar 12 11:35:10 2010 -0600
@@ -68,6 +68,10 @@
 
     /* Support Hardware-Assisted Paging? */
     int hap_supported;
+
+    /* Support 1GB Harware-Assisted Paging? */
+    int hap_1gb_pgtb;
+
 
     /*
      * Initialise/destroy HVM domain/vcpu resources

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH][3/3] 1GB Page Table Support for HVM Guest
@ 2010-04-02 15:35 Wei Huang
  0 siblings, 0 replies; 2+ messages in thread
From: Wei Huang @ 2010-04-02 15:35 UTC (permalink / raw)
  To: Keir Fraser, Xu, Dongxiao,
	'xen-devel@lists.xensource.com', Tim Deegan

[-- Attachment #1: Type: text/plain, Size: 419 bytes --]

This patch adds a new field in hvm to indicate 1gb is supported by CPU. 
In addition, users can turn 1GB feature on/off using a Xen option 
("hap_1gb", default is off). Per Tim's suggestion, I also add an 
assertion check in shadow/common.c file to prevent affecting shadow code.

Signed-off-by: Wei Huang <wei.huang2@amd.com>
Acked-by: Dongxiao Xu <dongxiao.xu@intel.com>
Acked-by: Tim Deegan <tim.deegan@citrix.com>


[-- Attachment #2: 3-Xen-hap-1gb-host-page-option.patch --]
[-- Type: text/x-patch, Size: 3177 bytes --]

# HG changeset patch
# User root@weisles1164.amd.com
# Date 1270220684 18000
# Node ID ab6294d72808fcb933e7a53953476c294a6163eb
# Parent  c2375d0545b72f1ba83072c502b6c437fbdc9770
add new IOMMU options

diff -r c2375d0545b7 -r ab6294d72808 xen/arch/x86/hvm/svm/svm.c
--- a/xen/arch/x86/hvm/svm/svm.c	Fri Apr 02 10:04:06 2010 -0500
+++ b/xen/arch/x86/hvm/svm/svm.c	Fri Apr 02 10:04:44 2010 -0500
@@ -883,6 +883,8 @@
                          cpuid_edx(0x8000000A) : 0);
 
     svm_function_table.hap_supported = cpu_has_svm_npt;
+    svm_function_table.hap_1gb_pgtb = 
+        (CONFIG_PAGING_LEVELS == 4)? !!(cpuid_edx(0x80000001) & 0x04000000):0;
 
     hvm_enable(&svm_function_table);
 }
diff -r c2375d0545b7 -r ab6294d72808 xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c	Fri Apr 02 10:04:06 2010 -0500
+++ b/xen/arch/x86/hvm/vmx/vmx.c	Fri Apr 02 10:04:44 2010 -0500
@@ -1445,6 +1445,8 @@
 
     if ( cpu_has_vmx_ept )
         vmx_function_table.hap_supported = 1;
+    
+    vmx_function_table.hap_1gb_pgtb = 0;
 
     setup_vmcs_dump();
 
diff -r c2375d0545b7 -r ab6294d72808 xen/arch/x86/mm/p2m.c
--- a/xen/arch/x86/mm/p2m.c	Fri Apr 02 10:04:06 2010 -0500
+++ b/xen/arch/x86/mm/p2m.c	Fri Apr 02 10:04:44 2010 -0500
@@ -38,6 +38,10 @@
 /* Debugging and auditing of the P2M code? */
 #define P2M_AUDIT     0
 #define P2M_DEBUGGING 0
+
+/* turn on/off 1GB host page table support for hap */
+static int opt_hap_1gb = 0;
+boolean_param("hap_1gb", opt_hap_1gb);
 
 /* Printouts */
 #define P2M_PRINTK(_f, _a...)                                \
@@ -1740,9 +1744,9 @@
     while ( todo )
     {
         if ( is_hvm_domain(d) && d->arch.hvm_domain.hap_enabled )
-            order = ( (((gfn | mfn_x(mfn) | todo) & ((1ul << 18) - 1)) == 0) ) ?
-                    18 :
-                    (((gfn | mfn_x(mfn) | todo) & ((1ul << 9) - 1)) == 0) ? 9 : 0;
+            order = ( (((gfn | mfn_x(mfn) | todo) & ((1ul << 18) - 1)) == 0) &&
+                      hvm_funcs.hap_1gb_pgtb && opt_hap_1gb ) ? 18 :
+                (((gfn | mfn_x(mfn) | todo) & ((1ul << 9) - 1)) == 0) ? 9 : 0;
 
         else
             order = 0;
diff -r c2375d0545b7 -r ab6294d72808 xen/arch/x86/mm/shadow/common.c
--- a/xen/arch/x86/mm/shadow/common.c	Fri Apr 02 10:04:06 2010 -0500
+++ b/xen/arch/x86/mm/shadow/common.c	Fri Apr 02 10:04:44 2010 -0500
@@ -3452,6 +3452,11 @@
 {
     struct domain *d = v->domain;
 
+    /* The following assertion is to make sure we don't step on 1GB host
+     * page support of HVM guest. */
+    ASSERT(!(level > 2 && (l1e_get_flags(*p) & _PAGE_PRESENT) &&
+             (l1e_get_flags(*p) & _PAGE_PSE)));
+
     /* If we're removing an MFN from the p2m, remove it from the shadows too */
     if ( level == 1 )
     {
diff -r c2375d0545b7 -r ab6294d72808 xen/include/asm-x86/hvm/hvm.h
--- a/xen/include/asm-x86/hvm/hvm.h	Fri Apr 02 10:04:06 2010 -0500
+++ b/xen/include/asm-x86/hvm/hvm.h	Fri Apr 02 10:04:44 2010 -0500
@@ -68,6 +68,10 @@
 
     /* Support Hardware-Assisted Paging? */
     int hap_supported;
+
+    /* Support 1GB Harware-Assisted Paging? */
+    int hap_1gb_pgtb;
+
 
     /*
      * Initialise/destroy HVM domain/vcpu resources

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-04-02 15:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-12 18:40 [PATCH][3/3] 1GB Page Table Support for HVM Guest Wei Huang
  -- strict thread matches above, loose matches on Subject: below --
2010-04-02 15:35 Wei Huang

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).