[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen staging] x86/shadow: fold p2m page accounting into sh_min_allocation()
commit 8e8ae158c85fd8b26ff7c0abc52fc5767905d7f9 Author: Jan Beulich <jbeulich@xxxxxxxx> AuthorDate: Wed Sep 11 14:54:34 2019 +0200 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Wed Sep 11 14:54:34 2019 +0200 x86/shadow: fold p2m page accounting into sh_min_allocation() This is to make the function live up to the promise its name makes. And it simplifies all callers. Suggested-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx> Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Acked-by: Tim Deegan <tim@xxxxxxx> --- xen/arch/x86/mm/shadow/common.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/common.c index bc9d41d38b..314d837602 100644 --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -1256,29 +1256,26 @@ static unsigned int sh_min_allocation(const struct domain *d) * up of slot zero and an LAPIC page), plus one for HVM's 1-to-1 pagetable. */ return shadow_min_acceptable_pages(d) + - max(d->tot_pages / 256, - is_hvm_domain(d) ? CONFIG_PAGING_LEVELS + 2 : 0U) + - is_hvm_domain(d); + max(max(d->tot_pages / 256, + is_hvm_domain(d) ? CONFIG_PAGING_LEVELS + 2 : 0U) + + is_hvm_domain(d), + d->arch.paging.shadow.p2m_pages); } int shadow_set_allocation(struct domain *d, unsigned int pages, bool *preempted) { struct page_info *sp; - unsigned int lower_bound; ASSERT(paging_locked_by_me(d)); if ( pages > 0 ) { /* Check for minimum value. */ - if ( pages < d->arch.paging.shadow.p2m_pages ) - pages = 0; - else - pages -= d->arch.paging.shadow.p2m_pages; + unsigned int lower_bound = sh_min_allocation(d); - lower_bound = sh_min_allocation(d); if ( pages < lower_bound ) pages = lower_bound; + pages -= d->arch.paging.shadow.p2m_pages; } SHADOW_PRINTK("current %i target %i\n", @@ -2607,7 +2604,7 @@ int shadow_enable(struct domain *d, u32 mode) /* Init the shadow memory allocation if the user hasn't done so */ old_pages = d->arch.paging.shadow.total_pages; - if ( old_pages < sh_min_allocation(d) + d->arch.paging.shadow.p2m_pages ) + if ( old_pages < sh_min_allocation(d) ) { paging_lock(d); rv = shadow_set_allocation(d, 1024, NULL); /* Use at least 4MB */ @@ -2864,8 +2861,7 @@ static int shadow_one_bit_enable(struct domain *d, u32 mode) mode |= PG_SH_enable; - if ( d->arch.paging.shadow.total_pages < - sh_min_allocation(d) + d->arch.paging.shadow.p2m_pages ) + if ( d->arch.paging.shadow.total_pages < sh_min_allocation(d) ) { /* Init the shadow memory allocation if the user hasn't done so */ if ( shadow_set_allocation(d, 1, NULL) != 0 ) -- generated by git-patchbot for /home/xen/git/xen.git#staging _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |