From nobody Thu Apr 25 02:24:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1584552940; cv=none; d=zohomail.com; s=zohoarc; b=b2ts70BHGlCxY9ZcX+XnMhJ2sX7683wnq8amPUpD2kYx8AvdNtrx2lknObUkWNEAPIfo5lp6xZTJwLm4U22iCJ0kg+44O0z2nmrHsNSI0bz49IjUtqtYsnNcptw2S9wBcsqHFPDHbPzWZAF6svFxAOPsbcPNR7+AWs52YlibMNE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584552940; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=m/ZjYcqbXKjNQHdppl3viEpM/CaGKVbK8Db8xA4SMt0=; b=M201SyiAXIWfoYgPw9vbxh0NYfinNuAXj0kbXtN+YqBjDJo7MyQLWgT79Ry3ieaokRzCPpItIlZJkPjXurghuxYg9Lm38RtkiaX801XLdpp4FFbJNq9gY5Eel3yQRXwOES7E1wp40E1r0XYo+foyEOXB6eOmgWu0gJO6vd8jxlA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1584552940736578.2090097681186; Wed, 18 Mar 2020 10:35:40 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jEcYq-0006Rt-S9; Wed, 18 Mar 2020 17:32:56 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jEcYp-0006Rn-AJ for xen-devel@lists.xenproject.org; Wed, 18 Mar 2020 17:32:55 +0000 Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 7d5027c2-693e-11ea-a6c1-bc764e2007e4; Wed, 18 Mar 2020 17:32:50 +0000 (UTC) Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jEcYj-0005U5-9o; Wed, 18 Mar 2020 17:32:49 +0000 Received: from 54-240-197-232.amazon.com ([54.240.197.232] helo=u2f063a87eabd5f.cbg10.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1jEcYj-0007B3-0F; Wed, 18 Mar 2020 17:32:49 +0000 X-Inumbo-ID: 7d5027c2-693e-11ea-a6c1-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=YLLsGkjP4tF/WD6q6mbIXn9yrxko9P1svCXUoA5+hZE=; b=Ffb1syo9zGhD03DXMHBiR9c6gb cZKF2fDaRkW8JXmgycd9b4Xw2cEAabUcYmtay+tDaPv4vbh0A+Twujn6gVRWHssuMk7eK+mELB+ba 2mb9pxfwDVsefLTREHfTIFDx3XWWnpJIcH/S7XTbjAzc5LYW0j/gpb58iv1kZg+NT9K8=; From: Paul Durrant To: xen-devel@lists.xenproject.org Date: Wed, 18 Mar 2020 17:32:41 +0000 Message-Id: <20200318173243.29183-2-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200318173243.29183-1-paul@xen.org> References: <20200318173243.29183-1-paul@xen.org> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v4 1/3] mm: keep PGC_extra pages on a separate list X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Julien Grall , Wei Liu , Paul Durrant , Andrew Cooper , Ian Jackson , George Dunlap , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This patch adds a new page_list_head into struct domain to hold PGC_extra pages. This avoids them getting confused with 'normal' domheap pages where the domain's page_list is walked. A new dump loop is also added to dump_pageframe_info() to unconditionally dump the 'extra page list'. Signed-off-by: Paul Durrant Reviewed-by: Jan Beulich Acked-by: Julien Grall --- Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Julien Grall Cc: Stefano Stabellini Cc: Wei Liu Cc: "Roger Pau Monn=C3=A9" v7: - Cosmetic changes v6: - New in v6 --- xen/arch/x86/domain.c | 9 +++++++++ xen/common/domain.c | 1 + xen/common/page_alloc.c | 2 +- xen/include/asm-x86/mm.h | 6 ++---- xen/include/xen/mm.h | 5 ++--- xen/include/xen/sched.h | 13 +++++++++++++ 6 files changed, 28 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index caf2ecad7e..683bc619aa 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -251,12 +251,21 @@ void dump_pageframe_info(struct domain *d) p2m_pod_dump_data(d); =20 spin_lock(&d->page_alloc_lock); + page_list_for_each ( page, &d->xenpage_list ) { printk(" XenPage %p: caf=3D%08lx, taf=3D%" PRtype_info "\n", _p(mfn_x(page_to_mfn(page))), page->count_info, page->u.inuse.type_info); } + + page_list_for_each ( page, &d->extra_page_list ) + { + printk(" ExtraPage %p: caf=3D%08lx, taf=3D%" PRtype_info "\n", + _p(mfn_x(page_to_mfn(page))), + page->count_info, page->u.inuse.type_info); + } + spin_unlock(&d->page_alloc_lock); } =20 diff --git a/xen/common/domain.c b/xen/common/domain.c index b4eb476a9c..3dcd73f67c 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -403,6 +403,7 @@ struct domain *domain_create(domid_t domid, spin_lock_init_prof(d, page_alloc_lock); spin_lock_init(&d->hypercall_deadlock_mutex); INIT_PAGE_LIST_HEAD(&d->page_list); + INIT_PAGE_LIST_HEAD(&d->extra_page_list); INIT_PAGE_LIST_HEAD(&d->xenpage_list); =20 spin_lock_init(&d->node_affinity_lock); diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 76d37226df..10b7aeca48 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -2314,7 +2314,7 @@ int assign_pages( smp_wmb(); /* Domain pointer must be visible before updating refcn= t. */ pg[i].count_info =3D (pg[i].count_info & PGC_extra) | PGC_allocated | 1; - page_list_add_tail(&pg[i], &d->page_list); + page_list_add_tail(&pg[i], page_to_list(d, &pg[i])); } =20 out: diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h index a06b2fb81f..1fa334b306 100644 --- a/xen/include/asm-x86/mm.h +++ b/xen/include/asm-x86/mm.h @@ -629,10 +629,8 @@ typedef struct mm_rwlock { const char *locker_function; /* func that took it */ } mm_rwlock_t; =20 -#define arch_free_heap_page(d, pg) \ - page_list_del2(pg, is_xen_heap_page(pg) ? \ - &(d)->xenpage_list : &(d)->page_list, \ - &(d)->arch.relmem_list) +#define arch_free_heap_page(d, pg) \ + page_list_del2(pg, page_to_list(d, pg), &(d)->arch.relmem_list) =20 extern const char zero_page[]; =20 diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index d0d095d9c7..a163c201e2 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -583,9 +583,8 @@ static inline unsigned int get_order_from_pages(unsigne= d long nr_pages) void scrub_one_page(struct page_info *); =20 #ifndef arch_free_heap_page -#define arch_free_heap_page(d, pg) \ - page_list_del(pg, is_xen_heap_page(pg) ? \ - &(d)->xenpage_list : &(d)->page_list) +#define arch_free_heap_page(d, pg) \ + page_list_del(pg, page_to_list(d, pg)) #endif =20 int xenmem_add_to_physmap_one(struct domain *d, unsigned int space, diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index e6813288ab..4b78291d51 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -329,6 +329,7 @@ struct domain =20 spinlock_t page_alloc_lock; /* protects all the following fields= */ struct page_list_head page_list; /* linked list */ + struct page_list_head extra_page_list; /* linked list (size extra_page= s) */ struct page_list_head xenpage_list; /* linked list (size xenheap_pages= ) */ =20 /* @@ -512,6 +513,18 @@ struct domain #endif }; =20 +static inline struct page_list_head *page_to_list( + struct domain *d, const struct page_info *pg) +{ + if ( is_xen_heap_page(pg) ) + return &d->xenpage_list; + + if ( pg->count_info & PGC_extra ) + return &d->extra_page_list; + + return &d->page_list; +} + /* Return number of pages currently posessed by the domain */ static inline unsigned int domain_tot_pages(const struct domain *d) { --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu Apr 25 02:24:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1584552923; cv=none; d=zohomail.com; s=zohoarc; b=f9bWmmv2hgC5SpzUU5dzJfrEgZ6lIcSzJst1cVpTM6P4evcgykog5oD7fVptV0ceIjZilthC9ameIVNA/LS1ZIj03BlTaCjzDo5od2u+GUGbKrK8Bnk/PgrR9ZiHZ2SiMEkDqlNIj+W6Tpl2wHLCrwkqWRIs4115/FI+qhZ+H6U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584552923; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OMX9KhIFAVHdRfRT0wT6LR2HHm8oenJ+VQChNGzI+pw=; b=DcagPEDGICNZP9Cm6nSnTWaC8adyCs9RUQSKCNx49TSnkS2Skts9sK9yCRz84KDvk0URoonKu68LO4dol9yYVrnf1TbO7SorKV/e2A5aeuooo3YrY3CaA2dlGr2WtxQqXub3KNKi/RG3Plk4HKGNnLAAZuN56NfF3jgQOE40fR8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1584552923154377.259305220353; Wed, 18 Mar 2020 10:35:23 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jEcYn-0006Rc-JU; Wed, 18 Mar 2020 17:32:53 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jEcYm-0006RX-SK for xen-devel@lists.xenproject.org; Wed, 18 Mar 2020 17:32:52 +0000 Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 7e1cb080-693e-11ea-bb3a-12813bfff9fa; Wed, 18 Mar 2020 17:32:51 +0000 (UTC) Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jEcYk-0005UC-In; Wed, 18 Mar 2020 17:32:50 +0000 Received: from 54-240-197-232.amazon.com ([54.240.197.232] helo=u2f063a87eabd5f.cbg10.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1jEcYk-0007B3-9d; Wed, 18 Mar 2020 17:32:50 +0000 X-Inumbo-ID: 7e1cb080-693e-11ea-bb3a-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=1R8tZJcYN4tYZnqAnW3BaOpJQtbMY/9yYaflzyTYuJE=; b=dtNQy8TxkeFh+7l8jHLk3WBSsM LpOWWbel6YloxsMfvEuiWcAdk0htrSbL8gOQF6jitSP+hCJf7K3MK+xL/XCw5WF8ssTeH9Vg++rTZ qDDd19EZItmZQMdMsQc8KDs24xIG3oVbX45MhUt5tSDzrb9TxxQugbZ2DbTWknc2jR/c=; From: Paul Durrant To: xen-devel@lists.xenproject.org Date: Wed, 18 Mar 2020 17:32:42 +0000 Message-Id: <20200318173243.29183-3-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200318173243.29183-1-paul@xen.org> References: <20200318173243.29183-1-paul@xen.org> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v4 2/3] x86 / ioreq: use a MEMF_no_refcount allocation for server pages... X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , Paul Durrant , Andrew Cooper , Paul Durrant , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Paul Durrant ... now that it is safe to assign them. This avoids relying on libxl (or whatever toolstack is in use) setting max_pages up with sufficient 'slop' to allow all necessary ioreq server pages to be allocated. Signed-off-by: Paul Durrant Reviewed-by: Jan Beulich --- Cc: Andrew Cooper Cc: Wei Liu Cc: "Roger Pau Monn=C3=A9" v2: - New in v2 --- xen/arch/x86/hvm/ioreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/x86/hvm/ioreq.c b/xen/arch/x86/hvm/ioreq.c index 36fbbcf0ea..70e61788d7 100644 --- a/xen/arch/x86/hvm/ioreq.c +++ b/xen/arch/x86/hvm/ioreq.c @@ -376,7 +376,7 @@ static int hvm_alloc_ioreq_mfn(struct hvm_ioreq_server = *s, bool buf) return 0; } =20 - page =3D alloc_domheap_page(s->target, 0); + page =3D alloc_domheap_page(s->target, MEMF_no_refcount); =20 if ( !page ) return -ENOMEM; --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu Apr 25 02:24:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1584552856; cv=none; d=zohomail.com; s=zohoarc; b=SxDr1nD8/z8FI5qu3Gc9l7hCTacM7SVVQg7RC92HQFZMgNEKJ7ekzxlkQ4ugIqIBMFCQMb583JREUPlOfbSag3fCbRb94D+xpH0Ov92ZhknXTwZcimrC2OcoLeBVpzhoRkYg6+KlVgjB8AYJmBnJ3pXk3WaHn7lqWald6W5hiUs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584552856; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xJnGRsDvPcbzwUEnHdQX2x/8jg5Y9Ek3VGLO5DpzHL4=; b=a36MiYVt0ZtCPyIWbXczq810UCEWuthKhDABer2oyfoGYzNLZuhx0uPYQMpEhYxUKeXmg2dC60TSQMyffUzi5SFbzmadWdYUJ1XmqM6HpJIpaLgTJswWr+9N6G8OYdjarhXBntN1NaGjhXcdE5yN3XdXU6iYuHCuyqls9+0Xs7Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1584552856741978.1496144590444; Wed, 18 Mar 2020 10:34:16 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jEcYt-0006St-5K; Wed, 18 Mar 2020 17:32:59 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jEcYr-0006S4-Nq for xen-devel@lists.xenproject.org; Wed, 18 Mar 2020 17:32:57 +0000 Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 8000c3c8-693e-11ea-bb3a-12813bfff9fa; Wed, 18 Mar 2020 17:32:54 +0000 (UTC) Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jEcYm-0005UL-QH; Wed, 18 Mar 2020 17:32:52 +0000 Received: from 54-240-197-232.amazon.com ([54.240.197.232] helo=u2f063a87eabd5f.cbg10.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1jEcYm-0007B3-DB; Wed, 18 Mar 2020 17:32:52 +0000 X-Inumbo-ID: 8000c3c8-693e-11ea-bb3a-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=y6kty7dqS5pUZuLyfvCfmuZ/hu6jH8Nr3+pSYYCvBKw=; b=PVeliIT7PMUNQd7dI2WOtFXJ2+ /7vANj2+vHU/OPc4HP4G/C4d4wFrjAqdzpbi0xXPUiitp9sErb9dSO+YS9pywcKjoyn6HV7eh9Vb9 ioFw69bFmslIvEdTThJ4QtIIq57o7u0txL6zxShiIMxujzge9Ut8HyUQ6ZACObeg7bLQ=; From: Paul Durrant To: xen-devel@lists.xenproject.org Date: Wed, 18 Mar 2020 17:32:43 +0000 Message-Id: <20200318173243.29183-4-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200318173243.29183-1-paul@xen.org> References: <20200318173243.29183-1-paul@xen.org> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v4 3/3] mm: add 'is_special_page' inline function... X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Tamas K Lengyel , Julien Grall , Wei Liu , Paul Durrant , Andrew Cooper , Paul Durrant , Konrad Rzeszutek Wilk , Ian Jackson , George Dunlap , Tim Deegan , Stefano Stabellini , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Paul Durrant ... to cover xenheap and PGC_extra pages. PGC_extra pages are intended to hold data structures that are associated with a domain and may be mapped by that domain. They should not be treated as 'normal' guest pages (i.e. RAM or page tables). Hence, in many cases where code currently tests is_xen_heap_page() it should also check for the PGC_extra bit in 'count_info'. This patch therefore defines is_special_page() to cover both cases and converts tests of is_xen_heap_page() (or open coded tests of PGC_xen_heap) to is_special_page() where the page is assigned to a domain. Signed-off-by: Paul Durrant Acked-by: Tamas K Lengyel Acked-by: Julien Grall Reviewed-by: Jan Beulich --- Cc: Jan Beulich Cc: Andrew Cooper Cc: Wei Liu Cc: "Roger Pau Monn=C3=A9" Cc: George Dunlap Cc: Ian Jackson Cc: Julien Grall Cc: Konrad Rzeszutek Wilk Cc: Stefano Stabellini Cc: Tim Deegan v7: - Fixed some uses of is_xen_heap_mfn() that I'd missed - Updated commit comment to point out that only tests on assigned xenheap pages are candidates for conversion v6: - Convert open-coded checks of PGC_xen_heap to use is_special_page() where appropriate v4: - Use inline function instead of macro - Add missing conversions from is_xen_heap_page() v3: - Delete obsolete comment. v2: - New in v2 --- xen/arch/x86/domctl.c | 2 +- xen/arch/x86/mm.c | 13 ++++++------- xen/arch/x86/mm/altp2m.c | 2 +- xen/arch/x86/mm/mem_sharing.c | 3 +-- xen/arch/x86/mm/p2m-pod.c | 12 +++++++----- xen/arch/x86/mm/p2m.c | 4 ++-- xen/arch/x86/mm/shadow/common.c | 13 ++++++++----- xen/arch/x86/mm/shadow/multi.c | 3 ++- xen/arch/x86/tboot.c | 4 ++-- xen/include/xen/mm.h | 5 +++++ 10 files changed, 35 insertions(+), 26 deletions(-) diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c index ed86762fa6..add70126b9 100644 --- a/xen/arch/x86/domctl.c +++ b/xen/arch/x86/domctl.c @@ -394,7 +394,7 @@ long arch_do_domctl( page =3D get_page_from_gfn(d, gfn, &t, P2M_ALLOC); =20 if ( unlikely(!page) || - unlikely(is_xen_heap_page(page)) ) + unlikely(is_special_page(page)) ) { if ( unlikely(p2m_is_broken(t)) ) type =3D XEN_DOMCTL_PFINFO_BROKEN; diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 62507ca651..2fac67ad57 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -1014,7 +1014,7 @@ get_page_from_l1e( unsigned long cacheattr =3D pte_flags_to_cacheattr(l1f); int err; =20 - if ( is_xen_heap_page(page) ) + if ( is_special_page(page) ) { if ( write ) put_page_type(page); @@ -2447,7 +2447,7 @@ static int cleanup_page_mappings(struct page_info *pa= ge) { page->count_info &=3D ~PGC_cacheattr_mask; =20 - BUG_ON(is_xen_heap_page(page)); + BUG_ON(is_special_page(page)); =20 rc =3D update_xen_mappings(mfn, 0); } @@ -2477,7 +2477,7 @@ static int cleanup_page_mappings(struct page_info *pa= ge) rc =3D rc2; } =20 - if ( likely(!is_xen_heap_page(page)) ) + if ( likely(!is_special_page(page)) ) { ASSERT((page->u.inuse.type_info & (PGT_type_mask | PGT_count_mask)) =3D=3D PGT_writable_= page); @@ -4216,8 +4216,7 @@ int steal_page( if ( !(owner =3D page_get_owner_and_reference(page)) ) goto fail; =20 - if ( owner !=3D d || is_xen_heap_page(page) || - (page->count_info & PGC_extra) ) + if ( owner !=3D d || is_special_page(page) ) goto fail_put; =20 /* @@ -4580,8 +4579,8 @@ int xenmem_add_to_physmap_one( prev_mfn =3D get_gfn(d, gfn_x(gpfn), &p2mt); if ( mfn_valid(prev_mfn) ) { - if ( is_xen_heap_mfn(prev_mfn) ) - /* Xen heap frames are simply unhooked from this phys slot. */ + if ( is_special_page(mfn_to_page(prev_mfn)) ) + /* Special pages are simply unhooked from this phys slot. */ rc =3D guest_physmap_remove_page(d, gpfn, prev_mfn, PAGE_ORDER= _4K); else /* Normal domain memory is freed, to avoid leaking memory. */ diff --git a/xen/arch/x86/mm/altp2m.c b/xen/arch/x86/mm/altp2m.c index 50768f2547..c091b03ea3 100644 --- a/xen/arch/x86/mm/altp2m.c +++ b/xen/arch/x86/mm/altp2m.c @@ -77,7 +77,7 @@ int altp2m_vcpu_enable_ve(struct vcpu *v, gfn_t gfn) * pageable() predicate for this, due to it having the same properties * that we want. */ - if ( !p2m_is_pageable(p2mt) || is_xen_heap_page(pg) ) + if ( !p2m_is_pageable(p2mt) || is_special_page(pg) ) { rc =3D -EINVAL; goto err; diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c index 3835bc928f..f49f27a3ef 100644 --- a/xen/arch/x86/mm/mem_sharing.c +++ b/xen/arch/x86/mm/mem_sharing.c @@ -840,9 +840,8 @@ static int nominate_page(struct domain *d, gfn_t gfn, if ( !p2m_is_sharable(p2mt) ) goto out; =20 - /* Skip xen heap pages */ page =3D mfn_to_page(mfn); - if ( !page || is_xen_heap_page(page) ) + if ( !page || is_special_page(page) ) goto out; =20 /* Check if there are mem_access/remapped altp2m entries for this page= */ diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c index 2a7b8c117b..36bc471e7f 100644 --- a/xen/arch/x86/mm/p2m-pod.c +++ b/xen/arch/x86/mm/p2m-pod.c @@ -749,8 +749,9 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, gf= n_t gfn) =20 n =3D 1UL << min(cur_order, SUPERPAGE_ORDER + 0U); for ( k =3D 0, page =3D mfn_to_page(mfn); k < n; ++k, ++page ) - if ( !(page->count_info & PGC_allocated) || - (page->count_info & (PGC_page_table | PGC_xen_heap)) || + if ( is_special_page(page) || + !(page->count_info & PGC_allocated) || + (page->count_info & PGC_page_table) || (page->count_info & PGC_count_mask) > max_ref ) goto out; } @@ -883,11 +884,12 @@ p2m_pod_zero_check(struct p2m_domain *p2m, const gfn_= t *gfns, unsigned int count pg =3D mfn_to_page(mfns[i]); =20 /* - * If this is ram, and not a pagetable or from the xen heap, and + * If this is ram, and not a pagetable or a special page, and * probably not mapped elsewhere, map it; otherwise, skip. */ - if ( p2m_is_ram(types[i]) && (pg->count_info & PGC_allocated) && - !(pg->count_info & (PGC_page_table | PGC_xen_heap)) && + if ( !is_special_page(pg) && p2m_is_ram(types[i]) && + (pg->count_info & PGC_allocated) && + !(pg->count_info & PGC_page_table) && ((pg->count_info & PGC_count_mask) <=3D max_ref) ) map[i] =3D map_domain_page(mfns[i]); else diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index 9f51370327..d93c418bcf 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -2983,8 +2983,8 @@ int p2m_add_foreign(struct domain *tdom, unsigned lon= g fgfn, prev_mfn =3D get_gfn(tdom, gpfn, &p2mt_prev); if ( mfn_valid(prev_mfn) ) { - if ( is_xen_heap_mfn(prev_mfn) ) - /* Xen heap frames are simply unhooked from this phys slot */ + if ( is_special_page(mfn_to_page(prev_mfn)) ) + /* Special pages are simply unhooked from this phys slot */ rc =3D guest_physmap_remove_page(tdom, _gfn(gpfn), prev_mfn, 0= ); else /* Normal domain memory is freed, to avoid leaking memory. */ diff --git a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/commo= n.c index 121ddf1255..75dd414a6e 100644 --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -2087,19 +2087,22 @@ static int sh_remove_all_mappings(struct domain *d,= mfn_t gmfn, gfn_t gfn) * The qemu helper process has an untyped mapping of this dom's RAM * and the HVM restore program takes another. * Also allow one typed refcount for - * - Xen heap pages, to match share_xen_page_with_guest(), - * - ioreq server pages, to match prepare_ring_for_helper(). + * - special pages, which are explicitly referenced and mapped by + * Xen. + * - ioreq server pages, which may be special pages or normal + * guest pages with an extra reference taken by + * prepare_ring_for_helper(). */ if ( !(shadow_mode_external(d) && (page->count_info & PGC_count_mask) <=3D 3 && ((page->u.inuse.type_info & PGT_count_mask) - =3D=3D (is_xen_heap_page(page) || + =3D=3D (is_special_page(page) || (is_hvm_domain(d) && is_ioreq_server_page(d, page))= ))) ) printk(XENLOG_G_ERR "can't find all mappings of mfn %"PRI_mfn - " (gfn %"PRI_gfn"): c=3D%lx t=3D%lx x=3D%d i=3D%d\n", + " (gfn %"PRI_gfn"): c=3D%lx t=3D%lx s=3D%d i=3D%d\n", mfn_x(gmfn), gfn_x(gfn), page->count_info, page->u.inuse.type_info, - !!is_xen_heap_page(page), + is_special_page(page), (is_hvm_domain(d) && is_ioreq_server_page(d, page))); } =20 diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c index b6afc0fba4..f6b1628742 100644 --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -559,7 +559,8 @@ _sh_propagate(struct vcpu *v, * caching attributes in the shadows to match what was asked for. */ if ( (level =3D=3D 1) && is_hvm_domain(d) && - !is_xen_heap_mfn(target_mfn) ) + (!mfn_valid(target_mfn) || + !is_special_page(mfn_to_page(target_mfn))) ) { int type; =20 diff --git a/xen/arch/x86/tboot.c b/xen/arch/x86/tboot.c index 8c232270b4..3224d1684b 100644 --- a/xen/arch/x86/tboot.c +++ b/xen/arch/x86/tboot.c @@ -189,7 +189,7 @@ static void update_pagetable_mac(vmac_ctx_t *ctx) =20 if ( !mfn_valid(_mfn(mfn)) ) continue; - if ( is_page_in_use(page) && !is_xen_heap_page(page) ) + if ( is_page_in_use(page) && !is_special_page(page) ) { if ( page->count_info & PGC_page_table ) { @@ -289,7 +289,7 @@ static void tboot_gen_xenheap_integrity(const uint8_t k= ey[TB_KEY_SIZE], + 3 * PAGE_SIZE)) ) continue; /* skip tboot and its page tables */ =20 - if ( is_page_in_use(page) && is_xen_heap_page(page) ) + if ( is_page_in_use(page) && is_special_page(page) ) { void *pg; =20 diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index a163c201e2..9b62087be1 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -285,6 +285,11 @@ extern struct domain *dom_cow; =20 #include =20 +static inline bool is_special_page(const struct page_info *page) +{ + return is_xen_heap_page(page) || (page->count_info & PGC_extra); +} + #ifndef page_list_entry struct page_list_head { --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel