From nobody Tue Feb 10 03:20:43 2026 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557242211; cv=none; d=zoho.com; s=zohoarc; b=XAPiirWCReAQlUk0heprC/aJ9b8ZQxrNbIb2jqTRtgS4VoMwHbHMEIEsQrxCI5wJHVNuRs6drceLNRBXfIE7vg1OaYcxujzGlWhnt3Kb8iXQBqro4xrTMcEojM9BnlINBSryooDn/eiPS9Pi1mMIDpqcLVGh9PbgQbOcPuwyKlk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557242211; 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:ARC-Authentication-Results; bh=hbhu0YohWONiIdqNjjwb9jC9809YnzZVx3Mwl7Zxu28=; b=od5O5EfN9sjwfRRQJl89TflHoAS0/h0Q1uhnkC1PadQdpdW0rrCLgYZyPYRXh3ljIG9AwIp/AVdZJF9HlMvH4pvYRpfnHOhhSqB1m9fs7KQbBMydyIhEpQZF1dktk35aA3l5jNwgiEXZhLTURvGqjKOy8gmdeZCyaCE+LHCm5dk= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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 1557242211141738.1092091746368; Tue, 7 May 2019 08:16:51 -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 1hO1oc-0007Vq-I2; Tue, 07 May 2019 15:15:34 +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 1hO1ob-0007UV-5f for xen-devel@lists.xenproject.org; Tue, 07 May 2019 15:15:33 +0000 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id f4392e90-70da-11e9-82a8-5b2083d4bc8e; Tue, 07 May 2019 15:15:31 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 35F4F15AD; Tue, 7 May 2019 08:15:31 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 025F63F5AF; Tue, 7 May 2019 08:15:29 -0700 (PDT) X-Inumbo-ID: f4392e90-70da-11e9-82a8-5b2083d4bc8e From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 7 May 2019 16:14:55 +0100 Message-Id: <20190507151458.29350-12-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190507151458.29350-1-julien.grall@arm.com> References: <20190507151458.29350-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 11/14] xen/x86: mm: Re-implement set_gpfn_from_mfn() as a static 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: Andrew Cooper , Julien Grall , Wei Liu , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" set_gpfn_from_mfn() is currently implement in a 2 part macros. The second macro is only called within the first macro, so they can be folded together. Furthermore, this is now converted to a static inline making the code more readable and safer. As set_gpfn_from_mfn is now a static inline function, the extern variable dom_cow should be defined earlier on. For convenience, the definition of all dom_* variables are moved earlier on. Signed-off-by: Julien Grall --- Changes in v2: - Patch added --- xen/include/asm-x86/mm.h | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h index 717378730b..4721725c60 100644 --- a/xen/include/asm-x86/mm.h +++ b/xen/include/asm-x86/mm.h @@ -442,6 +442,8 @@ int check_descriptor(const struct domain *d, seg_desc_t= *desc); =20 extern paddr_t mem_hotplug; =20 +extern struct domain *dom_xen, *dom_io, *dom_cow; /* for vmcoreinfo */ + /*************************************************************************= ***** * With shadow pagetables, the different kinds of address start * to get get confusing. @@ -483,24 +485,25 @@ extern paddr_t mem_hotplug; #define SHARED_M2P(_e) ((_e) =3D=3D SHARED_M2P_ENTRY) =20 #define compat_machine_to_phys_mapping ((unsigned int *)RDWR_COMPAT_MPT_VI= RT_START) -#define _set_gpfn_from_mfn(mfn, pfn) ({ \ - struct domain *d =3D page_get_owner(mfn_to_page(_mfn(mfn))); \ - unsigned long entry =3D (d && (d =3D=3D dom_cow)) ? \ - SHARED_M2P_ENTRY : (pfn); \ - ((void)((mfn) >=3D (RDWR_COMPAT_MPT_VIRT_END - RDWR_COMPAT_MPT_VIRT_ST= ART) / 4 || \ - (compat_machine_to_phys_mapping[(mfn)] =3D (unsigned int)(entr= y))), \ - machine_to_phys_mapping[(mfn)] =3D (entry)); \ - }) =20 /* * Disable some users of set_gpfn_from_mfn() (e.g., free_heap_pages()) unt= il * the machine_to_phys_mapping is actually set up. */ extern bool machine_to_phys_mapping_valid; -#define set_gpfn_from_mfn(mfn, pfn) do { \ - if ( machine_to_phys_mapping_valid ) \ - _set_gpfn_from_mfn(mfn, pfn); \ -} while (0) + +static inline void set_gpfn_from_mfn(unsigned long mfn, unsigned long pfn) +{ + struct domain *d =3D page_get_owner(mfn_to_page(_mfn(mfn))); + unsigned long entry =3D (d && (d =3D=3D dom_cow)) ? SHARED_M2P_ENTRY := pfn; + + if (!machine_to_phys_mapping_valid) + return; + + if ( mfn >=3D (RDWR_COMPAT_MPT_VIRT_END - RDWR_COMPAT_MPT_VIRT_START) = / 4 ) + compat_machine_to_phys_mapping[mfn] =3D entry; + machine_to_phys_mapping[mfn] =3D entry; +} =20 extern struct rangeset *mmio_ro_ranges; =20 @@ -592,8 +595,6 @@ unsigned int domain_clamp_alloc_bitsize(struct domain *= d, unsigned int bits); =20 unsigned long domain_get_maximum_gpfn(struct domain *d); =20 -extern struct domain *dom_xen, *dom_io, *dom_cow; /* for vmcoreinfo */ - /* Definition of an mm lock: spinlock with extra fields for debugging */ typedef struct mm_lock { spinlock_t lock; --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel