From patchwork Tue Sep 27 15:57:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 9352205 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2022160757 for ; Tue, 27 Sep 2016 16:01:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 111162927A for ; Tue, 27 Sep 2016 16:01:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 051692928A; Tue, 27 Sep 2016 16:00:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A6C502928B for ; Tue, 27 Sep 2016 16:00:54 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1boulv-0007aP-3p; Tue, 27 Sep 2016 15:58:19 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1boult-0007Xd-Av for xen-devel@lists.xenproject.org; Tue, 27 Sep 2016 15:58:17 +0000 Received: from [85.158.139.211] by server-7.bemta-5.messagelabs.com id 2E/FD-05127-8179AE75; Tue, 27 Sep 2016 15:58:16 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrBIsWRWlGSWpSXmKPExsXitHSDva749Ff hBgdbxS2+b5nM5MDocfjDFZYAxijWzLyk/IoE1oyvt8QLbphWrJ7ZyNjAuFW7i5GTQ0LAX2LL lKesIDabgI7Exbk72boYOThEBFQkbu816GLk4mAW+MUocehBGwtIjbCAq8TNWWeZQWwWAVWJP zs/gcV5BVwk2qdfY4WYqSvx8NxvMJsTqL63bQETiC0EVHN35kdWiHpBiZMzn4D1MgtoSrRu/8 0OYctLNG+dzQxRryjRP+8BG8RMbonbp6cyT2Dkn4WkfRaS9llI2hcwMq9i1ChOLSpLLdI1NNR LKspMzyjJTczM0TU0MNXLTS0uTkxPzUlMKtZLzs/dxAgMQQYg2MG4st35EKMkB5OSKK9G+6tw Ib6k/JTKjMTijPii0pzU4kOMMhwcShK8HlOBcoJFqempFWmZOcBogElLcPAoifDyTANK8xYXJ OYWZ6ZDpE4xKkqJ8zaA9AmAJDJK8+DaYBF4iVFWSpiXEegQIZ6C1KLczBJU+VeM4hyMSsK8Ci DjeTLzSuCmvwJazAS0eOmJFyCLSxIRUlINjDWenGe9jp88pnh9rW7gzC7WXRwWAbES0vlvfhu scpvMlCX5jGvLRRmeXzll6x331c5ZJPn32tdPHI7O967+5QzdvqltqskPv/PLI1LCLzR/i/56 u3DKLqbKVfa3ZrO3lDl7We5xF3GX2zffppLvIi/3onPmG0Q+z6jb6yCYdZ99zz35k6eiWpVYi jMSDbWYi4oTAW0jAt+7AgAA X-Env-Sender: prvs=071b8e69e=roger.pau@citrix.com X-Msg-Ref: server-5.tower-206.messagelabs.com!1474991886!60100383!4 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 17126 invoked from network); 27 Sep 2016 15:58:15 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-5.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 27 Sep 2016 15:58:15 -0000 X-IronPort-AV: E=Sophos;i="5.30,405,1470700800"; d="scan'208";a="389169496" From: Roger Pau Monne To: Date: Tue, 27 Sep 2016 17:57:01 +0200 Message-ID: <1474991845-27962-7-git-send-email-roger.pau@citrix.com> X-Mailer: git-send-email 2.7.4 (Apple Git-66) In-Reply-To: <1474991845-27962-1-git-send-email-roger.pau@citrix.com> References: <1474991845-27962-1-git-send-email-roger.pau@citrix.com> MIME-Version: 1.0 X-DLP: MIA2 Cc: George Dunlap , Andrew Cooper , Tim Deegan , Jan Beulich , boris.ostrovsky@oracle.com, Roger Pau Monne Subject: [Xen-devel] [PATCH v2 06/30] x86/paging: introduce paging_set_allocation X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP ... and remove hap_set_alloc_for_pvh_dom0. Signed-off-by: Roger Pau Monné Acked-by: Tim Deegan Acked-by: George Dunlap --- Cc: Jan Beulich Cc: Andrew Cooper Cc: George Dunlap Cc: Tim Deegan --- Changes since RFC: - Make paging_set_allocation preemtable. - Move comments. --- xen/arch/x86/domain_build.c | 17 +++++++++++++---- xen/arch/x86/mm/hap/hap.c | 14 +------------- xen/arch/x86/mm/paging.c | 16 ++++++++++++++++ xen/arch/x86/mm/shadow/common.c | 7 +------ xen/include/asm-x86/hap.h | 2 +- xen/include/asm-x86/paging.h | 7 +++++++ xen/include/asm-x86/shadow.h | 8 ++++++++ 7 files changed, 47 insertions(+), 24 deletions(-) diff --git a/xen/arch/x86/domain_build.c b/xen/arch/x86/domain_build.c index 0a02d65..04d6cb0 100644 --- a/xen/arch/x86/domain_build.c +++ b/xen/arch/x86/domain_build.c @@ -35,7 +35,6 @@ #include #include /* for bzimage_parse */ #include -#include #include #include @@ -1383,15 +1382,25 @@ int __init construct_dom0( nr_pages); } - if ( is_pvh_domain(d) ) - hap_set_alloc_for_pvh_dom0(d, dom0_paging_pages(d, nr_pages)); - /* * We enable paging mode again so guest_physmap_add_page will do the * right thing for us. */ d->arch.paging.mode = save_pvh_pg_mode; + if ( is_pvh_domain(d) ) + { + int preempted; + + do { + preempted = 0; + paging_set_allocation(d, dom0_paging_pages(d, nr_pages), + &preempted); + process_pending_softirqs(); + } while ( preempted ); + } + + /* Write the phys->machine and machine->phys table entries. */ for ( pfn = 0; pfn < count; pfn++ ) { diff --git a/xen/arch/x86/mm/hap/hap.c b/xen/arch/x86/mm/hap/hap.c index 2dc82f5..4420e4e 100644 --- a/xen/arch/x86/mm/hap/hap.c +++ b/xen/arch/x86/mm/hap/hap.c @@ -334,7 +334,7 @@ hap_get_allocation(struct domain *d) /* Set the pool of pages to the required number of pages. * Returns 0 for success, non-zero for failure. */ -static int +int hap_set_allocation(struct domain *d, unsigned long pages, int *preempted) { struct page_info *pg; @@ -640,18 +640,6 @@ int hap_domctl(struct domain *d, xen_domctl_shadow_op_t *sc, } } -void __init hap_set_alloc_for_pvh_dom0(struct domain *d, - unsigned long hap_pages) -{ - int rc; - - paging_lock(d); - rc = hap_set_allocation(d, hap_pages, NULL); - paging_unlock(d); - - BUG_ON(rc); -} - static const struct paging_mode hap_paging_real_mode; static const struct paging_mode hap_paging_protected_mode; static const struct paging_mode hap_paging_pae_mode; diff --git a/xen/arch/x86/mm/paging.c b/xen/arch/x86/mm/paging.c index cc44682..2717bd3 100644 --- a/xen/arch/x86/mm/paging.c +++ b/xen/arch/x86/mm/paging.c @@ -954,6 +954,22 @@ void paging_write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn, safe_write_pte(p, new); } +int paging_set_allocation(struct domain *d, unsigned long pages, int *preempted) +{ + int rc; + + ASSERT(paging_mode_enabled(d)); + + paging_lock(d); + if ( hap_enabled(d) ) + rc = hap_set_allocation(d, pages, preempted); + else + rc = sh_set_allocation(d, pages, preempted); + paging_unlock(d); + + return rc; +} + /* * Local variables: * mode: C diff --git a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/common.c index d3cc2cc..53ffe1a 100644 --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -1609,12 +1609,7 @@ shadow_free_p2m_page(struct domain *d, struct page_info *pg) paging_unlock(d); } -/* Set the pool of shadow pages to the required number of pages. - * Input will be rounded up to at least shadow_min_acceptable_pages(), - * plus space for the p2m table. - * Returns 0 for success, non-zero for failure. */ -static int sh_set_allocation(struct domain *d, unsigned long pages, - int *preempted) +int sh_set_allocation(struct domain *d, unsigned long pages, int *preempted) { struct page_info *sp; unsigned int lower_bound; diff --git a/xen/include/asm-x86/hap.h b/xen/include/asm-x86/hap.h index c613836..9d59430 100644 --- a/xen/include/asm-x86/hap.h +++ b/xen/include/asm-x86/hap.h @@ -46,7 +46,7 @@ int hap_track_dirty_vram(struct domain *d, XEN_GUEST_HANDLE_64(uint8) dirty_bitmap); extern const struct paging_mode *hap_paging_get_mode(struct vcpu *); -void hap_set_alloc_for_pvh_dom0(struct domain *d, unsigned long num_pages); +int hap_set_allocation(struct domain *d, unsigned long pages, int *preempted); #endif /* XEN_HAP_H */ diff --git a/xen/include/asm-x86/paging.h b/xen/include/asm-x86/paging.h index 56eef6b..c2d60d3 100644 --- a/xen/include/asm-x86/paging.h +++ b/xen/include/asm-x86/paging.h @@ -347,6 +347,13 @@ void pagetable_dying(struct domain *d, paddr_t gpa); void paging_dump_domain_info(struct domain *d); void paging_dump_vcpu_info(struct vcpu *v); +/* Set the pool of shadow pages to the required number of pages. + * Input might be rounded up to at minimum amount of pages, plus + * space for the p2m table. + * Returns 0 for success, non-zero for failure. */ +int paging_set_allocation(struct domain *d, unsigned long pages, + int *preempted); + #endif /* XEN_PAGING_H */ /* diff --git a/xen/include/asm-x86/shadow.h b/xen/include/asm-x86/shadow.h index 6d0aefb..f0e2227 100644 --- a/xen/include/asm-x86/shadow.h +++ b/xen/include/asm-x86/shadow.h @@ -83,6 +83,12 @@ void sh_remove_shadows(struct domain *d, mfn_t gmfn, int fast, int all); /* Discard _all_ mappings from the domain's shadows. */ void shadow_blow_tables_per_domain(struct domain *d); +/* Set the pool of shadow pages to the required number of pages. + * Input will be rounded up to at least shadow_min_acceptable_pages(), + * plus space for the p2m table. + * Returns 0 for success, non-zero for failure. */ +int sh_set_allocation(struct domain *d, unsigned long pages, int *preempted); + #else /* !CONFIG_SHADOW_PAGING */ #define shadow_teardown(d, p) ASSERT(is_pv_domain(d)) @@ -91,6 +97,8 @@ void shadow_blow_tables_per_domain(struct domain *d); ({ ASSERT(is_pv_domain(d)); -EOPNOTSUPP; }) #define shadow_track_dirty_vram(d, begin_pfn, nr, bitmap) \ ({ ASSERT_UNREACHABLE(); -EOPNOTSUPP; }) +#define sh_set_allocation(d, pages, preempted) \ + ({ ASSERT_UNREACHABLE(); -EOPNOTSUPP; }) static inline void sh_remove_shadows(struct domain *d, mfn_t gmfn, bool_t fast, bool_t all) {}