From nobody Fri May 3 23:04:12 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=1625332346; cv=none; d=zohomail.com; s=zohoarc; b=O6yL32anlhp2v2XSJaY2YO0Cn+K2EYd4x6KRjdRR4YD8N6bQrj+wUwxbQogLV22LR95mq2C8q9J+97VdAf5HVeOvH2DUSsKAIaO2pErEWkoHIAMd/ehx8RsDu2eNB+SH75Ya4RoS1GRYh9RuluawkoMjl2otHqT08u8nkOf96Lo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1625332346; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=Mi7EgN/CRi27LYrSm9zQaxJ46g16tr2Wj55yCnIlKA4=; b=BJCZ39I3aUp5Ga2wMANFvNR/57pHW3OZ02rM4zwtx16/GOziSbpiiEYrSSdWDK3VN6egsnTvMV+KmaBCfra+3YYfzROMZ2XQXL4JAAoSfEQsa+JNtRINqup9zILJJk+9bEXWGo8V/WThJT0AeaRIxkTuHkKngtCQA4JEP5rBqz8= 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 1625332346470738.1793895373712; Sat, 3 Jul 2021 10:12:26 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.149548.276609 (Exim 4.92) (envelope-from ) id 1lzjBU-0000oa-UO; Sat, 03 Jul 2021 17:12:04 +0000 Received: by outflank-mailman (output) from mailman id 149548.276609; Sat, 03 Jul 2021 17:12: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 1lzjBU-0000oT-Pc; Sat, 03 Jul 2021 17:12:04 +0000 Received: by outflank-mailman (input) for mailman id 149548; Sat, 03 Jul 2021 17:12:03 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lzjBT-0000YD-BV for xen-devel@lists.xenproject.org; Sat, 03 Jul 2021 17:12:03 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lzjBR-0007bT-Ta; Sat, 03 Jul 2021 17:12:01 +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 1lzjBR-0005vs-KR; Sat, 03 Jul 2021 17:12:01 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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" 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=Mi7EgN/CRi27LYrSm9zQaxJ46g16tr2Wj55yCnIlKA4=; b=I/EuoQBYvNK1bKaRntBYRnGvh FJ43TXmrBKZj4zbksjE7SIxxWCUKk6nfjSWCj0x0iJJ7YgMKjcCmrz8/L0gJwva1bxEltPCOYbypW buNjjooGqQMKG6EXQ6nAueboG2EfwBVx6u/Sn0arGUPWI1///rBxo1zrPXvaKuBnFnhK0=; 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 v5 1/4] xen: XENMEM_exchange should only be used/compiled for arch supporting PV guest Date: Sat, 3 Jul 2021 18:11:49 +0100 Message-Id: <20210703171152.15874-2-julien@xen.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210703171152.15874-1-julien@xen.org> References: <20210703171152.15874-1-julien@xen.org> X-ZohoMail-DKIM: pass (identity @xen.org) X-ZM-MESSAGEID: 1625332349516100001 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. In a follow-up patch, mfn_to_gfn() will be completely removed for arch not supporting M2P as it is a call for trouble to use it. Take the opportunity to compile out the code if CONFIG_PV is not set. Ideally, we would want to to move the hypercall implementation in arch/x86/pv/mm.c. But this is incredibly tangled. Signed-off-by: Julien Grall Reviewed-by: Jan Beulich --- Ideally we would want to move the hypercall implementation in arch/x86/pv/mm.c. But this is a bit messy. So for now just #ifdef it. Changes in v5: - Removed the #ifdef CONFIG_X86 as they are not necessary anymore - Used paging_mode_translate() rather than is_pv_domain() - Reword the commit message to explain why the #ifdef rather than implementing mfn_to_gfn() using a BUG_ON() or moving the code to arch/x86/pv. Changes in v4: - Patch added --- xen/common/memory.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/xen/common/memory.c b/xen/common/memory.c index e07bd9a5ea4b..9bc78aae35db 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -522,6 +522,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); @@ -609,6 +610,13 @@ static long memory_exchange(XEN_GUEST_HANDLE_PARAM(xen= _memory_exchange_t) arg) goto fail_early; } =20 + if ( paging_mode_translate(d) ) + { + rc =3D -EOPNOTSUPP; + rcu_unlock_domain(d); + goto fail_early; + } + rc =3D xsm_memory_exchange(XSM_TARGET, d); if ( rc ) { @@ -648,7 +656,6 @@ static long memory_exchange(XEN_GUEST_HANDLE_PARAM(xen_= memory_exchange_t) arg) =20 for ( k =3D 0; k < (1UL << exch.in.extent_order); k++ ) { -#ifdef CONFIG_X86 p2m_type_t p2mt; =20 /* Shared pages cannot be exchanged */ @@ -659,14 +666,9 @@ static long memory_exchange(XEN_GUEST_HANDLE_PARAM(xen= _memory_exchange_t) arg) rc =3D -ENOMEM; goto fail;=20 } -#else /* !CONFIG_X86 */ - mfn =3D gfn_to_mfn(d, _gfn(gmfn + k)); -#endif if ( unlikely(!mfn_valid(mfn)) ) { -#ifdef CONFIG_X86 put_gfn(d, gmfn + k); -#endif rc =3D -EINVAL; goto fail; } @@ -676,16 +678,12 @@ static long memory_exchange(XEN_GUEST_HANDLE_PARAM(xe= n_memory_exchange_t) arg) rc =3D steal_page(d, page, MEMF_no_refcount); if ( unlikely(rc) ) { -#ifdef CONFIG_X86 put_gfn(d, gmfn + k); -#endif goto fail; } =20 page_list_add(page, &in_chunk_list); -#ifdef CONFIG_X86 put_gfn(d, gmfn + k); -#endif } } =20 @@ -768,8 +766,7 @@ static long memory_exchange(XEN_GUEST_HANDLE_PARAM(xen_= memory_exchange_t) arg) guest_physmap_add_page(d, _gfn(gpfn), mfn, exch.out.extent_order); =20 - if ( !paging_mode_translate(d) && - __copy_mfn_to_guest_offset(exch.out.extent_start, + if ( __copy_mfn_to_guest_offset(exch.out.extent_start, (i << out_chunk_order) + j, mfn) ) rc =3D -EFAULT; @@ -815,6 +812,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 Fri May 3 23:04:12 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=1625332347; cv=none; d=zohomail.com; s=zohoarc; b=NqqRvO6s591ZYb5ZyvRjnmccKnsG5bEgHaxX2Y7+H4cUs923awB4+bvXcgwkGGLukmtyjbrVWnEPM5wIE3azZY32fm3ieFkbMjZFQ0mudVUx29ql9m9uDfBXQmSeazAj2Va0gl/tVxPY5N00sqYuaotrcd9SXEvwBjr0pr3W57E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1625332347; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=2pkpvyGryxTS4uBplOORxJnDBZlpgWoUp7jdUVlTkUk=; b=ZnfDQlDig0eRxFrKZneM4Hnt21W6m9POwfG68DB8XqTK0r9z0+c4olIQBMSyOELJQ6g/sy35vieiQ6A4dTjVZUPvWv9WRiVK739FSwYyZvag5u49Q2Y8LkSnuDEofRoPc2XK8QT0V5OuLAfsUbf0bPWwRI1/7Oxcl6LSgXGQ8yQ= 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 1625332347979362.72524543922077; Sat, 3 Jul 2021 10:12:27 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.149550.276628 (Exim 4.92) (envelope-from ) id 1lzjBW-0001DT-PM; Sat, 03 Jul 2021 17:12:06 +0000 Received: by outflank-mailman (output) from mailman id 149550.276628; Sat, 03 Jul 2021 17:12: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 1lzjBW-0001Ae-H8; Sat, 03 Jul 2021 17:12:06 +0000 Received: by outflank-mailman (input) for mailman id 149550; Sat, 03 Jul 2021 17:12:05 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lzjBV-0000rQ-2j for xen-devel@lists.xenproject.org; Sat, 03 Jul 2021 17:12:05 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lzjBT-0007c2-FM; Sat, 03 Jul 2021 17:12:03 +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 1lzjBT-0005vs-6h; Sat, 03 Jul 2021 17:12:03 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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" 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=2pkpvyGryxTS4uBplOORxJnDBZlpgWoUp7jdUVlTkUk=; b=PsTwUivc5yu22Oe9pxT9BLzvy k0g6AirkHbuRzdlKfdYTloWhxO6D+Mx9hrsSY0OdqAOQJByi7WjKJAvRVmFYtflr3dt1GM1NNhBWQ g0DUfCflztgPKFN9OGedj1wtuzDkfaS9zl78dzASKACE17rKh08kOZXcKjG6CG6CbSM3k=; 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 Subject: [PATCH v5 2/4] xen: arm: Stop returning a bogus GFN for the shared info Date: Sat, 3 Jul 2021 18:11:50 +0100 Message-Id: <20210703171152.15874-3-julien@xen.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210703171152.15874-1-julien@xen.org> References: <20210703171152.15874-1-julien@xen.org> X-ZohoMail-DKIM: pass (identity @xen.org) X-ZM-MESSAGEID: 1625332350676100003 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_gfn() is pretty bogus as we directly return the MFN passed in parameter. The last use of mfn_to_gfn() on Arm is in getdomaininfo(). It looks like this is mostly used for mapping the P2M Of PV guest. Furthermore, the structure on Arm doesn't seem to contain a lot of useful information. Therefore it is unclear whether we want to allow the toolstack to map it. As there is a high change that RISC-V will not implement an M2P, provide a new wrapper that will by default return an invalid GFN and move the code to find the GFN in an x86 specific helper. If in the future we want to map the shared info, then we should consider to do it using the acquire hypercall. Note that as INVALID_GFN is unsigned long, we can't return directly because the value would differ between 64-bit and 32-bit. Instead, a fixed value needs to be introduced. While the fixed value could be shared with other field storing a GFN, we unfortunately use a mix of type (unsigned long, uint64_t) for exposing it externally. So to avoid any misuse, it is better to define a fixed value for just the shared_info_gfn field. Signed-off-by Julien Grall --- I am not comfortable with introduce a generic invalid GFN fixed value because we don't use a common type. I also didn't get any feedback on whether it would be acceptable to focus on one type. So the fixed value has not been changed. I think this is acceptable because this a DOMCTL and therefore not stable. If someone still disagree, then please provide concrete steps how to solve the mixing of type. Changes in v5: - This was originally "xen: Introduce HAS_M2P config and use to protect mfn_to_gmfn call". - Rebase to the latest Xen. - Rename the helper to arch_shared_info_gfn() - The default stub now return INVALID_GFN rather than using the M2P 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/domain.c | 9 +++++++++ xen/common/Kconfig | 3 +++ xen/common/domctl.c | 10 +++++++--- xen/include/asm-x86/domain.h | 3 +++ xen/include/public/domctl.h | 6 ++++++ xen/include/xen/domain.h | 7 +++++++ 6 files changed, 35 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index ef1812dc1402..b3f216cd6f51 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -2553,6 +2553,15 @@ void domain_pause_for_debugger(void) #endif } =20 +gfn_t arch_shared_info_gfn(const struct domain *d) +{ + gfn_t gfn =3D mfn_to_gfn(d, _mfn(__virt_to_mfn(d->shared_info))); + + BUG_ON(SHARED_M2P(gfn_x(gfn))); + + return gfn; +} + /* * Local variables: * mode: C diff --git a/xen/common/Kconfig b/xen/common/Kconfig index 0ddd18e11af3..cd5b89f2f02e 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -64,6 +64,9 @@ config MEM_ACCESS Framework to configure memory access types for guests and receive related events in userspace. =20 +config HAS_M2P + bool + config NEEDS_LIBELF bool =20 diff --git a/xen/common/domctl.c b/xen/common/domctl.c index 12d6144d2896..834a2183fda1 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,9 +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 - gfn_x(mfn_to_gfn(d, _mfn(virt_to_mfn(d->shared_info)))); - BUG_ON(SHARED_M2P(info->shared_info_frame)); + + shared_info_frame =3D arch_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/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h index 92d54de0b9a1..912a545c93f6 100644 --- a/xen/include/asm-x86/domain.h +++ b/xen/include/asm-x86/domain.h @@ -756,6 +756,9 @@ static inline void pv_inject_sw_interrupt(unsigned int = vector) : is_pv_32bit_domain(d) ? PV32_VM_ASSIST_MASK \ : PV64_VM_ASSIST_MASK) =20 +gfn_t arch_shared_info_gfn(const struct domain *d); +#define arch_shared_info_gfn arch_shared_info_gfn + #endif /* __ASM_DOMAIN_H__ */ =20 /* diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index 4dbf107785c3..02a2bfa969ec 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -141,6 +141,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 1708c369642e..d8044b7936ae 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -133,4 +133,11 @@ static inline void vnuma_destroy(struct vnuma_info *vn= uma) { ASSERT(!vnuma); } =20 extern bool vmtrace_available; =20 +#ifndef arch_shared_info_gfn +static inline gfn_t arch_shared_info_gfn(const struct domain *d) +{ + return INVALID_GFN; +} +#endif + #endif /* __XEN_DOMAIN_H__ */ --=20 2.17.1 From nobody Fri May 3 23:04:12 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=1625332349; cv=none; d=zohomail.com; s=zohoarc; b=JbCHDH9sPcQzXxeWBOihWZnpBLDpWEXe2xlMHGrrPDr1DazZMnY3lhob7hNm91x1ebSUTb87jLQbkWhp9ciTsAg4cDrPdU6EgyLF3s0OsCVaJoS0vtJyMjbVHIliKmUEEZFkS4Xwd1HrYQ7RMNf7+flHt+S8T2u8HznK4Z80WcU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1625332349; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=FR0yQDCD2iJpaV70AOOT+E3zRKLyD/84/EMXzs8PXvw=; b=VLCvxan5f7J8H8nEtFdxOHxOcSAB+lIBGJA6fuoNh2akIAbnN7koDf9iaB8ZGopnK5pKi4obMg/sG243guHVZ1OEOAq0ZzQ3COiry5TTj6NrKFUF5isVcy4z7emF83qRyPwp8o8p2ZxHp8KBPo4nT7AEPUz6UVI6JZWgtEifzWE= 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 1625332349195997.9366581539418; Sat, 3 Jul 2021 10:12:29 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.149549.276620 (Exim 4.92) (envelope-from ) id 1lzjBW-00014u-5H; Sat, 03 Jul 2021 17:12:06 +0000 Received: by outflank-mailman (output) from mailman id 149549.276620; Sat, 03 Jul 2021 17:12: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 1lzjBW-00014n-1z; Sat, 03 Jul 2021 17:12:06 +0000 Received: by outflank-mailman (input) for mailman id 149549; Sat, 03 Jul 2021 17:12:04 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lzjBU-0000oO-Ne for xen-devel@lists.xenproject.org; Sat, 03 Jul 2021 17:12:04 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lzjBU-0007cA-Fg; Sat, 03 Jul 2021 17:12:04 +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 1lzjBU-0005vs-7I; Sat, 03 Jul 2021 17:12:04 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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" 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=FR0yQDCD2iJpaV70AOOT+E3zRKLyD/84/EMXzs8PXvw=; b=zZ9vO3J39ZF/biDQHuJOiEOO7 4ShvOFdqg6iNCoF7G/1vB3Zbg+oEe4b8sh2XDSLlkE9CdpFbfo1c8aTAAzK0eRUrxcm7IIrQG2557 eTV9edB03YJBc5W8D8aZ/alX34kzdIOMlRt6xwND8xrjoLgnMKLYrukvjO6xAZdzpKz20=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: julien@xen.org, Julien Grall , Stefano Stabellini , Volodymyr Babchuk Subject: [PATCH v5 3/4] xen: arm: Remove mfn_to_gfn() macro Date: Sat, 3 Jul 2021 18:11:51 +0100 Message-Id: <20210703171152.15874-4-julien@xen.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210703171152.15874-1-julien@xen.org> References: <20210703171152.15874-1-julien@xen.org> X-ZohoMail-DKIM: pass (identity @xen.org) X-ZM-MESSAGEID: 1625332351961100007 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Julien Grall The current implementation of mfn_to_gfn() is completely bogus and there are no plan to implement an M2P on Arm. As there are no more users, drop the helper. At the same time rework a comment in Arm code that does not make sense. Signed-off-by: Julien Grall Acked-by: Stefano Stabellini Reviewed-by: Michal Orzel --- Changes in v5: - Rebase to the latest Xen - The patch is now arm only because mfn_to_gmfn() has been dropped on x86 and the arm helper was renamed to mfn_to_gfn(). 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 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h index ded74d29da0c..07c24654a0b6 100644 --- a/xen/include/asm-arm/mm.h +++ b/xen/include/asm-arm/mm.h @@ -326,9 +326,8 @@ struct page_info *get_page_from_gva(struct vcpu *v, vad= dr_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_gfn(d, mfn) ((void)(d), _gfn(mfn_x(mfn))) =20 /* Arch-specific portion of memory_op hypercall. */ long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg); --=20 2.17.1 From nobody Fri May 3 23:04:12 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=1625332348; cv=none; d=zohomail.com; s=zohoarc; b=VeiEnvrgmDgKCq+8V0mQ+QrDs6megYh/hP1yMuEjkSB5IzI1cD7taL6ZGdu++XC2cvt5C4Qv4SwR3w0HhzMsCm9Igy2L6/rBm4fuYFozZ0c6rGptt5pyJiOc3wWd1QmLB72LCxETQM++UGdSPpJoxu2hhbNa27bHgcNm9HuKtYI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1625332348; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=aIWtWhcuPOkNdbKN38vfGnv+lqziWSfdZNPE+Udjlj8=; b=W3hdh9TuK8CjCFTqV9eHMzX1PbDwcrHcUama/wx8Pb0rMo3Zu1re+0cqryCxnGq9ijvkWayHnjX5700L4V0HnzX/0yn9j47IVRfM3QRMSD0s5K2orsHNeuFvSN7G8ZQL3RdWLHJCtGmCd7Ah5JFIGgNwLKbpQCrOiOxgBdW3yUk= 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 1625332348068953.276179500616; Sat, 3 Jul 2021 10:12:28 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.149551.276641 (Exim 4.92) (envelope-from ) id 1lzjBZ-0001eJ-0U; Sat, 03 Jul 2021 17:12:09 +0000 Received: by outflank-mailman (output) from mailman id 149551.276641; Sat, 03 Jul 2021 17:12:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lzjBY-0001e6-SB; Sat, 03 Jul 2021 17:12:08 +0000 Received: by outflank-mailman (input) for mailman id 149551; Sat, 03 Jul 2021 17:12:07 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lzjBX-0001Wu-HV for xen-devel@lists.xenproject.org; Sat, 03 Jul 2021 17:12:07 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lzjBW-0007ce-5b; Sat, 03 Jul 2021 17:12:06 +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 1lzjBV-0005vs-TO; Sat, 03 Jul 2021 17:12:06 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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" 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=aIWtWhcuPOkNdbKN38vfGnv+lqziWSfdZNPE+Udjlj8=; b=Vf9Vm+yQSPcRJdNGq9MMtxp0c OwQStU5yFNCZGF9m4yO8Pu6lx/vbibpnPWFR9QnVeKuAkEiUFDn6XVxdISUM3N4mXJ4NHvMMt04dy sE4oKpjcoW3XIFTKfFmtGH+k0h9mh0kWm9Zj3Ax4nVGFt6J66u2ZlfhKRuclXqXTypGnc=; 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 v5 4/4] xen/mm: Provide dummy M2P-related helpers when the M2P is not supported Date: Sat, 3 Jul 2021 18:11:52 +0100 Message-Id: <20210703171152.15874-5-julien@xen.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210703171152.15874-1-julien@xen.org> References: <20210703171152.15874-1-julien@xen.org> X-ZohoMail-DKIM: pass (identity @xen.org) X-ZM-MESSAGEID: 1625332350679100004 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 the helpers necessary for compilation in xen/mm.h and gate them with a new config !HAS_M2P. The other M2P related helpers are removed. Take the opportunity to encode that CONFIG_MEM_SHARING requires the M2P. It is done in the header rather than the Kconfig because the option is not defined in the common Kconfig. Signed-off-by: Julien Grall Acked-by: Stefano Stabellini Reviewed-by: Jan Beulich --- INVALID_M2P_ENTRY needs to be defined because it is a parameter of set_gpfn_from_mfn(). The alternative would be to not evaluate the parameter 'pfn' (e.g. leave the helper as a macro) however this is a bit risky. Changes in v5: - Check that MEM_SHARING is not enabled without the M2P. 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/arch/x86/Kconfig | 1 + xen/include/asm-arm/mm.h | 11 ----------- xen/include/xen/mm.h | 17 +++++++++++++++++ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig index 9b164db64187..a083d8194680 100644 --- a/xen/arch/x86/Kconfig +++ b/xen/arch/x86/Kconfig @@ -16,6 +16,7 @@ config X86 select HAS_FAST_MULTIPLY select HAS_IOPORTS select HAS_KEXEC + select HAS_M2P select HAS_NS16550 select HAS_PASSTHROUGH select HAS_PCI diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h index 07c24654a0b6..beff43786bda 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 667f9dac83a4..b98a1a7f423f 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -612,4 +612,21 @@ 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 + +#ifdef CONFIG_MEM_SHARING +# error "Memory sharing depends on the M2P" +#endif + +#define INVALID_M2P_ENTRY (~0UL) +#define SHARED_M2P(_e) ((void)(_e), false) + +static inline void set_gpfn_from_mfn(unsigned long mfn, unsigned long pfn)= {} + +#endif + #endif /* __XEN_MM_H__ */ --=20 2.17.1