* [PATCH 0/2] x86/hvm: Improvements to HAP superpage feature detection @ 2015-09-22 17:33 Andrew Cooper 2015-09-22 17:33 ` [PATCH 1/2] x86/hvm: Refine hap_has_{2mb,1gb} checks Andrew Cooper ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: Andrew Cooper @ 2015-09-22 17:33 UTC (permalink / raw) To: Xen-devel; +Cc: George Dunlap, Andrew Cooper, Jan Beulich Two small patches which reduce the runtime overhead of detecting HAP superpages by moving more initialisation into __init. Noticed while reviewing "x86/p2m: use large pages for MMIO mappings". Andrew Cooper (2): x86/hvm: Refine hap_has_{2mb,1gb} checks x86/hvm: Fold opt_hap_{2mb,1gb} into hap_capabilities xen/arch/x86/hvm/hvm.c | 8 ++++++++ xen/arch/x86/mm/p2m-ept.c | 4 ++-- xen/arch/x86/mm/p2m.c | 10 ++++------ xen/include/asm-x86/hvm/hvm.h | 6 ++---- 4 files changed, 16 insertions(+), 12 deletions(-) -- 1.7.10.4 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] x86/hvm: Refine hap_has_{2mb,1gb} checks 2015-09-22 17:33 [PATCH 0/2] x86/hvm: Improvements to HAP superpage feature detection Andrew Cooper @ 2015-09-22 17:33 ` Andrew Cooper 2015-09-23 8:47 ` [PATCH 1/2] x86/hvm: Refine hap_has_{2mb, 1gb} checks George Dunlap 2015-09-22 17:33 ` [PATCH 2/2] x86/hvm: Fold opt_hap_{2mb, 1gb} into hap_capabilities Andrew Cooper 2015-09-23 17:53 ` [PATCH 0/2] x86/hvm: Improvements to HAP superpage feature detection Konrad Rzeszutek Wilk 2 siblings, 1 reply; 6+ messages in thread From: Andrew Cooper @ 2015-09-22 17:33 UTC (permalink / raw) To: Xen-devel; +Cc: George Dunlap, Andrew Cooper, Jan Beulich HAP superpages are a host property and not dependent on domain configuration. Drop the domain paramter (which was only used in one of the two callsites), and drop the redundant hvm_ prefix to mirror the cpu_has_* style of feature detection. Finally, convert the checks to being proper booleans rather than just non-zero integers. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> --- CC: Jan Beulich <JBeulich@suse.com> CC: George Dunlap <george.dunlap@eu.citrix.com> --- xen/arch/x86/mm/p2m-ept.c | 4 ++-- xen/arch/x86/mm/p2m.c | 4 ++-- xen/include/asm-x86/hvm/hvm.h | 6 ++---- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c index 58db34e..dde242e 100644 --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -696,8 +696,8 @@ bool_t ept_handle_misconfig(uint64_t gpa) if ( ret > 0 ) needs_sync = sync_on; - ASSERT((target == 2 && hvm_hap_has_1gb()) || - (target == 1 && hvm_hap_has_2mb()) || + ASSERT((target == 2 && hap_has_1gb) || + (target == 1 && hap_has_2mb) || (target == 0)); ASSERT(!p2m_is_foreign(p2mt) || target == 0); diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index e1d930a..9cf7a71 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -452,9 +452,9 @@ int p2m_set_entry(struct p2m_domain *p2m, unsigned long gfn, mfn_t mfn, { if ( hap_enabled(d) ) order = ( (((gfn | mfn_x(mfn) | todo) & ((1ul << PAGE_ORDER_1G) - 1)) == 0) && - hvm_hap_has_1gb(d) && opt_hap_1gb ) ? PAGE_ORDER_1G : + hap_has_1gb && opt_hap_1gb) ? PAGE_ORDER_1G : ((((gfn | mfn_x(mfn) | todo) & ((1ul << PAGE_ORDER_2M) - 1)) == 0) && - hvm_hap_has_2mb(d) && opt_hap_2mb) ? PAGE_ORDER_2M : PAGE_ORDER_4K; + hap_has_2mb && opt_hap_2mb) ? PAGE_ORDER_2M : PAGE_ORDER_4K; else order = 0; diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h index 9f49e6d..2c3192c 100644 --- a/xen/include/asm-x86/hvm/hvm.h +++ b/xen/include/asm-x86/hvm/hvm.h @@ -278,10 +278,8 @@ int vmsi_deliver( (!!((v)->arch.hvm_vcpu.guest_efer & EFER_NX)) /* Can we use superpages in the HAP p2m table? */ -#define hvm_hap_has_1gb(d) \ - (hvm_funcs.hap_capabilities & HVM_HAP_SUPERPAGE_1GB) -#define hvm_hap_has_2mb(d) \ - (hvm_funcs.hap_capabilities & HVM_HAP_SUPERPAGE_2MB) +#define hap_has_1gb !!(hvm_funcs.hap_capabilities & HVM_HAP_SUPERPAGE_1GB) +#define hap_has_2mb !!(hvm_funcs.hap_capabilities & HVM_HAP_SUPERPAGE_2MB) /* Can the guest use 1GB superpages in its own pagetables? */ #define hvm_pse1gb_supported(d) \ -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] x86/hvm: Refine hap_has_{2mb, 1gb} checks 2015-09-22 17:33 ` [PATCH 1/2] x86/hvm: Refine hap_has_{2mb,1gb} checks Andrew Cooper @ 2015-09-23 8:47 ` George Dunlap 0 siblings, 0 replies; 6+ messages in thread From: George Dunlap @ 2015-09-23 8:47 UTC (permalink / raw) To: Andrew Cooper; +Cc: Jan Beulich, Xen-devel On Tue, Sep 22, 2015 at 6:33 PM, Andrew Cooper <andrew.cooper3@citrix.com> wrote: > HAP superpages are a host property and not dependent on domain configuration. > Drop the domain paramter (which was only used in one of the two callsites), > and drop the redundant hvm_ prefix to mirror the cpu_has_* style of feature > detection. > > Finally, convert the checks to being proper booleans rather than just non-zero > integers. > > Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Acked-by: George Dunlap <george.dunlap@citrix.com> ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] x86/hvm: Fold opt_hap_{2mb, 1gb} into hap_capabilities 2015-09-22 17:33 [PATCH 0/2] x86/hvm: Improvements to HAP superpage feature detection Andrew Cooper 2015-09-22 17:33 ` [PATCH 1/2] x86/hvm: Refine hap_has_{2mb,1gb} checks Andrew Cooper @ 2015-09-22 17:33 ` Andrew Cooper 2015-09-23 8:49 ` George Dunlap 2015-09-23 17:53 ` [PATCH 0/2] x86/hvm: Improvements to HAP superpage feature detection Konrad Rzeszutek Wilk 2 siblings, 1 reply; 6+ messages in thread From: Andrew Cooper @ 2015-09-22 17:33 UTC (permalink / raw) To: Xen-devel; +Cc: George Dunlap, Andrew Cooper, Jan Beulich This allows all runtime users to simply check hap_has_{2mb,1gb} rather than having to check opt_hap_{2mb,1gb} as well. As a result, opt_hap_{2mb,1gb} can move into __initdata. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> --- CC: Jan Beulich <JBeulich@suse.com> CC: George Dunlap <george.dunlap@eu.citrix.com> --- xen/arch/x86/hvm/hvm.c | 8 ++++++++ xen/arch/x86/mm/p2m.c | 10 ++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index f082b86..6afc344 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -158,9 +158,17 @@ static int __init hvm_enable(void) printk("HVM: Hardware Assisted Paging (HAP) detected\n"); printk("HVM: HAP page sizes: 4kB"); if ( fns->hap_capabilities & HVM_HAP_SUPERPAGE_2MB ) + { printk(", 2MB%s", opt_hap_2mb ? "" : " [disabled]"); + if ( !opt_hap_2mb ) + hvm_funcs.hap_capabilities &= ~HVM_HAP_SUPERPAGE_2MB; + } if ( fns->hap_capabilities & HVM_HAP_SUPERPAGE_1GB ) + { printk(", 1GB%s", opt_hap_1gb ? "" : " [disabled]"); + if ( !opt_hap_1gb ) + hvm_funcs.hap_capabilities &= ~HVM_HAP_SUPERPAGE_1GB; + } printk("\n"); } diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index 9cf7a71..5d2a532 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -41,11 +41,9 @@ #include "mm-locks.h" -/* turn on/off 1GB host page table support for hap, default on */ -bool_t __read_mostly opt_hap_1gb = 1; +/* turn on/off host superpage page table support for hap, default on */ +bool_t __initdata opt_hap_1gb = 1, __initdata opt_hap_2mb = 1; boolean_param("hap_1gb", opt_hap_1gb); - -bool_t __read_mostly opt_hap_2mb = 1; boolean_param("hap_2mb", opt_hap_2mb); @@ -452,9 +450,9 @@ int p2m_set_entry(struct p2m_domain *p2m, unsigned long gfn, mfn_t mfn, { if ( hap_enabled(d) ) order = ( (((gfn | mfn_x(mfn) | todo) & ((1ul << PAGE_ORDER_1G) - 1)) == 0) && - hap_has_1gb && opt_hap_1gb) ? PAGE_ORDER_1G : + hap_has_1gb) ? PAGE_ORDER_1G : ((((gfn | mfn_x(mfn) | todo) & ((1ul << PAGE_ORDER_2M) - 1)) == 0) && - hap_has_2mb && opt_hap_2mb) ? PAGE_ORDER_2M : PAGE_ORDER_4K; + hap_has_2mb) ? PAGE_ORDER_2M : PAGE_ORDER_4K; else order = 0; -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] x86/hvm: Fold opt_hap_{2mb, 1gb} into hap_capabilities 2015-09-22 17:33 ` [PATCH 2/2] x86/hvm: Fold opt_hap_{2mb, 1gb} into hap_capabilities Andrew Cooper @ 2015-09-23 8:49 ` George Dunlap 0 siblings, 0 replies; 6+ messages in thread From: George Dunlap @ 2015-09-23 8:49 UTC (permalink / raw) To: Andrew Cooper; +Cc: Jan Beulich, Xen-devel On Tue, Sep 22, 2015 at 6:33 PM, Andrew Cooper <andrew.cooper3@citrix.com> wrote: > This allows all runtime users to simply check hap_has_{2mb,1gb} rather than > having to check opt_hap_{2mb,1gb} as well. > > As a result, opt_hap_{2mb,1gb} can move into __initdata. > > Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Acked-by: George Dunlap <george.dunlap@citrix.com> > --- > CC: Jan Beulich <JBeulich@suse.com> > CC: George Dunlap <george.dunlap@eu.citrix.com> > --- > xen/arch/x86/hvm/hvm.c | 8 ++++++++ > xen/arch/x86/mm/p2m.c | 10 ++++------ > 2 files changed, 12 insertions(+), 6 deletions(-) > > diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c > index f082b86..6afc344 100644 > --- a/xen/arch/x86/hvm/hvm.c > +++ b/xen/arch/x86/hvm/hvm.c > @@ -158,9 +158,17 @@ static int __init hvm_enable(void) > printk("HVM: Hardware Assisted Paging (HAP) detected\n"); > printk("HVM: HAP page sizes: 4kB"); > if ( fns->hap_capabilities & HVM_HAP_SUPERPAGE_2MB ) > + { > printk(", 2MB%s", opt_hap_2mb ? "" : " [disabled]"); > + if ( !opt_hap_2mb ) > + hvm_funcs.hap_capabilities &= ~HVM_HAP_SUPERPAGE_2MB; > + } > if ( fns->hap_capabilities & HVM_HAP_SUPERPAGE_1GB ) > + { > printk(", 1GB%s", opt_hap_1gb ? "" : " [disabled]"); > + if ( !opt_hap_1gb ) > + hvm_funcs.hap_capabilities &= ~HVM_HAP_SUPERPAGE_1GB; > + } > printk("\n"); > } > > diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c > index 9cf7a71..5d2a532 100644 > --- a/xen/arch/x86/mm/p2m.c > +++ b/xen/arch/x86/mm/p2m.c > @@ -41,11 +41,9 @@ > > #include "mm-locks.h" > > -/* turn on/off 1GB host page table support for hap, default on */ > -bool_t __read_mostly opt_hap_1gb = 1; > +/* turn on/off host superpage page table support for hap, default on */ > +bool_t __initdata opt_hap_1gb = 1, __initdata opt_hap_2mb = 1; > boolean_param("hap_1gb", opt_hap_1gb); > - > -bool_t __read_mostly opt_hap_2mb = 1; > boolean_param("hap_2mb", opt_hap_2mb); > > > @@ -452,9 +450,9 @@ int p2m_set_entry(struct p2m_domain *p2m, unsigned long gfn, mfn_t mfn, > { > if ( hap_enabled(d) ) > order = ( (((gfn | mfn_x(mfn) | todo) & ((1ul << PAGE_ORDER_1G) - 1)) == 0) && > - hap_has_1gb && opt_hap_1gb) ? PAGE_ORDER_1G : > + hap_has_1gb) ? PAGE_ORDER_1G : > ((((gfn | mfn_x(mfn) | todo) & ((1ul << PAGE_ORDER_2M) - 1)) == 0) && > - hap_has_2mb && opt_hap_2mb) ? PAGE_ORDER_2M : PAGE_ORDER_4K; > + hap_has_2mb) ? PAGE_ORDER_2M : PAGE_ORDER_4K; > else > order = 0; > > -- > 1.7.10.4 > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] x86/hvm: Improvements to HAP superpage feature detection 2015-09-22 17:33 [PATCH 0/2] x86/hvm: Improvements to HAP superpage feature detection Andrew Cooper 2015-09-22 17:33 ` [PATCH 1/2] x86/hvm: Refine hap_has_{2mb,1gb} checks Andrew Cooper 2015-09-22 17:33 ` [PATCH 2/2] x86/hvm: Fold opt_hap_{2mb, 1gb} into hap_capabilities Andrew Cooper @ 2015-09-23 17:53 ` Konrad Rzeszutek Wilk 2 siblings, 0 replies; 6+ messages in thread From: Konrad Rzeszutek Wilk @ 2015-09-23 17:53 UTC (permalink / raw) To: Andrew Cooper; +Cc: George Dunlap, Jan Beulich, Xen-devel On Tue, Sep 22, 2015 at 06:33:01PM +0100, Andrew Cooper wrote: > Two small patches which reduce the runtime overhead of detecting HAP > superpages by moving more initialisation into __init. > > Noticed while reviewing "x86/p2m: use large pages for MMIO mappings". Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> for both patches. > > Andrew Cooper (2): > x86/hvm: Refine hap_has_{2mb,1gb} checks > x86/hvm: Fold opt_hap_{2mb,1gb} into hap_capabilities > > xen/arch/x86/hvm/hvm.c | 8 ++++++++ > xen/arch/x86/mm/p2m-ept.c | 4 ++-- > xen/arch/x86/mm/p2m.c | 10 ++++------ > xen/include/asm-x86/hvm/hvm.h | 6 ++---- > 4 files changed, 16 insertions(+), 12 deletions(-) > > -- > 1.7.10.4 > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-09-23 17:53 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-09-22 17:33 [PATCH 0/2] x86/hvm: Improvements to HAP superpage feature detection Andrew Cooper 2015-09-22 17:33 ` [PATCH 1/2] x86/hvm: Refine hap_has_{2mb,1gb} checks Andrew Cooper 2015-09-23 8:47 ` [PATCH 1/2] x86/hvm: Refine hap_has_{2mb, 1gb} checks George Dunlap 2015-09-22 17:33 ` [PATCH 2/2] x86/hvm: Fold opt_hap_{2mb, 1gb} into hap_capabilities Andrew Cooper 2015-09-23 8:49 ` George Dunlap 2015-09-23 17:53 ` [PATCH 0/2] x86/hvm: Improvements to HAP superpage feature detection Konrad Rzeszutek Wilk
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).