debuggers.hg
changeset 21148:44bef2b4a075
1GB Page Table Support for HVM Guest 3/3
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>
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>
author | Keir Fraser <keir.fraser@citrix.com> |
---|---|
date | Tue Apr 06 07:09:35 2010 +0100 (2010-04-06) |
parents | 1ea7b73b3061 |
children | 61372a4f4e76 |
files | xen/arch/x86/hvm/svm/svm.c xen/arch/x86/hvm/vmx/vmx.c xen/arch/x86/mm/p2m.c xen/arch/x86/mm/shadow/common.c xen/include/asm-x86/hvm/hvm.h |
line diff
1.1 --- a/xen/arch/x86/hvm/svm/svm.c Tue Apr 06 07:07:37 2010 +0100 1.2 +++ b/xen/arch/x86/hvm/svm/svm.c Tue Apr 06 07:09:35 2010 +0100 1.3 @@ -884,6 +884,8 @@ void start_svm(struct cpuinfo_x86 *c) 1.4 cpuid_edx(0x8000000A) : 0); 1.5 1.6 svm_function_table.hap_supported = cpu_has_svm_npt; 1.7 + svm_function_table.hap_1gb_pgtb = 1.8 + (CONFIG_PAGING_LEVELS == 4)? !!(cpuid_edx(0x80000001) & 0x04000000):0; 1.9 1.10 hvm_enable(&svm_function_table); 1.11 }
2.1 --- a/xen/arch/x86/hvm/vmx/vmx.c Tue Apr 06 07:07:37 2010 +0100 2.2 +++ b/xen/arch/x86/hvm/vmx/vmx.c Tue Apr 06 07:09:35 2010 +0100 2.3 @@ -1445,6 +1445,8 @@ void start_vmx(void) 2.4 2.5 if ( cpu_has_vmx_ept ) 2.6 vmx_function_table.hap_supported = 1; 2.7 + 2.8 + vmx_function_table.hap_1gb_pgtb = 0; 2.9 2.10 setup_vmcs_dump(); 2.11
3.1 --- a/xen/arch/x86/mm/p2m.c Tue Apr 06 07:07:37 2010 +0100 3.2 +++ b/xen/arch/x86/mm/p2m.c Tue Apr 06 07:09:35 2010 +0100 3.3 @@ -39,6 +39,10 @@ 3.4 #define P2M_AUDIT 0 3.5 #define P2M_DEBUGGING 0 3.6 3.7 +/* turn on/off 1GB host page table support for hap */ 3.8 +static int opt_hap_1gb = 0; 3.9 +boolean_param("hap_1gb", opt_hap_1gb); 3.10 + 3.11 /* Printouts */ 3.12 #define P2M_PRINTK(_f, _a...) \ 3.13 debugtrace_printk("p2m: %s(): " _f, __func__, ##_a) 3.14 @@ -1736,9 +1740,9 @@ int set_p2m_entry(struct domain *d, unsi 3.15 while ( todo ) 3.16 { 3.17 if ( is_hvm_domain(d) && paging_mode_hap(d) ) 3.18 - order = ( (((gfn | mfn_x(mfn) | todo) & ((1ul << 18) - 1)) == 0) ) ? 3.19 - 18 : 3.20 - (((gfn | mfn_x(mfn) | todo) & ((1ul << 9) - 1)) == 0) ? 9 : 0; 3.21 + order = ( (((gfn | mfn_x(mfn) | todo) & ((1ul << 18) - 1)) == 0) && 3.22 + hvm_funcs.hap_1gb_pgtb && opt_hap_1gb ) ? 18 : 3.23 + (((gfn | mfn_x(mfn) | todo) & ((1ul << 9) - 1)) == 0) ? 9 : 0; 3.24 else 3.25 order = 0; 3.26
4.1 --- a/xen/arch/x86/mm/shadow/common.c Tue Apr 06 07:07:37 2010 +0100 4.2 +++ b/xen/arch/x86/mm/shadow/common.c Tue Apr 06 07:09:35 2010 +0100 4.3 @@ -3452,6 +3452,11 @@ static void sh_unshadow_for_p2m_change(s 4.4 { 4.5 struct domain *d = v->domain; 4.6 4.7 + /* The following assertion is to make sure we don't step on 1GB host 4.8 + * page support of HVM guest. */ 4.9 + ASSERT(!(level > 2 && (l1e_get_flags(*p) & _PAGE_PRESENT) && 4.10 + (l1e_get_flags(*p) & _PAGE_PSE))); 4.11 + 4.12 /* If we're removing an MFN from the p2m, remove it from the shadows too */ 4.13 if ( level == 1 ) 4.14 {
5.1 --- a/xen/include/asm-x86/hvm/hvm.h Tue Apr 06 07:07:37 2010 +0100 5.2 +++ b/xen/include/asm-x86/hvm/hvm.h Tue Apr 06 07:09:35 2010 +0100 5.3 @@ -69,6 +69,10 @@ struct hvm_function_table { 5.4 /* Support Hardware-Assisted Paging? */ 5.5 int hap_supported; 5.6 5.7 + /* Support 1GB Harware-Assisted Paging? */ 5.8 + int hap_1gb_pgtb; 5.9 + 5.10 + 5.11 /* 5.12 * Initialise/destroy HVM domain/vcpu resources 5.13 */