From nobody Wed Apr 24 03:46:52 2024 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=1557242204; cv=none; d=zoho.com; s=zohoarc; b=Y2kORQu0nCJ8JHv25aK0m4Ax9wpQRpbbTClA5YJag/I5WmKvIoMxNzc12yPPUwJZCjJBLTJAyaeQAItFcxiI46TNAEea//S9uFzQfAY7Rutvw5l/lDQDpHKAFepYmlSRsbvukksz2bMWqmjSXQCHkbrDsEKDbrknTnh5AQJpVdU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557242204; 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=Xd3+7Olhhm6rfKoym/O4qbSdHhJ3GK0QWJEJ5/2B2n0=; b=boxNxd89vqeHDeLXONoVc1yLjh91JOwyB6KqXU7HUW9MzKnhFafBNt8p+Lcywv1TwxfaG1xPw0jfqL4KrdLgZGYhgj+20NUSA65LVBhs+lPtDgurYYWa5kNAgE2dxKsGVM9CnE04JilAitucvUs0jg5mDlAaq6miGUXKI/US3Eg= 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 1557242204903743.4952275643265; Tue, 7 May 2019 08:16:44 -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 1hO1oP-0007Ll-A4; Tue, 07 May 2019 15:15:21 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hO1oO-0007LK-2w for xen-devel@lists.xenproject.org; Tue, 07 May 2019 15:15:20 +0000 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id ecb7c372-70da-11e9-843c-bc764e045a96; Tue, 07 May 2019 15:15:18 +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 8D03115AD; Tue, 7 May 2019 08:15:18 -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 9CA613F5AF; Tue, 7 May 2019 08:15:16 -0700 (PDT) X-Inumbo-ID: ecb7c372-70da-11e9-843c-bc764e045a96 From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 7 May 2019 16:14:49 +0100 Message-Id: <20190507151458.29350-6-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 05/14] xen/grant-table: Make arch specific macros typesafe 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 , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , 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" This patch rework all the arch specific macros in grant_table.h to use the typesafe MFN/GFN. At the same time, some functions are renamed s/gmfn/gfn/ to match the current naming scheme (see include/mm.h). No functional changes intended. Signed-off-by: Julien Grall Acked-by: Jan Beulich Reviewed-by: Stefano Stabellini --- Changes in v2: - Update commit message to explain the changes made - Fix indentation - Adapt the code to match the new prototype of mfn_to_gfn - Add Jan's acked-by for non-ARM parts --- xen/common/grant_table.c | 4 ++-- xen/include/asm-arm/grant_table.h | 12 ++++++------ xen/include/asm-x86/grant_table.h | 19 +++++++------------ 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c index 80728ea57d..abc966f775 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -1935,7 +1935,7 @@ gnttab_setup_table( op.status =3D GNTST_okay; for ( i =3D 0; i < op.nr_frames; i++ ) { - xen_pfn_t gmfn =3D gnttab_shared_gmfn(d, gt, i); + xen_pfn_t gmfn =3D gfn_x(gnttab_shared_gfn(d, gt, i)); =20 /* Grant tables cannot be shared */ BUG_ON(SHARED_M2P(gmfn)); @@ -3149,7 +3149,7 @@ gnttab_get_status_frames(XEN_GUEST_HANDLE_PARAM(gntta= b_get_status_frames_t) uop, =20 for ( i =3D 0; i < op.nr_frames; i++ ) { - gmfn =3D gnttab_status_gmfn(d, gt, i); + gmfn =3D gfn_x(gnttab_status_gfn(d, gt, i)); if ( copy_to_guest_offset(op.frame_list, i, &gmfn, 1) ) op.status =3D GNTST_bad_virt_addr; } diff --git a/xen/include/asm-arm/grant_table.h b/xen/include/asm-arm/grant_= table.h index 051db1362b..750536184e 100644 --- a/xen/include/asm-arm/grant_table.h +++ b/xen/include/asm-arm/grant_table.h @@ -65,15 +65,15 @@ void gnttab_mark_dirty(struct domain *d, mfn_t mfn); } while ( 0 ) =20 #define gnttab_get_frame_gfn(gt, st, idx) ({ \ - _gfn((st) ? gnttab_status_gmfn(NULL, gt, idx) \ - : gnttab_shared_gmfn(NULL, gt, idx)); \ + (st) ? gnttab_status_gfn(NULL, gt, idx) \ + : gnttab_shared_gfn(NULL, gt, idx); \ }) =20 -#define gnttab_shared_gmfn(d, t, i) \ - gfn_x(((i) >=3D nr_grant_frames(t)) ? INVALID_GFN : (t)->arch.shared_g= fn[i]) +#define gnttab_shared_gfn(d, t, i) \ + (((i) >=3D nr_grant_frames(t)) ? INVALID_GFN : (t)->arch.shared_gfn[i]) =20 -#define gnttab_status_gmfn(d, t, i) \ - gfn_x(((i) >=3D nr_status_frames(t)) ? INVALID_GFN : (t)->arch.status_= gfn[i]) +#define gnttab_status_gfn(d, t, i) \ + (((i) >=3D nr_status_frames(t)) ? INVALID_GFN : (t)->arch.status_gfn[i= ]) =20 #define gnttab_need_iommu_mapping(d) \ (is_domain_direct_mapped(d) && need_iommu_pt_sync(d)) diff --git a/xen/include/asm-x86/grant_table.h b/xen/include/asm-x86/grant_= table.h index 8b604ed51f..661228dd39 100644 --- a/xen/include/asm-x86/grant_table.h +++ b/xen/include/asm-x86/grant_table.h @@ -39,24 +39,19 @@ static inline int replace_grant_host_mapping(uint64_t a= ddr, mfn_t frame, #define gnttab_destroy_arch(gt) do {} while ( 0 ) #define gnttab_set_frame_gfn(gt, st, idx, gfn) do {} while ( 0 ) #define gnttab_get_frame_gfn(gt, st, idx) ({ \ - unsigned long mfn_ =3D (st) ? gnttab_status_mfn(gt, idx) = \ - : gnttab_shared_mfn(gt, idx); \ - unsigned long gpfn_ =3D get_gpfn_from_mfn(mfn_); = \ + mfn_t mfn_ =3D (st) ? gnttab_status_mfn(gt, idx) = \ + : gnttab_shared_mfn(gt, idx); \ + unsigned long gpfn_ =3D get_gpfn_from_mfn(mfn_x(mfn_)); = \ VALID_M2P(gpfn_) ? _gfn(gpfn_) : INVALID_GFN; \ }) =20 -#define gnttab_shared_mfn(t, i) \ - ((virt_to_maddr((t)->shared_raw[i]) >> PAGE_SHIFT)) +#define gnttab_shared_mfn(t, i) _mfn(__virt_to_mfn((t)->shared_raw[i])) =20 -#define gnttab_shared_gmfn(d, t, i) \ - (mfn_to_gmfn(d, gnttab_shared_mfn(t, i))) +#define gnttab_shared_gfn(d, t, i) mfn_to_gfn(d, gnttab_shared_mfn(t, i)) =20 +#define gnttab_status_mfn(t, i) _mfn(__virt_to_mfn((t)->status[i])) =20 -#define gnttab_status_mfn(t, i) \ - ((virt_to_maddr((t)->status[i]) >> PAGE_SHIFT)) - -#define gnttab_status_gmfn(d, t, i) \ - (mfn_to_gmfn(d, gnttab_status_mfn(t, i))) +#define gnttab_status_gfn(d, t, i) mfn_to_gfn(d, gnttab_status_mfn(t, i)) =20 #define gnttab_mark_dirty(d, f) paging_mark_dirty(d, f) =20 --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel