From patchwork Wed Aug 31 02:40:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Penny Zheng X-Patchwork-Id: 12960268 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 58E39C3DA6B for ; Wed, 31 Aug 2022 02:41:23 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.395292.634854 (Exim 4.92) (envelope-from ) id 1oTDf6-00062o-CC; Wed, 31 Aug 2022 02:41:04 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 395292.634854; Wed, 31 Aug 2022 02:41:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oTDf6-00062h-9N; Wed, 31 Aug 2022 02:41:04 +0000 Received: by outflank-mailman (input) for mailman id 395292; Wed, 31 Aug 2022 02:41:03 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oTDf5-0005nD-6M for xen-devel@lists.xenproject.org; Wed, 31 Aug 2022 02:41:03 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id 5949800f-28d6-11ed-bd2e-47488cf2e6aa; Wed, 31 Aug 2022 04:41:00 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 336CDED1; Tue, 30 Aug 2022 19:41:06 -0700 (PDT) Received: from a011292.shanghai.arm.com (a011292.shanghai.arm.com [10.169.190.94]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2DE153F71A; Tue, 30 Aug 2022 19:40:55 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 5949800f-28d6-11ed-bd2e-47488cf2e6aa From: Penny Zheng To: xen-devel@lists.xenproject.org Cc: wei.chen@arm.com, Penny Zheng , Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk , Andrew Cooper , George Dunlap , Jan Beulich , Wei Liu , Penny Zheng , Julien Grall Subject: [PATCH v11 1/6] xen: do not free reserved memory into heap Date: Wed, 31 Aug 2022 10:40:36 +0800 Message-Id: <20220831024041.468757-2-Penny.Zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220831024041.468757-1-Penny.Zheng@arm.com> References: <20220831024041.468757-1-Penny.Zheng@arm.com> MIME-Version: 1.0 Pages used as guest RAM for static domain, shall be reserved to this domain only. So in case reserved pages being used for other purpose, users shall not free them back to heap, even when last ref gets dropped. This commit introduces a new helper free_domstatic_page to free static page in runtime, and free_staticmem_pages will be called by it in runtime, so let's drop the __init flag. Wrapper #ifdef CONFIG_STATIC_MEMORY around function declaration( free_staticmem_pages, free_domstatic_page, etc) is kinds of redundant, so we decide to remove it here. Signed-off-by: Penny Zheng Reviewed-by: Jan Beulich Reviewed-by: Julien Grall --- v11 changes: - printing message ahead of the assertion, which should also be XENLOG_G_* kind of log level --- v10 changes: - let Arm keep #define PGC_static 0 private, with the generic fallback remaining in page_alloc.c - change ASSERT(d) to ASSERT_UNREACHABLE() to be more robust looking forward, and also add a printk() to log the problem - mention the the removal of #ifdef CONFIG_STATIC_MEMORY in commit message --- v9 changes: - move free_domheap_page into else-condition - considering scrubbing static pages, domain dying case and opt_scrub_domheap both donot apply to static pages. - as unowned static pages don't make themselves to free_domstatic_page at the moment, remove else-condition and add ASSERT(d) at the top of the function --- v8 changes: - introduce new helper free_domstatic_page - let put_page call free_domstatic_page for static page, when last ref drops - #define PGC_static zero when !CONFIG_STATIC_MEMORY, as it is used outside page_alloc.c --- v7 changes: - protect free_staticmem_pages with heap_lock to match its reverse function acquire_staticmem_pages --- v6 changes: - adapt to PGC_static - remove #ifdef aroud function declaration --- v5 changes: - In order to avoid stub functions, we #define PGC_staticmem to non-zero only when CONFIG_STATIC_MEMORY - use "unlikely()" around pg->count_info & PGC_staticmem - remove pointless "if", since mark_page_free() is going to set count_info to PGC_state_free and by consequence clear PGC_staticmem - move #define PGC_staticmem 0 to mm.h --- v4 changes: - no changes --- v3 changes: - fix possible racy issue in free_staticmem_pages() - introduce a stub free_staticmem_pages() for the !CONFIG_STATIC_MEMORY case - move the change to free_heap_pages() to cover other potential call sites - fix the indentation --- v2 changes: - new commit --- xen/arch/arm/include/asm/mm.h | 6 +++++- xen/arch/arm/mm.c | 5 ++++- xen/common/page_alloc.c | 40 ++++++++++++++++++++++++++++++++--- xen/include/xen/mm.h | 3 +-- 4 files changed, 47 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/include/asm/mm.h b/xen/arch/arm/include/asm/mm.h index da25251cda..749fbefa0c 100644 --- a/xen/arch/arm/include/asm/mm.h +++ b/xen/arch/arm/include/asm/mm.h @@ -121,9 +121,13 @@ struct page_info /* Page is Xen heap? */ #define _PGC_xen_heap PG_shift(2) #define PGC_xen_heap PG_mask(1, 2) - /* Page is static memory */ +#ifdef CONFIG_STATIC_MEMORY +/* Page is static memory */ #define _PGC_static PG_shift(3) #define PGC_static PG_mask(1, 3) +#else +#define PGC_static 0 +#endif /* ... */ /* Page is broken? */ #define _PGC_broken PG_shift(7) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index b42cddb1b4..fbdab5598c 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -1496,7 +1496,10 @@ void put_page(struct page_info *page) if ( unlikely((nx & PGC_count_mask) == 0) ) { - free_domheap_page(page); + if ( unlikely(nx & PGC_static) ) + free_domstatic_page(page); + else + free_domheap_page(page); } } diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index bfd4150be7..0c50dee4c5 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -2694,12 +2694,14 @@ struct domain *get_pg_owner(domid_t domid) #ifdef CONFIG_STATIC_MEMORY /* Equivalent of free_heap_pages to free nr_mfns pages of static memory. */ -void __init free_staticmem_pages(struct page_info *pg, unsigned long nr_mfns, - bool need_scrub) +void free_staticmem_pages(struct page_info *pg, unsigned long nr_mfns, + bool need_scrub) { mfn_t mfn = page_to_mfn(pg); unsigned long i; + spin_lock(&heap_lock); + for ( i = 0; i < nr_mfns; i++ ) { mark_page_free(&pg[i], mfn_add(mfn, i)); @@ -2710,9 +2712,41 @@ void __init free_staticmem_pages(struct page_info *pg, unsigned long nr_mfns, scrub_one_page(pg); } - /* In case initializing page of static memory, mark it PGC_static. */ pg[i].count_info |= PGC_static; } + + spin_unlock(&heap_lock); +} + +void free_domstatic_page(struct page_info *page) +{ + struct domain *d = page_get_owner(page); + bool drop_dom_ref; + + if ( unlikely(!d) ) + { + printk(XENLOG_G_ERR + "The about-to-free static page %"PRI_mfn" must be owned by a domain\n", + mfn_x(page_to_mfn(page))); + ASSERT_UNREACHABLE(); + return; + } + + ASSERT_ALLOC_CONTEXT(); + + /* NB. May recursively lock from relinquish_memory(). */ + spin_lock_recursive(&d->page_alloc_lock); + + arch_free_heap_page(d, page); + + drop_dom_ref = !domain_adjust_tot_pages(d, -1); + + spin_unlock_recursive(&d->page_alloc_lock); + + free_staticmem_pages(page, 1, scrub_debug); + + if ( drop_dom_ref ) + put_domain(d); } /* diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index 35b065146f..deadf4b2a1 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -85,13 +85,12 @@ bool scrub_free_pages(void); } while ( false ) #define FREE_XENHEAP_PAGE(p) FREE_XENHEAP_PAGES(p, 0) -#ifdef CONFIG_STATIC_MEMORY /* These functions are for static memory */ void free_staticmem_pages(struct page_info *pg, unsigned long nr_mfns, bool need_scrub); +void free_domstatic_page(struct page_info *page); int acquire_domstatic_pages(struct domain *d, mfn_t smfn, unsigned int nr_mfns, unsigned int memflags); -#endif /* Map machine page range in Xen virtual address space. */ int map_pages_to_xen( From patchwork Wed Aug 31 02:40:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Penny Zheng X-Patchwork-Id: 12960265 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C3235ECAAA1 for ; Wed, 31 Aug 2022 02:41:21 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.395293.634865 (Exim 4.92) (envelope-from ) id 1oTDf8-0006Ja-O4; Wed, 31 Aug 2022 02:41:06 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 395293.634865; Wed, 31 Aug 2022 02:41:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oTDf8-0006JR-Kx; Wed, 31 Aug 2022 02:41:06 +0000 Received: by outflank-mailman (input) for mailman id 395293; Wed, 31 Aug 2022 02:41:05 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oTDf7-0005nD-Qw for xen-devel@lists.xenproject.org; Wed, 31 Aug 2022 02:41:05 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id 5bdeea27-28d6-11ed-bd2e-47488cf2e6aa; Wed, 31 Aug 2022 04:41:05 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 924F61042; Tue, 30 Aug 2022 19:41:10 -0700 (PDT) Received: from a011292.shanghai.arm.com (a011292.shanghai.arm.com [10.169.190.94]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8DB843F71A; Tue, 30 Aug 2022 19:41:00 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 5bdeea27-28d6-11ed-bd2e-47488cf2e6aa From: Penny Zheng To: xen-devel@lists.xenproject.org Cc: wei.chen@arm.com, Penny Zheng , Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk , Andrew Cooper , George Dunlap , Jan Beulich , Wei Liu , Penny Zheng , Julien Grall Subject: [PATCH v11 2/6] xen/arm: introduce CDF_staticmem Date: Wed, 31 Aug 2022 10:40:37 +0800 Message-Id: <20220831024041.468757-3-Penny.Zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220831024041.468757-1-Penny.Zheng@arm.com> References: <20220831024041.468757-1-Penny.Zheng@arm.com> MIME-Version: 1.0 In order to have an easy and quick way to find out whether this domain memory is statically configured, this commit introduces a new flag CDF_staticmem and a new helper is_domain_using_staticmem() to tell. Signed-off-by: Penny Zheng Acked-by: Julien Grall Acked-by: Jan Beulich --- v11 changes: - no change --- v10 changes: - no change --- v9 changes: - no change --- v8 changes: - #ifdef-ary around is_domain_using_staticmem() is not needed anymore --- v7 changes: - IS_ENABLED(CONFIG_STATIC_MEMORY) would not be needed anymore --- v6 changes: - move non-zero is_domain_using_staticmem() from ARM header to common header --- v5 changes: - guard "is_domain_using_staticmem" under CONFIG_STATIC_MEMORY - #define is_domain_using_staticmem zero if undefined --- v4 changes: - no changes --- v3 changes: - change name from "is_domain_static()" to "is_domain_using_staticmem" --- v2 changes: - change name from "is_domain_on_static_allocation" to "is_domain_static() --- xen/arch/arm/domain_build.c | 5 ++++- xen/include/xen/domain.h | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 3fd1186b53..b76a84e8f5 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -3287,9 +3287,12 @@ void __init create_domUs(void) if ( !dt_device_is_compatible(node, "xen,domain") ) continue; + if ( dt_find_property(node, "xen,static-mem", NULL) ) + flags |= CDF_staticmem; + if ( dt_property_read_bool(node, "direct-map") ) { - if ( !IS_ENABLED(CONFIG_STATIC_MEMORY) || !dt_find_property(node, "xen,static-mem", NULL) ) + if ( !(flags & CDF_staticmem) ) panic("direct-map is not valid for domain %s without static allocation.\n", dt_node_name(node)); diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index 628b14b086..2c8116afba 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -35,6 +35,14 @@ void arch_get_domain_info(const struct domain *d, /* Should domain memory be directly mapped? */ #define CDF_directmap (1U << 1) #endif +/* Is domain memory on static allocation? */ +#ifdef CONFIG_STATIC_MEMORY +#define CDF_staticmem (1U << 2) +#else +#define CDF_staticmem 0 +#endif + +#define is_domain_using_staticmem(d) ((d)->cdf & CDF_staticmem) /* * Arch-specifics. From patchwork Wed Aug 31 02:40:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Penny Zheng X-Patchwork-Id: 12960269 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F22A9ECAAD5 for ; Wed, 31 Aug 2022 02:41:22 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.395294.634875 (Exim 4.92) (envelope-from ) id 1oTDfC-0006dx-Vh; Wed, 31 Aug 2022 02:41:10 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 395294.634875; Wed, 31 Aug 2022 02:41:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oTDfC-0006dl-SQ; Wed, 31 Aug 2022 02:41:10 +0000 Received: by outflank-mailman (input) for mailman id 395294; Wed, 31 Aug 2022 02:41:10 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oTDfC-0005nD-3S for xen-devel@lists.xenproject.org; Wed, 31 Aug 2022 02:41:10 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id 5e3ec29f-28d6-11ed-bd2e-47488cf2e6aa; Wed, 31 Aug 2022 04:41:09 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 735DDED1; Tue, 30 Aug 2022 19:41:14 -0700 (PDT) Received: from a011292.shanghai.arm.com (a011292.shanghai.arm.com [10.169.190.94]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id ECA323F71A; Tue, 30 Aug 2022 19:41:04 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 5e3ec29f-28d6-11ed-bd2e-47488cf2e6aa From: Penny Zheng To: xen-devel@lists.xenproject.org Cc: wei.chen@arm.com, Penny Zheng , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Penny Zheng , Julien Grall Subject: [PATCH v11 3/6] xen: unpopulate memory when domain is static Date: Wed, 31 Aug 2022 10:40:38 +0800 Message-Id: <20220831024041.468757-4-Penny.Zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220831024041.468757-1-Penny.Zheng@arm.com> References: <20220831024041.468757-1-Penny.Zheng@arm.com> MIME-Version: 1.0 Today when a domain unpopulates the memory on runtime, they will always hand the memory back to the heap allocator. And it will be a problem if domain is static. Pages as guest RAM for static domain shall be reserved to only this domain and not be used for any other purposes, so they shall never go back to heap allocator. This commit puts reserved page on the new list resv_page_list after it has been freed. Signed-off-by: Penny Zheng Acked-by: Jan Beulich Acked-by: Julien Grall --- v11 change: - commit message tweak --- v10 change: - Do not skip the list addition in that one special case --- v9 change: - remove macro helper put_static_page, and just expand its code inside free_domstatic_page --- v8 changes: - adapt this patch for newly introduced free_domstatic_page - order as a parameter is not needed here, as all staticmem operations are limited to order-0 regions - move d->page_alloc_lock after operation on d->resv_page_list --- v7 changes: - Add page on the rsv_page_list *after* it has been freed --- v6 changes: - refine in-code comment - move PGC_static !CONFIG_STATIC_MEMORY definition to common header --- v5 changes: - adapt this patch for PGC_staticmem --- v4 changes: - no changes --- v3 changes: - have page_list_del() just once out of the if() - remove resv_pages counter - make arch_free_heap_page be an expression, not a compound statement. --- v2 changes: - put reserved pages on resv_page_list after having taken them off the "normal" list --- xen/common/domain.c | 4 ++++ xen/common/page_alloc.c | 7 +++++-- xen/include/xen/sched.h | 3 +++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/xen/common/domain.c b/xen/common/domain.c index 7062393e37..c23f449451 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -604,6 +604,10 @@ struct domain *domain_create(domid_t domid, INIT_PAGE_LIST_HEAD(&d->page_list); INIT_PAGE_LIST_HEAD(&d->extra_page_list); INIT_PAGE_LIST_HEAD(&d->xenpage_list); +#ifdef CONFIG_STATIC_MEMORY + INIT_PAGE_LIST_HEAD(&d->resv_page_list); +#endif + spin_lock_init(&d->node_affinity_lock); d->node_affinity = NODE_MASK_ALL; diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 0c50dee4c5..26a2fad4e3 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -2741,10 +2741,13 @@ void free_domstatic_page(struct page_info *page) drop_dom_ref = !domain_adjust_tot_pages(d, -1); - spin_unlock_recursive(&d->page_alloc_lock); - free_staticmem_pages(page, 1, scrub_debug); + /* Add page on the resv_page_list *after* it has been freed. */ + page_list_add_tail(page, &d->resv_page_list); + + spin_unlock_recursive(&d->page_alloc_lock); + if ( drop_dom_ref ) put_domain(d); } diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 1cf629e7ec..956e0f9dca 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -381,6 +381,9 @@ struct domain struct page_list_head page_list; /* linked list */ struct page_list_head extra_page_list; /* linked list (size extra_pages) */ struct page_list_head xenpage_list; /* linked list (size xenheap_pages) */ +#ifdef CONFIG_STATIC_MEMORY + struct page_list_head resv_page_list; /* linked list */ +#endif /* * This field should only be directly accessed by domain_adjust_tot_pages() From patchwork Wed Aug 31 02:40:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Penny Zheng X-Patchwork-Id: 12960267 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9F123C54EE9 for ; Wed, 31 Aug 2022 02:41:23 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.395296.634887 (Exim 4.92) (envelope-from ) id 1oTDfH-00070S-AB; Wed, 31 Aug 2022 02:41:15 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 395296.634887; Wed, 31 Aug 2022 02:41:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oTDfH-00070L-5Z; Wed, 31 Aug 2022 02:41:15 +0000 Received: by outflank-mailman (input) for mailman id 395296; Wed, 31 Aug 2022 02:41:14 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oTDfF-0005n7-Ti for xen-devel@lists.xenproject.org; Wed, 31 Aug 2022 02:41:14 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id 608aaf66-28d6-11ed-a60c-1f1ba7de4fb0; Wed, 31 Aug 2022 04:41:12 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 54D61ED1; Tue, 30 Aug 2022 19:41:18 -0700 (PDT) Received: from a011292.shanghai.arm.com (a011292.shanghai.arm.com [10.169.190.94]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id CDDE73F71A; Tue, 30 Aug 2022 19:41:08 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 608aaf66-28d6-11ed-a60c-1f1ba7de4fb0 From: Penny Zheng To: xen-devel@lists.xenproject.org Cc: wei.chen@arm.com, Penny Zheng , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Penny Zheng , Julien Grall Subject: [PATCH v11 4/6] xen: introduce prepare_staticmem_pages Date: Wed, 31 Aug 2022 10:40:39 +0800 Message-Id: <20220831024041.468757-5-Penny.Zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220831024041.468757-1-Penny.Zheng@arm.com> References: <20220831024041.468757-1-Penny.Zheng@arm.com> MIME-Version: 1.0 Later, we want to use acquire_domstatic_pages() for populating memory for static domain on runtime, however, there are a lot of pointless work (checking mfn_valid(), scrubbing the free part, cleaning the cache...) considering we know the page is valid and belong to the guest. This commit splits acquire_staticmem_pages() in two parts, and introduces prepare_staticmem_pages to bypass all "pointless work". Signed-off-by: Penny Zheng Acked-by: Jan Beulich Acked-by: Julien Grall --- v11 changes: - no change --- v10 changes: - no change --- v9 changes: - no change --- v8 changes: - no change --- v7 changes: - no change --- v6 changes: - adapt to PGC_static --- v5 changes: - new commit --- xen/common/page_alloc.c | 61 ++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 26a2fad4e3..adcc16e4f6 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -2752,26 +2752,13 @@ void free_domstatic_page(struct page_info *page) put_domain(d); } -/* - * Acquire nr_mfns contiguous reserved pages, starting at #smfn, of - * static memory. - * This function needs to be reworked if used outside of boot. - */ -static struct page_info * __init acquire_staticmem_pages(mfn_t smfn, - unsigned long nr_mfns, - unsigned int memflags) +static bool __init prepare_staticmem_pages(struct page_info *pg, + unsigned long nr_mfns, + unsigned int memflags) { bool need_tlbflush = false; uint32_t tlbflush_timestamp = 0; unsigned long i; - struct page_info *pg; - - ASSERT(nr_mfns); - for ( i = 0; i < nr_mfns; i++ ) - if ( !mfn_valid(mfn_add(smfn, i)) ) - return NULL; - - pg = mfn_to_page(smfn); spin_lock(&heap_lock); @@ -2782,7 +2769,7 @@ static struct page_info * __init acquire_staticmem_pages(mfn_t smfn, { printk(XENLOG_ERR "pg[%lu] Static MFN %"PRI_mfn" c=%#lx t=%#x\n", - i, mfn_x(smfn) + i, + i, mfn_x(page_to_mfn(pg)) + i, pg[i].count_info, pg[i].tlbflush_timestamp); goto out_err; } @@ -2806,6 +2793,38 @@ static struct page_info * __init acquire_staticmem_pages(mfn_t smfn, if ( need_tlbflush ) filtered_flush_tlb_mask(tlbflush_timestamp); + return true; + + out_err: + while ( i-- ) + pg[i].count_info = PGC_static | PGC_state_free; + + spin_unlock(&heap_lock); + + return false; +} + +/* + * Acquire nr_mfns contiguous reserved pages, starting at #smfn, of + * static memory. + * This function needs to be reworked if used outside of boot. + */ +static struct page_info * __init acquire_staticmem_pages(mfn_t smfn, + unsigned long nr_mfns, + unsigned int memflags) +{ + unsigned long i; + struct page_info *pg; + + ASSERT(nr_mfns); + for ( i = 0; i < nr_mfns; i++ ) + if ( !mfn_valid(mfn_add(smfn, i)) ) + return NULL; + + pg = mfn_to_page(smfn); + if ( !prepare_staticmem_pages(pg, nr_mfns, memflags) ) + return NULL; + /* * Ensure cache and RAM are consistent for platforms where the guest * can control its own visibility of/through the cache. @@ -2814,14 +2833,6 @@ static struct page_info * __init acquire_staticmem_pages(mfn_t smfn, flush_page_to_ram(mfn_x(smfn) + i, !(memflags & MEMF_no_icache_flush)); return pg; - - out_err: - while ( i-- ) - pg[i].count_info = PGC_static | PGC_state_free; - - spin_unlock(&heap_lock); - - return NULL; } /* From patchwork Wed Aug 31 02:40:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Penny Zheng X-Patchwork-Id: 12960270 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BF97EECAAD5 for ; Wed, 31 Aug 2022 02:41:26 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.395299.634898 (Exim 4.92) (envelope-from ) id 1oTDfL-0007Oj-Hr; Wed, 31 Aug 2022 02:41:19 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 395299.634898; Wed, 31 Aug 2022 02:41:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oTDfL-0007Oc-Ee; Wed, 31 Aug 2022 02:41:19 +0000 Received: by outflank-mailman (input) for mailman id 395299; Wed, 31 Aug 2022 02:41:18 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oTDfJ-0005n7-VE for xen-devel@lists.xenproject.org; Wed, 31 Aug 2022 02:41:18 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id 62fce17d-28d6-11ed-a60c-1f1ba7de4fb0; Wed, 31 Aug 2022 04:41:17 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 74A2BED1; Tue, 30 Aug 2022 19:41:22 -0700 (PDT) Received: from a011292.shanghai.arm.com (a011292.shanghai.arm.com [10.169.190.94]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id AF2A43F71A; Tue, 30 Aug 2022 19:41:12 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 62fce17d-28d6-11ed-a60c-1f1ba7de4fb0 From: Penny Zheng To: xen-devel@lists.xenproject.org Cc: wei.chen@arm.com, Penny Zheng , Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk , Andrew Cooper , George Dunlap , Jan Beulich , Wei Liu , Penny Zheng Subject: [PATCH v11 5/6] xen: rename free_staticmem_pages to unprepare_staticmem_pages Date: Wed, 31 Aug 2022 10:40:40 +0800 Message-Id: <20220831024041.468757-6-Penny.Zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220831024041.468757-1-Penny.Zheng@arm.com> References: <20220831024041.468757-1-Penny.Zheng@arm.com> MIME-Version: 1.0 The name of free_staticmem_pages is inappropriate, considering it is the opposite of function prepare_staticmem_pages. Rename free_staticmem_pages to unprepare_staticmem_pages. Signed-off-by: Penny Zheng Acked-by: Jan Beulich Reviewed-by: Julien Grall --- v11 changes: - moved ahead of "xen: retrieve reserved pages on populate_physmap" --- v10 changes: - new commit --- xen/arch/arm/setup.c | 3 ++- xen/common/page_alloc.c | 13 ++++++++----- xen/include/xen/mm.h | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 500307edc0..4662997c7e 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -639,7 +639,8 @@ static void __init init_staticmem_pages(void) if ( mfn_x(bank_end) <= mfn_x(bank_start) ) return; - free_staticmem_pages(mfn_to_page(bank_start), bank_pages, false); + unprepare_staticmem_pages(mfn_to_page(bank_start), + bank_pages, false); } } #endif diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index adcc16e4f6..18d34d1b69 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -2693,9 +2693,12 @@ struct domain *get_pg_owner(domid_t domid) } #ifdef CONFIG_STATIC_MEMORY -/* Equivalent of free_heap_pages to free nr_mfns pages of static memory. */ -void free_staticmem_pages(struct page_info *pg, unsigned long nr_mfns, - bool need_scrub) +/* + * It is the opposite of prepare_staticmem_pages, and it aims to unprepare + * nr_mfns pages of static memory. + */ +void unprepare_staticmem_pages(struct page_info *pg, unsigned long nr_mfns, + bool need_scrub) { mfn_t mfn = page_to_mfn(pg); unsigned long i; @@ -2741,7 +2744,7 @@ void free_domstatic_page(struct page_info *page) drop_dom_ref = !domain_adjust_tot_pages(d, -1); - free_staticmem_pages(page, 1, scrub_debug); + unprepare_staticmem_pages(page, 1, scrub_debug); /* Add page on the resv_page_list *after* it has been freed. */ page_list_add_tail(page, &d->resv_page_list); @@ -2862,7 +2865,7 @@ int __init acquire_domstatic_pages(struct domain *d, mfn_t smfn, if ( assign_pages(pg, nr_mfns, d, memflags) ) { - free_staticmem_pages(pg, nr_mfns, memflags & MEMF_no_scrub); + unprepare_staticmem_pages(pg, nr_mfns, memflags & MEMF_no_scrub); return -EINVAL; } diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index deadf4b2a1..93db3c4418 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -86,8 +86,8 @@ bool scrub_free_pages(void); #define FREE_XENHEAP_PAGE(p) FREE_XENHEAP_PAGES(p, 0) /* These functions are for static memory */ -void free_staticmem_pages(struct page_info *pg, unsigned long nr_mfns, - bool need_scrub); +void unprepare_staticmem_pages(struct page_info *pg, unsigned long nr_mfns, + bool need_scrub); void free_domstatic_page(struct page_info *page); int acquire_domstatic_pages(struct domain *d, mfn_t smfn, unsigned int nr_mfns, unsigned int memflags); From patchwork Wed Aug 31 02:40:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Penny Zheng X-Patchwork-Id: 12960271 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E7D99ECAAA1 for ; Wed, 31 Aug 2022 02:41:32 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.395307.634909 (Exim 4.92) (envelope-from ) id 1oTDfQ-000816-U2; Wed, 31 Aug 2022 02:41:24 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 395307.634909; Wed, 31 Aug 2022 02:41:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oTDfQ-00080t-Pm; Wed, 31 Aug 2022 02:41:24 +0000 Received: by outflank-mailman (input) for mailman id 395307; Wed, 31 Aug 2022 02:41:23 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oTDfP-0005n7-5t for xen-devel@lists.xenproject.org; Wed, 31 Aug 2022 02:41:23 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id 6529e53a-28d6-11ed-a60c-1f1ba7de4fb0; Wed, 31 Aug 2022 04:41:20 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 177F2ED1; Tue, 30 Aug 2022 19:41:26 -0700 (PDT) Received: from a011292.shanghai.arm.com (a011292.shanghai.arm.com [10.169.190.94]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id CF0A93F71A; Tue, 30 Aug 2022 19:41:16 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 6529e53a-28d6-11ed-a60c-1f1ba7de4fb0 From: Penny Zheng To: xen-devel@lists.xenproject.org Cc: wei.chen@arm.com, Penny Zheng , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Penny Zheng Subject: [PATCH v11 6/6] xen: retrieve reserved pages on populate_physmap Date: Wed, 31 Aug 2022 10:40:41 +0800 Message-Id: <20220831024041.468757-7-Penny.Zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220831024041.468757-1-Penny.Zheng@arm.com> References: <20220831024041.468757-1-Penny.Zheng@arm.com> MIME-Version: 1.0 When a static domain populates memory through populate_physmap at runtime, it shall retrieve reserved pages from resv_page_list to make sure that guest RAM is still restricted in statically configured memory regions. This commit also introduces a new helper acquire_reserved_page to make it work. Signed-off-by: Penny Zheng --- v11 change: - with assignment having failed and the page not exposed to the guest at any point, there is no need for scrubbing --- v10 changes: - add lock on the fail path --- v9 changes: - Use ASSERT_ALLOC_CONTEXT() in acquire_reserved_page - Add free_staticmem_pages to undo prepare_staticmem_pages when assign_domstatic_pages - Remove redundant static in error message --- v8 changes: - As concurrent free/allocate could modify the resv_page_list, we still need the lock --- v7 changes: - remove the lock, since we add the page to rsv_page_list after it has been totally freed. --- v6 changes: - drop the lock before returning --- v5 changes: - extract common codes for assigning pages into a helper assign_domstatic_pages - refine commit message - remove stub function acquire_reserved_page - Alloc/free of memory can happen concurrently. So access to rsv_page_list needs to be protected with a spinlock --- v4 changes: - miss dropping __init in acquire_domstatic_pages - add the page back to the reserved list in case of error - remove redundant printk - refine log message and make it warn level --- v3 changes: - move is_domain_using_staticmem to the common header file - remove #ifdef CONFIG_STATIC_MEMORY-ary - remove meaningless page_to_mfn(page) in error log --- v2 changes: - introduce acquire_reserved_page to retrieve reserved pages from resv_page_list - forbid non-zero-order requests in populate_physmap - let is_domain_static return ((void)(d), false) on x86 --- xen/common/memory.c | 23 +++++++++++++ xen/common/page_alloc.c | 76 ++++++++++++++++++++++++++++++++--------- xen/include/xen/mm.h | 1 + 3 files changed, 83 insertions(+), 17 deletions(-) diff --git a/xen/common/memory.c b/xen/common/memory.c index bc89442ba5..ae8163a738 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -245,6 +245,29 @@ static void populate_physmap(struct memop_args *a) mfn = _mfn(gpfn); } + else if ( is_domain_using_staticmem(d) ) + { + /* + * No easy way to guarantee the retrieved pages are contiguous, + * so forbid non-zero-order requests here. + */ + if ( a->extent_order != 0 ) + { + gdprintk(XENLOG_WARNING, + "Cannot allocate static order-%u pages for %pd\n", + a->extent_order, d); + goto out; + } + + mfn = acquire_reserved_page(d, a->memflags); + if ( mfn_eq(mfn, INVALID_MFN) ) + { + gdprintk(XENLOG_WARNING, + "%pd: failed to retrieve a reserved page\n", + d); + goto out; + } + } else { page = alloc_domheap_pages(d, a->extent_order, a->memflags); diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 18d34d1b69..93d504c3c4 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -2755,9 +2755,8 @@ void free_domstatic_page(struct page_info *page) put_domain(d); } -static bool __init prepare_staticmem_pages(struct page_info *pg, - unsigned long nr_mfns, - unsigned int memflags) +static bool prepare_staticmem_pages(struct page_info *pg, unsigned long nr_mfns, + unsigned int memflags) { bool need_tlbflush = false; uint32_t tlbflush_timestamp = 0; @@ -2838,21 +2837,9 @@ static struct page_info * __init acquire_staticmem_pages(mfn_t smfn, return pg; } -/* - * Acquire nr_mfns contiguous pages, starting at #smfn, of static memory, - * then assign them to one specific domain #d. - */ -int __init acquire_domstatic_pages(struct domain *d, mfn_t smfn, - unsigned int nr_mfns, unsigned int memflags) +static int assign_domstatic_pages(struct domain *d, struct page_info *pg, + unsigned int nr_mfns, unsigned int memflags) { - struct page_info *pg; - - ASSERT_ALLOC_CONTEXT(); - - pg = acquire_staticmem_pages(smfn, nr_mfns, memflags); - if ( !pg ) - return -ENOENT; - if ( !d || (memflags & (MEMF_no_owner | MEMF_no_refcount)) ) { /* @@ -2871,6 +2858,61 @@ int __init acquire_domstatic_pages(struct domain *d, mfn_t smfn, return 0; } + +/* + * Acquire nr_mfns contiguous pages, starting at #smfn, of static memory, + * then assign them to one specific domain #d. + */ +int __init acquire_domstatic_pages(struct domain *d, mfn_t smfn, + unsigned int nr_mfns, unsigned int memflags) +{ + struct page_info *pg; + + ASSERT_ALLOC_CONTEXT(); + + pg = acquire_staticmem_pages(smfn, nr_mfns, memflags); + if ( !pg ) + return -ENOENT; + + if ( assign_domstatic_pages(d, pg, nr_mfns, memflags) ) + return -EINVAL; + + return 0; +} + +/* + * Acquire a page from reserved page list(resv_page_list), when populating + * memory for static domain on runtime. + */ +mfn_t acquire_reserved_page(struct domain *d, unsigned int memflags) +{ + struct page_info *page; + + ASSERT_ALLOC_CONTEXT(); + + /* Acquire a page from reserved page list(resv_page_list). */ + spin_lock(&d->page_alloc_lock); + page = page_list_remove_head(&d->resv_page_list); + spin_unlock(&d->page_alloc_lock); + if ( unlikely(!page) ) + return INVALID_MFN; + + if ( !prepare_staticmem_pages(page, 1, memflags) ) + goto fail; + + if ( assign_domstatic_pages(d, page, 1, memflags) ) + goto fail_assign; + + return page_to_mfn(page); + + fail_assign: + unprepare_staticmem_pages(page, 1, false); + fail: + spin_lock(&d->page_alloc_lock); + page_list_add_tail(page, &d->resv_page_list); + spin_unlock(&d->page_alloc_lock); + return INVALID_MFN; +} #endif /* diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index 93db3c4418..a925028ab3 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -198,6 +198,7 @@ struct npfec { #else #define MAX_ORDER 20 /* 2^20 contiguous pages */ #endif +mfn_t acquire_reserved_page(struct domain *d, unsigned int memflags); /* Private domain structs for DOMID_XEN, DOMID_IO, etc. */ extern struct domain *dom_xen, *dom_io;