From patchwork Mon Feb 18 11:35:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 158590 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2384317jaa; Mon, 18 Feb 2019 03:37:56 -0800 (PST) X-Google-Smtp-Source: AHgI3IYg6KSpL/CEtPEXUAzT6GmpKRtOujc46XGRl5Iz+bO6tHVf4dS5h7PanUvy9WtHhf3hgj7B X-Received: by 2002:a25:c886:: with SMTP id y128mr18673216ybf.250.1550489876326; Mon, 18 Feb 2019 03:37:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550489876; cv=none; d=google.com; s=arc-20160816; b=yGlkKxVdM4Mjd5pVG2Jy7WPMUjVEPWGyHu5QABH0QdTy/it73uOsN/6ehG/GQP3tE/ auQHoXetS+Q1SxmKGQkxqsEYG5LEhw5YLJfTQrFzO79tygsSJSKzGjwqeq2eqEpET+bB 19ntrCQ/xD+1EZsATFhNkUsekfRlb4yESyI20+aA3FrPBtL7kFTs+o5GZ8PQnSlv39nR m3bXuc6HXiwT/AfVG0F0CHLX0k9+6tfMpGKLq8b/JvEQ6w32v21Xugmx8/3O/nLeka+0 8km3ts3aiSu0x9Rb23qrPA7tSc+88zmEcaFtO1hIAEhGYo6T9Q1l16T0zoHUmAaVYsdc /nRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:references:in-reply-to:message-id:date:to:from; bh=CdimcobEcrhFFnkQEloOuRrNBlgWQV3DHIKLxLeqs2g=; b=Ym48yw+dglxKxbS/VJe+HDI+YDrD2Pg4inXL4znRH8Yhs6EKGaouB6mk6CUVE3Z7OB VwLWUkraDnqwDOyQFsnklPQHnHeOO9OBPyO/kh2fQJB6AEpYJISRsAjwHmbTYf5FiyWD oAzOEHFrOqT/OUWq4KoEJUlDOjDJLKTtYm/lZ3BteHQXp5l5P3Vr282Ha8tksWty3RfI seNEr5sOKAjwNSRiXcKxfV+2KSnw4OHEQG0p6DgrUmr18TqqJDvr1cVBpA2EslZpCpfM +3zvql2mMXjuCTOIFYJyYaH5D8HjQdnRzxDbdTav0CY6hN05/O1h18d8m6GKUTVn3rFs GV4Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@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.google.com with ESMTPS id y62si1856208ywc.117.2019.02.18.03.37.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Feb 2019 03:37:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1gvhDc-0001zk-EE; Mon, 18 Feb 2019 11:36:16 +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 1gvhDb-0001z0-FE for xen-devel@lists.xenproject.org; Mon, 18 Feb 2019 11:36:15 +0000 X-Inumbo-ID: 65d31784-3371-11e9-a240-cb5fbebfa846 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 65d31784-3371-11e9-a240-cb5fbebfa846; Mon, 18 Feb 2019 11:36:14 +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 412441684; Mon, 18 Feb 2019 03:36:14 -0800 (PST) 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 5163D3F720; Mon, 18 Feb 2019 03:36:12 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 18 Feb 2019 11:35:55 +0000 Message-Id: <20190218113600.9540-5-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190218113600.9540-1-julien.grall@arm.com> References: <20190218113600.9540-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH for-next 4/9] 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: sstabellini@kernel.org, Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , =?utf-8?q?Ro?= =?utf-8?q?ger_Pau_Monn=C3=A9?= MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" No functional changes intended. Signed-off-by: Julien Grall Acked-by: Jan Beulich --- xen/common/grant_table.c | 4 ++-- xen/include/asm-arm/grant_table.h | 12 ++++++------ xen/include/asm-x86/grant_table.h | 20 ++++++++------------ 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c index fd099a8f25..e7a65b38e0 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -1935,7 +1935,7 @@ gnttab_setup_table( op.status = GNTST_okay; for ( i = 0; i < op.nr_frames; i++ ) { - xen_pfn_t gmfn = gnttab_shared_gmfn(d, gt, i); + xen_pfn_t gmfn = gfn_x(gnttab_shared_gfn(d, gt, i)); /* Grant tables cannot be shared */ BUG_ON(SHARED_M2P(gmfn)); @@ -3147,7 +3147,7 @@ gnttab_get_status_frames(XEN_GUEST_HANDLE_PARAM(gnttab_get_status_frames_t) uop, for ( i = 0; i < op.nr_frames; i++ ) { - gmfn = gnttab_status_gmfn(d, gt, i); + gmfn = gfn_x(gnttab_status_gfn(d, gt, i)); if ( copy_to_guest_offset(op.frame_list, i, &gmfn, 1) ) op.status = GNTST_bad_virt_addr; } diff --git a/xen/include/asm-arm/grant_table.h b/xen/include/asm-arm/grant_table.h index 816e3c6d68..4c44b720f2 100644 --- a/xen/include/asm-arm/grant_table.h +++ b/xen/include/asm-arm/grant_table.h @@ -67,15 +67,15 @@ void gnttab_mark_dirty(struct domain *d, mfn_t mfn); } while ( 0 ) #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); \ }) -#define gnttab_shared_gmfn(d, t, i) \ - gfn_x(((i) >= nr_grant_frames(t)) ? INVALID_GFN : (t)->arch.shared_gfn[i]) +#define gnttab_shared_gfn(d, t, i) \ + (((i) >= nr_grant_frames(t)) ? INVALID_GFN : (t)->arch.shared_gfn[i]) -#define gnttab_status_gmfn(d, t, i) \ - gfn_x(((i) >= nr_status_frames(t)) ? INVALID_GFN : (t)->arch.status_gfn[i]) +#define gnttab_status_gfn(d, t, i) \ + (((i) >= nr_status_frames(t)) ? INVALID_GFN : (t)->arch.status_gfn[i]) #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 4b8c4f9160..8736d7286d 100644 --- a/xen/include/asm-x86/grant_table.h +++ b/xen/include/asm-x86/grant_table.h @@ -43,24 +43,20 @@ static inline int replace_grant_host_mapping(uint64_t addr, 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_ = (st) ? gnttab_status_mfn(gt, idx) \ - : gnttab_shared_mfn(gt, idx); \ - unsigned long gpfn_ = get_gpfn_from_mfn(mfn_); \ + mfn_t mfn_ = (st) ? gnttab_status_mfn(gt, idx) \ + : gnttab_shared_mfn(gt, idx); \ + unsigned long gpfn_ = get_gpfn_from_mfn(mfn_x(mfn_)); \ VALID_M2P(gpfn_) ? _gfn(gpfn_) : INVALID_GFN; \ }) -#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])) -#define gnttab_shared_gmfn(d, t, i) \ - (mfn_to_gmfn(d, gnttab_shared_mfn(t, i))) +#define gnttab_shared_gfn(d, t, i) _gfn(mfn_to_gfn(d, gnttab_shared_mfn(t, i))) +#define gnttab_status_mfn(t, i) _mfn(__virt_to_mfn((t)->status[i])) -#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) \ + _gfn(mfn_to_gfn(d, gnttab_status_mfn(t, i))) #define gnttab_mark_dirty(d, f) paging_mark_dirty((d), f)