From nobody Sun May 5 18:53:28 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=pass; 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=1600711371; cv=none; d=zohomail.com; s=zohoarc; b=CXQxMPteqzdO8leh6EpDEARb6HKyI3Ba7VmncuqASFW7inCVbq46nmFOSRSPzHBk8qXuZnMKy3ed48LHxQmQAzr0lcq//Tw8gjd/oAJj4VD4HCLukUWlqiRnsgLN8s6Nh4a8ASv4/mdfTVJFo3BdbHhGNmZMsElkb4Otb+eWELU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600711371; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=33YMzmUbMY7znlTscUrVDIV5v+7zwKEarD370yVOPcw=; b=MupGbRFGI6UhOIwtvtX11wnfO7qjZfhKyop6vpzoHutQjFTbVJJZfzbivSUNBLjO+cxwUFGmmlKfyEnsLxUfOkrHHZSn3/VpWapfgmjd84YZqaTwpqlTxt+qvJ29Xr97frbjw2VLBboyjMAtucSqMHy3EIXnG+eFNNLVCJGaV6E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1600711371441290.93228642380075; Mon, 21 Sep 2020 11:02:51 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kKQ8w-0003L2-AY; Mon, 21 Sep 2020 18:02:26 +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.92) (envelope-from ) id 1kKQ8v-0003Kh-4J for xen-devel@lists.xenproject.org; Mon, 21 Sep 2020 18:02:25 +0000 Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 93cad2df-20a6-4767-ab87-053150edfa14; Mon, 21 Sep 2020 18:02:23 +0000 (UTC) Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kKQ8s-000871-Ff; Mon, 21 Sep 2020 18:02:22 +0000 Received: from 54-240-197-235.amazon.com ([54.240.197.235] helo=ufe34d9ed68d054.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kKQ8s-0003uk-6L; Mon, 21 Sep 2020 18:02:22 +0000 X-Inumbo-ID: 93cad2df-20a6-4767-ab87-053150edfa14 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=33YMzmUbMY7znlTscUrVDIV5v+7zwKEarD370yVOPcw=; b=h+IcmBbvaNkXB9xBBoZRedXf6 k2XXdOwnFbHQV/J49RTpKC9mCw5L6bAiaGFYIzLefJ/mCGhuPjqxz3KwwpGMAdejqqAa4xyItp0Kn 46VNWhvyeOH6FIdvajpKzcyQwdSBDcZvMZI6ZKwjqbNaGmMp4DOEFZxgeuKq5hOEX+6f4=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: julien@xen.org, Julien Grall , Andrew Cooper , George Dunlap , Ian Jackson , Jan Beulich , Stefano Stabellini , Wei Liu Subject: [PATCH v4 1/4] xen: XENMEM_exchange should only be used/compiled for arch supporting PV guest Date: Mon, 21 Sep 2020 19:02:11 +0100 Message-Id: <20200921180214.4842-2-julien@xen.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200921180214.4842-1-julien@xen.org> References: <20200921180214.4842-1-julien@xen.org> X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: pass (identity @xen.org) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Julien Grall XENMEM_exchange can only be used by PV guest but the check is well hidden in steal_page(). This is because paging_model_external() will return false only for PV domain. To make clearer this is PV only, add a check at the beginning of the implementation. Take the opportunity to compile out the code if CONFIG_PV is not set. This change will also help a follow-up patch where the gmfn_mfn() will be completely removed on arch not supporting the M2P. Signed-off-by: Julien Grall --- Jan suggested to #ifdef anything after the check to is_pv_domain(). However, it means to have two block of #ifdef as we can't mix declaration and code. I am actually thinking to move the implementation outside of mm.c in possibly arch/x86 or a pv specific directory under common. Any opinion? Changes in v4: - Patch added --- xen/common/memory.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/xen/common/memory.c b/xen/common/memory.c index 714077c1e597..9300104943b0 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -504,6 +504,7 @@ static bool propagate_node(unsigned int xmf, unsigned i= nt *memflags) =20 static long memory_exchange(XEN_GUEST_HANDLE_PARAM(xen_memory_exchange_t) = arg) { +#ifdef CONFIG_PV struct xen_memory_exchange exch; PAGE_LIST_HEAD(in_chunk_list); PAGE_LIST_HEAD(out_chunk_list); @@ -516,6 +517,9 @@ static long memory_exchange(XEN_GUEST_HANDLE_PARAM(xen_= memory_exchange_t) arg) struct domain *d; struct page_info *page; =20 + if ( !is_pv_domain(d) ) + return -EOPNOTSUPP; + if ( copy_from_guest(&exch, arg, 1) ) return -EFAULT; =20 @@ -797,6 +801,9 @@ static long memory_exchange(XEN_GUEST_HANDLE_PARAM(xen_= memory_exchange_t) arg) if ( __copy_field_to_guest(arg, &exch, nr_exchanged) ) rc =3D -EFAULT; return rc; +#else /* !CONFIG_PV */ + return -EOPNOTSUPP; +#endif } =20 int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xat= p, --=20 2.17.1 From nobody Sun May 5 18:53:28 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=pass; 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=1600711367; cv=none; d=zohomail.com; s=zohoarc; b=BUbgpfEmgWM7VQevQq7nBDdXJ6PZUUUc+emqP0xAbezLBBlxcjw7/WqmmAkfVuwf9JfmMxsI9fc8MwOh1fAt6CQpC32Epnmc+fVEqMZ/1N4Dn6MW3ndOr34GM37wx7K4VZqm+M8g+T9Rk0DOMrq4nE3/1haikIZzSyJMRRNU89c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600711367; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=ycj+udjjN9eYdtjLRlg0VaaJ8Nr+SqZXsYEt5ubsCzA=; b=URnVyJhUIni0wSrTshILfr9Eyt834RhJ1+i5CVICBYCiCeGa8mFBQ9wjTT0SjsRZCjbeHW8axyHPpyrJDt0u/AHk9bgTTQbhXkNW1eSgjZNSMh3/+G/JsdoA6nNZltGVPoqjwoL3wZ5md2GUv6NTrQUegBXTw8f1K+aooAP77gk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 16007113671845.444651009792096; Mon, 21 Sep 2020 11:02:47 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kKQ8z-0003Lc-JK; Mon, 21 Sep 2020 18:02:29 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kKQ8y-0003KW-9g for xen-devel@lists.xenproject.org; Mon, 21 Sep 2020 18:02:28 +0000 Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 502a46da-a94b-4bcc-90da-959752d1fc97; Mon, 21 Sep 2020 18:02:25 +0000 (UTC) Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kKQ8u-00087C-94; Mon, 21 Sep 2020 18:02:24 +0000 Received: from 54-240-197-235.amazon.com ([54.240.197.235] helo=ufe34d9ed68d054.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kKQ8t-0003uk-Vf; Mon, 21 Sep 2020 18:02:24 +0000 X-Inumbo-ID: 502a46da-a94b-4bcc-90da-959752d1fc97 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=ycj+udjjN9eYdtjLRlg0VaaJ8Nr+SqZXsYEt5ubsCzA=; b=OnfZ8YFHFJu2UJ9p30k4xa9xO KyVM4mCYzP7KdYUbVmvFT3Psyd8kdXivEO9feKb5UNx5VdjgvUoXPAZVV1ZMsGdeMdp7NGzcPheUo Z4hulH1e5MCtYIxCSzTLxy1/gXiaIMy/Izs1nqfLDyeSq7T2AlOohMj3a3afey1OunrxY=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: julien@xen.org, Julien Grall , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , George Dunlap , Ian Jackson , Stefano Stabellini , Volodymyr Babchuk Subject: [PATCH v4 2/4] xen: Introduce HAS_M2P config and use to protect mfn_to_gmfn call Date: Mon, 21 Sep 2020 19:02:12 +0100 Message-Id: <20200921180214.4842-3-julien@xen.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200921180214.4842-1-julien@xen.org> References: <20200921180214.4842-1-julien@xen.org> X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: pass (identity @xen.org) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Julien Grall While Arm never had a M2P, the implementation of mfn_to_gmfn is pretty bogus as we directly return the MFN passed in parameter. Thankfully, the use of mfn_to_gmfn is pretty limited on Arm today. There are only 2 callers in the common code: - memory_exchange: Arm cannot not use it because steal_page is not implemented. Note this is already protected by !CONFIG_PV. - getdomaininfo: Toolstack may map the shared page. It looks like this is mostly used for mapping the P2M of PV guest. Therefore the issue might be minor. Implementing the M2P on Arm is not planned. The M2P would require significa= nt amount of VA address (very tough on 32-bit) that can hardly be justified wi= th the current use of mfn_to_gmfn. - memory_exchange: This does not work and I haven't seen any request for it so far. - getdomaininfo: The structure on Arm does not seem to contain a lot of useful information on Arm. It is unclear whether we want to allow the toolstack mapping it on Arm. This patch introduces a config option HAS_M2P to tell whether an architecture implements the M2P. - memory_exchange: This is PV only (not supported on Arm) but take the opportunity to gate with HAS_M2P as well in case someone decide to implement PV without M2P. - getdomaininfo: A new helper is introduced to wrap the call to mfn_to_gfn/mfn_to_gmfn. For Arm, a fixed value will be provided that wi= ll fail on mapping if used. Signed-off-by Julien Grall --- Changes in v4: - The IOMMU code doesn't use the M2P anymore, so this can be dropped. - Reword the commit message - Fix rebase conflict Changes in v3: - Move the BUG_ON() in domain_shared_info_gfn() - Use a fixed value when the field shared_info_frame is not supported. - Add an ASSERT_UNREACHABLE in iommu_hwdom_init + move printk within the #ifdef. Changes in v2: - Add a warning in public headers - Constify local variable in domain_shared_info_gfn - Invert the naming (_d / d) in domain_shared_info_gfn - Use -EOPNOTSUPP rather than -ENOSYS - Rework how the memory_exchange hypercall is removed from Arm --- xen/arch/x86/Kconfig | 1 + xen/common/Kconfig | 3 +++ xen/common/domctl.c | 9 +++++++-- xen/common/memory.c | 4 ++-- xen/include/asm-arm/domain.h | 5 +++++ xen/include/public/domctl.h | 6 ++++++ xen/include/xen/domain.h | 12 ++++++++++++ 7 files changed, 36 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig index a636a4bb1e69..ad92e756cccc 100644 --- a/xen/arch/x86/Kconfig +++ b/xen/arch/x86/Kconfig @@ -16,6 +16,7 @@ config X86 select HAS_IOPORTS select HAS_KEXEC select MEM_ACCESS_ALWAYS_ON + select HAS_M2P select HAS_MEM_PAGING select HAS_NS16550 select HAS_PASSTHROUGH diff --git a/xen/common/Kconfig b/xen/common/Kconfig index 15e3b79ff57f..b6b4db92d700 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -63,6 +63,9 @@ config HAS_IOPORTS config HAS_SCHED_GRANULARITY bool =20 +config HAS_M2P + bool + config NEEDS_LIBELF bool =20 diff --git a/xen/common/domctl.c b/xen/common/domctl.c index 5ac6e9c5cafa..2bf3e6659018 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -68,6 +68,7 @@ void getdomaininfo(struct domain *d, struct xen_domctl_ge= tdomaininfo *info) u64 cpu_time =3D 0; int flags =3D XEN_DOMINF_blocked; struct vcpu_runstate_info runstate; + gfn_t shared_info_frame; =20 info->domain =3D d->domain_id; info->max_vcpu_id =3D XEN_INVALID_MAX_VCPU_ID; @@ -111,8 +112,12 @@ void getdomaininfo(struct domain *d, struct xen_domctl= _getdomaininfo *info) info->outstanding_pages =3D d->outstanding_pages; info->shr_pages =3D atomic_read(&d->shr_pages); info->paged_pages =3D atomic_read(&d->paged_pages); - info->shared_info_frame =3D mfn_to_gmfn(d, virt_to_mfn(d->shared_info)= ); - BUG_ON(SHARED_M2P(info->shared_info_frame)); + + shared_info_frame =3D domain_shared_info_gfn(d); + if ( gfn_eq(shared_info_frame, INVALID_GFN) ) + info->shared_info_frame =3D XEN_INVALID_SHARED_INFO_FRAME; + else + info->shared_info_frame =3D gfn_x(shared_info_frame); =20 info->cpupool =3D cpupool_get_id(d); =20 diff --git a/xen/common/memory.c b/xen/common/memory.c index 9300104943b0..c698e6872596 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -504,7 +504,7 @@ static bool propagate_node(unsigned int xmf, unsigned i= nt *memflags) =20 static long memory_exchange(XEN_GUEST_HANDLE_PARAM(xen_memory_exchange_t) = arg) { -#ifdef CONFIG_PV +#if defined(CONFIG_PV) && defined(CONFIG_M2P) struct xen_memory_exchange exch; PAGE_LIST_HEAD(in_chunk_list); PAGE_LIST_HEAD(out_chunk_list); @@ -801,7 +801,7 @@ static long memory_exchange(XEN_GUEST_HANDLE_PARAM(xen_= memory_exchange_t) arg) if ( __copy_field_to_guest(arg, &exch, nr_exchanged) ) rc =3D -EFAULT; return rc; -#else /* !CONFIG_PV */ +#else /* !(CONFIG_PV && CONFIG_M2P) */ return -EOPNOTSUPP; #endif } diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h index 6819a3bf382f..90161dd079a1 100644 --- a/xen/include/asm-arm/domain.h +++ b/xen/include/asm-arm/domain.h @@ -262,6 +262,11 @@ static inline void arch_vcpu_block(struct vcpu *v) {} =20 #define arch_vm_assist_valid_mask(d) (1UL << VMASST_TYPE_runstate_update_f= lag) =20 +static inline gfn_t domain_shared_info_gfn(struct domain *d) +{ + return INVALID_GFN; +} + #endif /* __ASM_DOMAIN_H__ */ =20 /* diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index 5c5e55ebcb76..7564df5e8374 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -136,6 +136,12 @@ struct xen_domctl_getdomaininfo { uint64_aligned_t outstanding_pages; uint64_aligned_t shr_pages; uint64_aligned_t paged_pages; +#define XEN_INVALID_SHARED_INFO_FRAME (~(uint64_t)0) + /* + * GFN of shared_info struct. Some architectures (e.g Arm) may not + * provide a mappable address in the field. In that case, the field + * will be set to XEN_INVALID_SHARED_INFO_FRAME. + */ uint64_aligned_t shared_info_frame; /* GMFN of shared_info struct */ uint64_aligned_t cpu_time; uint32_t nr_online_vcpus; /* Number of VCPUs currently online. */ diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index cde0d9c7fe63..7281eb7b36c7 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -131,4 +131,16 @@ void vnuma_destroy(struct vnuma_info *vnuma); static inline void vnuma_destroy(struct vnuma_info *vnuma) { ASSERT(!vnuma= ); } #endif =20 +#ifdef CONFIG_HAS_M2P +#define domain_shared_info_gfn(d) ({ \ + const struct domain *d_ =3D (d); \ + gfn_t gfn_; \ + \ + gfn_ =3D mfn_to_gfn(d_, _mfn(__virt_to_mfn(d_->shared_info)));\ + BUG_ON(SHARED_M2P(gfn_x(gfn_))); \ + \ + gfn_; \ +}) +#endif + #endif /* __XEN_DOMAIN_H__ */ --=20 2.17.1 From nobody Sun May 5 18:53:28 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=pass; 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=1600711370; cv=none; d=zohomail.com; s=zohoarc; b=AnC/SudsG/Qm2kA7yKFIgQy78e+b9y/fdkHwVQdyFqHNf4nYt+yKDyrBVB5VTPKZDP+ODCXmowEKssr85OdilKqOPAO+GOehd5Bl+vs8Tg9bptpnT4KoeXPUee7QfKdFYRFj4DeUQw45MDQrh4CgsG1mCmmQLcXDPYy2rAbY+J4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600711370; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=EwQ+12qSdbyDMM79qb1aOX/v/SX+2YxKEDlXBP9XAZk=; b=SmglXDYuLQRHOPcpiTzAWurTk9JqH8aiiGEHrtneMoNrVu/xzbPXfPbUNLsFZzukp17sRpkJyUjl8JkBjOFUQmhKfi5NIxgYtgEhLdhIDUqVQIbWAmaIFGAqnSVGn9lMP6gEV3mYOIhLJk69X/l/Y9ErzTxn3AZdp5ddq4D60mQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1600711370798321.70497130162755; Mon, 21 Sep 2020 11:02:50 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kKQ91-0003Mr-S0; Mon, 21 Sep 2020 18:02:31 +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.92) (envelope-from ) id 1kKQ90-0003Kh-2F for xen-devel@lists.xenproject.org; Mon, 21 Sep 2020 18:02:30 +0000 Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 3834be56-5e9e-4c87-a493-4c7a5181e662; Mon, 21 Sep 2020 18:02:26 +0000 (UTC) Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kKQ8v-00087L-QM; Mon, 21 Sep 2020 18:02:25 +0000 Received: from 54-240-197-235.amazon.com ([54.240.197.235] helo=ufe34d9ed68d054.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kKQ8v-0003uk-HP; Mon, 21 Sep 2020 18:02:25 +0000 X-Inumbo-ID: 3834be56-5e9e-4c87-a493-4c7a5181e662 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=EwQ+12qSdbyDMM79qb1aOX/v/SX+2YxKEDlXBP9XAZk=; b=g9HyBMo5qm+msv6psDz9kiCvd u8wiQoGZHPSFXSqG33EmtRa/VZrxX6c9erKx8gIgOJGvlneNNtDBShJM0oPi7l5Fhyn7cu3APwFeL eJePh7FGCS0e4H/wQYFDa0B9Aton3a3Ub/wDX8pDHcWbJKHTercgK9TMdqL+1MeY7AqoM=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: julien@xen.org, Julien Grall , Stefano Stabellini , Volodymyr Babchuk , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH v4 3/4] xen: Remove mfn_to_gmfn macro Date: Mon, 21 Sep 2020 19:02:13 +0100 Message-Id: <20200921180214.4842-4-julien@xen.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200921180214.4842-1-julien@xen.org> References: <20200921180214.4842-1-julien@xen.org> X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: pass (identity @xen.org) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Julien Grall On x86, mfn_to_gmfn can be replaced with mfn_to_gfn. On Arm, there are no more call to mfn_to_gmfn, so the helper can be dropped. At the same time rework a comment in Arm code that does not make sense. Signed-off-by: Julien Grall --- Changes in v4: - Remove acks as the patch is old Changes in v2: - Add Jan's and Stefano's acked-by --- xen/include/asm-arm/mm.h | 4 +--- xen/include/asm-x86/mm.h | 5 ----- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h index f8ba49b1188f..29489a3e1076 100644 --- a/xen/include/asm-arm/mm.h +++ b/xen/include/asm-arm/mm.h @@ -326,10 +326,8 @@ struct page_info *get_page_from_gva(struct vcpu *v, va= ddr_t va, #define SHARED_M2P_ENTRY (~0UL - 1UL) #define SHARED_M2P(_e) ((_e) =3D=3D SHARED_M2P_ENTRY) =20 -/* Xen always owns P2M on ARM */ +/* We don't have a M2P on Arm */ #define set_gpfn_from_mfn(mfn, pfn) do { (void) (mfn), (void)(pfn); } whil= e (0) -#define mfn_to_gmfn(_d, mfn) (mfn) - =20 /* Arch-specific portion of memory_op hypercall. */ long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg); diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h index deeba75a1cbb..dfa71ce15ac3 100644 --- a/xen/include/asm-x86/mm.h +++ b/xen/include/asm-x86/mm.h @@ -508,11 +508,6 @@ extern struct rangeset *mmio_ro_ranges; =20 #define get_gpfn_from_mfn(mfn) (machine_to_phys_mapping[(mfn)]) =20 -#define mfn_to_gmfn(_d, mfn) \ - ( (paging_mode_translate(_d)) \ - ? get_gpfn_from_mfn(mfn) \ - : (mfn) ) - #define compat_pfn_to_cr3(pfn) (((unsigned)(pfn) << 12) | ((unsigned)(pfn)= >> 20)) #define compat_cr3_to_pfn(cr3) (((unsigned)(cr3) >> 12) | ((unsigned)(cr3)= << 20)) =20 --=20 2.17.1 From nobody Sun May 5 18:53:28 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=pass; 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=1600711369; cv=none; d=zohomail.com; s=zohoarc; b=BZc6YC933BAyWIWyL8sWqbI2vdsgpM17VluOn181HolXhV1plmxvII6qO82P6xsPKEJfPljTNzqjiJGGuIBYUPY6yskuwtAd4veCO/CBmB8PQaUiLXtxZc7uRAs1nwhZCnbwKpXe3sk4QM9fCxVaaIL1Hgjy5K/gPZI0SS0HSEw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600711369; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=kRgAuPJg4QZgZY5JhR8JA1mjiraFCTIYdvp+6bJCoIk=; b=au78YPM/0S0A3g2sVp+F4UAK+qFmVdXEipWmDabbLUWtUSETvd+eoyPnhG+106dIOErU99yQePTyK7qP/3chIdUKe32fPAtaA3HA0pizwCjg7f8llRhs1jZEsx39izcYNSOhhyGog7f6T1Df9jlg5HCQr4MR9o9pZuKjF3w5yko= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1600711369242686.8773090128835; Mon, 21 Sep 2020 11:02:49 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kKQ94-0003O6-5Y; Mon, 21 Sep 2020 18:02:34 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kKQ93-0003KW-9x for xen-devel@lists.xenproject.org; Mon, 21 Sep 2020 18:02:33 +0000 Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id b8fc4c22-75bd-495e-bbca-5bdad6c84546; Mon, 21 Sep 2020 18:02:29 +0000 (UTC) Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kKQ8x-00087T-FT; Mon, 21 Sep 2020 18:02:27 +0000 Received: from 54-240-197-235.amazon.com ([54.240.197.235] helo=ufe34d9ed68d054.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kKQ8x-0003uk-6X; Mon, 21 Sep 2020 18:02:27 +0000 X-Inumbo-ID: b8fc4c22-75bd-495e-bbca-5bdad6c84546 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=kRgAuPJg4QZgZY5JhR8JA1mjiraFCTIYdvp+6bJCoIk=; b=H34jv+ycNSiWmns6bXUCA0I/p DK9uipV5nBaqWuwKi1By0fUPcF4SO/wWIWVypLRKptbOHXivL/Mu6koqhb4F8a+KUfZSIvpQbVcOU wfS5f9f5j2tZhPoizJ95EyeCdlOoWi1oFFgowGHxuxPHVB35lFkQ0aCC0Ws5ycbfzJhvY=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: julien@xen.org, Julien Grall , Stefano Stabellini , Volodymyr Babchuk , Andrew Cooper , George Dunlap , Ian Jackson , Jan Beulich , Wei Liu Subject: [PATCH v4 4/4] xen/mm: Provide dummy M2P-related helpers when !CONFIG_HAVE_M2P Date: Mon, 21 Sep 2020 19:02:14 +0100 Message-Id: <20200921180214.4842-5-julien@xen.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200921180214.4842-1-julien@xen.org> References: <20200921180214.4842-1-julien@xen.org> X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: pass (identity @xen.org) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Julien Grall At the moment, Arm is providing a dummy implementation for the M2P helpers used in common code. However, they are quite isolated and could be used by other architecture in the future. So move all the helpers in xen/mm.h. Signed-off-by: Julien Grall --- Changes in v4: - The tags were dropped as the previous version was sent a long time ago. Changes in v3: - Add Stefano's reviewed-by - Add George's acked-by Changes in v2: - Patch added --- xen/include/asm-arm/mm.h | 11 ----------- xen/include/xen/mm.h | 13 +++++++++++++ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h index 29489a3e1076..5929201d0299 100644 --- a/xen/include/asm-arm/mm.h +++ b/xen/include/asm-arm/mm.h @@ -318,17 +318,6 @@ static inline void *page_to_virt(const struct page_inf= o *pg) struct page_info *get_page_from_gva(struct vcpu *v, vaddr_t va, unsigned long flags); =20 -/* - * Arm does not have an M2P, but common code expects a handful of - * M2P-related defines and functions. Provide dummy versions of these. - */ -#define INVALID_M2P_ENTRY (~0UL) -#define SHARED_M2P_ENTRY (~0UL - 1UL) -#define SHARED_M2P(_e) ((_e) =3D=3D SHARED_M2P_ENTRY) - -/* We don't have a M2P on Arm */ -#define set_gpfn_from_mfn(mfn, pfn) do { (void) (mfn), (void)(pfn); } whil= e (0) - /* Arch-specific portion of memory_op hypercall. */ long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg); =20 diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index 4536a62940a1..15bb0aa30d22 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -685,4 +685,17 @@ static inline void put_page_alloc_ref(struct page_info= *page) } } =20 +/* + * Dummy implementation of M2P-related helpers for common code when + * the architecture doesn't have an M2P. + */ +#ifndef CONFIG_HAS_M2P + +#define INVALID_M2P_ENTRY (~0UL) +#define SHARED_M2P(_e) false + +static inline void set_gpfn_from_mfn(unsigned long mfn, unsigned long pfn)= {} + +#endif + #endif /* __XEN_MM_H__ */ --=20 2.17.1