[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] hvm: Enable HAP by default (NPT on AMD SVM systems).
# HG changeset patch # User Keir Fraser <keir@xxxxxxxxxxxxx> # Date 1190988230 -3600 # Node ID b4c8cd753b88f042741edd4402562dbf27ca9811 # Parent 8817a53c030f9c2c5f39fafad72aa9502342e7b3 hvm: Enable HAP by default (NPT on AMD SVM systems). Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx> --- xen/arch/x86/hvm/hvm.c | 12 ++++++++++++ xen/arch/x86/hvm/svm/svm.c | 18 ++++-------------- xen/arch/x86/mm/paging.c | 16 +++++++--------- xen/include/asm-x86/hvm/hvm.h | 3 +++ 4 files changed, 26 insertions(+), 23 deletions(-) diff -r 8817a53c030f -r b4c8cd753b88 xen/arch/x86/hvm/hvm.c --- a/xen/arch/x86/hvm/hvm.c Thu Sep 27 18:08:11 2007 +0100 +++ b/xen/arch/x86/hvm/hvm.c Fri Sep 28 15:03:50 2007 +0100 @@ -49,6 +49,10 @@ #include <public/version.h> #include <public/memory.h> +/* Xen command-line option to disable hardware-assisted paging */ +static int opt_hap_disabled; +invbool_param("hap", opt_hap_disabled); + int hvm_enabled __read_mostly; unsigned int opt_hvm_debug_level __read_mostly; @@ -74,6 +78,14 @@ void hvm_enable(struct hvm_function_tabl hvm_funcs = *fns; hvm_enabled = 1; + + if ( hvm_funcs.hap_supported ) + { + if ( opt_hap_disabled ) + hvm_funcs.hap_supported = 0; + printk("HVM: Hardware Assisted Paging %sabled\n", + hvm_funcs.hap_supported ? "en" : "dis"); + } } void hvm_set_guest_time(struct vcpu *v, u64 gtime) diff -r 8817a53c030f -r b4c8cd753b88 xen/arch/x86/hvm/svm/svm.c --- a/xen/arch/x86/hvm/svm/svm.c Thu Sep 27 18:08:11 2007 +0100 +++ b/xen/arch/x86/hvm/svm/svm.c Fri Sep 28 15:03:50 2007 +0100 @@ -69,9 +69,6 @@ static void *hsa[NR_CPUS] __read_mostly; /* vmcb used for extended host state */ static void *root_vmcb[NR_CPUS] __read_mostly; -/* hardware assisted paging bits */ -extern int opt_hap_enabled; - static void inline __update_guest_eip( struct cpu_user_regs *regs, int inst_len) { @@ -936,18 +933,14 @@ static struct hvm_function_table svm_fun .event_pending = svm_event_pending }; -static void svm_npt_detect(void) +static int svm_npt_detect(void) { u32 eax, ebx, ecx, edx; /* Check CPUID for nested paging support. */ cpuid(0x8000000A, &eax, &ebx, &ecx, &edx); - if ( !(edx & 1) && opt_hap_enabled ) - { - printk("SVM: Nested paging is not supported by this CPU.\n"); - opt_hap_enabled = 0; - } + return (edx & 1); } int start_svm(struct cpuinfo_x86 *c) @@ -978,8 +971,6 @@ int start_svm(struct cpuinfo_x86 *c) write_efer(read_efer() | EFER_SVME); - svm_npt_detect(); - /* Initialize the HSA for this core. */ phys_hsa = (u64) virt_to_maddr(hsa[cpu]); phys_hsa_lo = (u32) phys_hsa; @@ -994,11 +985,10 @@ int start_svm(struct cpuinfo_x86 *c) setup_vmcb_dump(); + svm_function_table.hap_supported = svm_npt_detect(); + hvm_enable(&svm_function_table); - if ( opt_hap_enabled ) - printk("SVM: Nested paging enabled.\n"); - return 1; } diff -r 8817a53c030f -r b4c8cd753b88 xen/arch/x86/mm/paging.c --- a/xen/arch/x86/mm/paging.c Thu Sep 27 18:08:11 2007 +0100 +++ b/xen/arch/x86/mm/paging.c Fri Sep 28 15:03:50 2007 +0100 @@ -28,9 +28,7 @@ #include <asm/guest_access.h> #include <xsm/xsm.h> -/* Xen command-line option to enable hardware-assisted paging */ -int opt_hap_enabled; -boolean_param("hap", opt_hap_enabled); +#define hap_enabled(d) (hvm_funcs.hap_supported && is_hvm_domain(d)) /* Printouts */ #define PAGING_PRINTK(_f, _a...) \ @@ -363,14 +361,14 @@ void paging_domain_init(struct domain *d shadow_domain_init(d); /* ... but we will use hardware assistance if it's available. */ - if ( opt_hap_enabled && is_hvm_domain(d) ) + if ( hap_enabled(d) ) hap_domain_init(d); } /* vcpu paging struct initialization goes here */ void paging_vcpu_init(struct vcpu *v) { - if ( opt_hap_enabled && is_hvm_vcpu(v) ) + if ( hap_enabled(v->domain) ) hap_vcpu_init(v); else shadow_vcpu_init(v); @@ -434,7 +432,7 @@ int paging_domctl(struct domain *d, xen_ } /* Here, dispatch domctl to the appropriate paging code */ - if ( opt_hap_enabled && is_hvm_domain(d) ) + if ( hap_enabled(d) ) return hap_domctl(d, sc, u_domctl); else return shadow_domctl(d, sc, u_domctl); @@ -443,7 +441,7 @@ int paging_domctl(struct domain *d, xen_ /* Call when destroying a domain */ void paging_teardown(struct domain *d) { - if ( opt_hap_enabled && is_hvm_domain(d) ) + if ( hap_enabled(d) ) hap_teardown(d); else shadow_teardown(d); @@ -455,7 +453,7 @@ void paging_teardown(struct domain *d) /* Call once all of the references to the domain have gone away */ void paging_final_teardown(struct domain *d) { - if ( opt_hap_enabled && is_hvm_domain(d) ) + if ( hap_enabled(d) ) hap_final_teardown(d); else shadow_final_teardown(d); @@ -465,7 +463,7 @@ void paging_final_teardown(struct domain * creation. */ int paging_enable(struct domain *d, u32 mode) { - if ( opt_hap_enabled && is_hvm_domain(d) ) + if ( hap_enabled(d) ) return hap_enable(d, mode | PG_HAP_enable); else return shadow_enable(d, mode | PG_SH_enable); diff -r 8817a53c030f -r b4c8cd753b88 xen/include/asm-x86/hvm/hvm.h --- a/xen/include/asm-x86/hvm/hvm.h Thu Sep 27 18:08:11 2007 +0100 +++ b/xen/include/asm-x86/hvm/hvm.h Fri Sep 28 15:03:50 2007 +0100 @@ -71,6 +71,9 @@ enum hvm_intack { */ struct hvm_function_table { char *name; + + /* Support Hardware-Assisted Paging? */ + int hap_supported; /* * Initialise/destroy HVM domain/vcpu resources _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |