From patchwork Mon Feb 18 11:35:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 158589 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2384244jaa; Mon, 18 Feb 2019 03:37:51 -0800 (PST) X-Google-Smtp-Source: AHgI3IbA2iQKyQstYp3x4qYGVUfwB16f3Cb+suNG/jcY5I694GWb7qrcigb6QG729CRkdo6BXAGK X-Received: by 2002:a25:d60e:: with SMTP id n14mr9597392ybg.71.1550489871770; Mon, 18 Feb 2019 03:37:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550489871; cv=none; d=google.com; s=arc-20160816; b=vtH7NE71mr2DiPFDwnrPX0EmauPL306mh3MjCZgziM4uJxcQDcJ3SGXoMfKgWB3m/0 R4SjEGAnUwCtXvWdZ6L/NBOp4kf8BO0S7Lx7i0zDkO9y01K8VNOWveK3bGlDZSzmpTUp 7qV1+5PLdsKfylJPkd4/uuIuXJlrRAT9QoRSHHw2obkA3reXRBMxcDq1VPY7RLRVWA5k k5IYwwCbiqVGTsfNCYljH9BJb7cZojkzZGtI4cOqzcOaZgnWKA095msfUZdHyBpZ2K4a DIovvaZiDKRFPeanLl9Gml+Dlf1KnEOyTiOy8EmyOXJFifCu1Tt36UEubv+/u0iDCqLh wcWw== 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=UKe+DanCXXqdkrAV1RP8zH7NUqTw+jZPiUXYLo0wWD8=; b=JeVXEtRV4Vkrw1psxQs+8f6vEIsf3qoMzYHkAVQC4sczhyNrwdlbUhiMGtWN4OMHbw XYj8zNreEDL24hEV26W/fSiJ7DcnyZYGY1qmSFbw5zKdebX71TXRrCXqpAp2iTx3uDr+ EfmQOzZ5osTzcGtvpihnEh0dTkJUAd56SZg7rId8WmUkEn81d+uBePc/m1/zAvDRHCyq 5oyf+dA2XwNTQqWN2lJRGzt6d/m/6kllaz83IhL1/G0sPnvElD2R20MfT9tBvzgacq4G rzmmVzZpdp0CIIAfG0vuAs5NAIyuDIHSN44Cozg2yYSu2miYrp4dFBTdDNuA1wodTlBP jwrA== 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 d185si8117919ywe.27.2019.02.18.03.37.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Feb 2019 03:37:51 -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 1gvhDW-0001wD-KJ; Mon, 18 Feb 2019 11:36:10 +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 1gvhDV-0001vX-OD for xen-devel@lists.xenproject.org; Mon, 18 Feb 2019 11:36:09 +0000 X-Inumbo-ID: 62a5acb6-3371-11e9-974e-0f99d71fa2e4 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 62a5acb6-3371-11e9-974e-0f99d71fa2e4; Mon, 18 Feb 2019 11:36:09 +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 D26A815AB; Mon, 18 Feb 2019 03:36:08 -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 160E03F73F; Mon, 18 Feb 2019 03:36:07 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 18 Feb 2019 11:35:52 +0000 Message-Id: <20190218113600.9540-2-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 1/9] xen/arm: Use mfn_to_pdx instead of pfn_to_pdx when possible 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: Julien Grall , sstabellini@kernel.org MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" mfn_to_pdx adds more safety than pfn_to_pdx. Replace all but on place in the Arm code to use the former. No functional changes. Signed-off-by: Julien Grall --- xen/arch/arm/mm.c | 2 +- xen/include/asm-arm/mm.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 01ae2cccc0..be5338bb4c 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -886,7 +886,7 @@ void __init setup_frametable_mappings(paddr_t ps, paddr_t pe) int i; #endif - frametable_base_pdx = pfn_to_pdx(ps >> PAGE_SHIFT); + frametable_base_pdx = mfn_to_pdx(maddr_to_mfn(ps)); /* Round up to 2M or 32M boundary, as appropriate. */ frametable_size = ROUNDUP(frametable_size, mapping_size); base_mfn = alloc_boot_pages(frametable_size >> PAGE_SHIFT, 32<<(20-12)); diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h index eafa26f56e..7b6aaf5e3f 100644 --- a/xen/include/asm-arm/mm.h +++ b/xen/include/asm-arm/mm.h @@ -225,7 +225,7 @@ static inline void __iomem *ioremap_wc(paddr_t start, size_t len) /* Convert between frame number and address formats. */ #define pfn_to_paddr(pfn) ((paddr_t)(pfn) << PAGE_SHIFT) #define paddr_to_pfn(pa) ((unsigned long)((pa) >> PAGE_SHIFT)) -#define paddr_to_pdx(pa) pfn_to_pdx(paddr_to_pfn(pa)) +#define paddr_to_pdx(pa) mfn_to_pdx(maddr_to_mfn(pa)) #define gfn_to_gaddr(gfn) pfn_to_paddr(gfn_x(gfn)) #define gaddr_to_gfn(ga) _gfn(paddr_to_pfn(ga)) #define mfn_to_maddr(mfn) pfn_to_paddr(mfn_x(mfn)) @@ -253,7 +253,7 @@ static inline void *maddr_to_virt(paddr_t ma) #else static inline void *maddr_to_virt(paddr_t ma) { - ASSERT(pfn_to_pdx(ma >> PAGE_SHIFT) < (DIRECTMAP_SIZE >> PAGE_SHIFT)); + ASSERT(mfn_to_pdx(maddr_to_mfn(ma)) < (DIRECTMAP_SIZE >> PAGE_SHIFT)); return (void *)(XENHEAP_VIRT_START - mfn_to_maddr(xenheap_mfn_start) + ((ma & ma_va_bottom_mask) | @@ -301,7 +301,7 @@ static inline struct page_info *virt_to_page(const void *v) ASSERT(va < xenheap_virt_end); pdx = (va - XENHEAP_VIRT_START) >> PAGE_SHIFT; - pdx += pfn_to_pdx(mfn_x(xenheap_mfn_start)); + pdx += mfn_to_pdx(xenheap_mfn_start); return frame_table + pdx - frametable_base_pdx; } From patchwork Mon Feb 18 11:35:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 158593 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2384407jaa; Mon, 18 Feb 2019 03:38:01 -0800 (PST) X-Google-Smtp-Source: AHgI3IaA9eDLu6DKv2hfiFx4PsPixED3z7Tt4byu5u4jtOSJ9R5Dc1rsHhsHU8f+Kj0ni1tOstj3 X-Received: by 2002:a25:4703:: with SMTP id u3mr18883128yba.49.1550489881884; Mon, 18 Feb 2019 03:38:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550489881; cv=none; d=google.com; s=arc-20160816; b=qbZlMBT+9akoRnqCnr/ylL7sb52MQ3KN6xVHm9WHwzi+uWTkrezj2P1NVOD09cXVhG U6T+AlQSnkhN5jE4hZciLidFl/01nG/G7HsUCICoxwvCa+qJ6JUHtZy4bxjiTCeqtliY H5zgJOKgpUyRyi3GS+WL0tdnw6XFlQ2LdcoEe86CETjqQr6X7czEWtpKgXGEav6hkzrn IHSadRsQv9VTYVfpnRzJZIOgtmXhUUvDqc83G5AFbStNBHoly5CSwhCbOKleAs5gFYJ4 8cYQIbEapCYSLVUUz7L0ra5YnX/U3bHOkFbEkJsGTS7hFCdyhpb1PBurcPbwxeFSUSat cgHQ== 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=6svcBUaUbFretAoTpx/A63mX6SsW78Bx1pkcu7EuS3A=; b=E4XPuZ0afQwlGjqUYPU33PeCDReMP0mz+clk/RvJdKFj6WJu63ZRI7exKcnyRz6PNz aQ8iyBfACbcPXT6ZnMGldD88KsvVB32dP9m7nFBzhQgL+S9GUBMmxibGJaVJyUQLko2T Tj0S08g3FD2kEM1rJV3a7d1BUqFIhWe3H1X8BgIkLMpQgD7w20mVCkgHml/PoPyOQIga YcZ/TJuUWS/xtqMkQNIuFw5dBnJHIbPFNmc2NWhgwnCuLv7sUdtQYhIYB70nk2HdHWSj 9Q36ba/BC+U0ZTFQR0PZxOsawEOTvnU6nb4S2V/kohE5T03id6ThpOmFH2BVOOOSapJE G3Lw== 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 z127si7400578ywb.337.2019.02.18.03.38.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Feb 2019 03:38:01 -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 1gvhDb-0001yh-3H; Mon, 18 Feb 2019 11:36:15 +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 1gvhDY-0001xf-UZ for xen-devel@lists.xenproject.org; Mon, 18 Feb 2019 11:36:12 +0000 X-Inumbo-ID: 648b0e7c-3371-11e9-8ab2-db931bc02096 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 648b0e7c-3371-11e9-8ab2-db931bc02096; Mon, 18 Feb 2019 11:36:12 +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 16E1E1650; Mon, 18 Feb 2019 03:36:12 -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 1C7E63F720; Mon, 18 Feb 2019 03:36:08 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 18 Feb 2019 11:35:53 +0000 Message-Id: <20190218113600.9540-3-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 2/9] xen/x86: Constify the parameter "d" in mfn_to_mfn 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 , Andrew Cooper , Julien Grall , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The parameter "d" holds the domain and is not modified by the function. So constify it. Signed-off-by: Julien Grall Reviewed-by: Jan Beulich --- xen/include/asm-x86/p2m.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h index 2095076556..b6852dc133 100644 --- a/xen/include/asm-x86/p2m.h +++ b/xen/include/asm-x86/p2m.h @@ -506,7 +506,7 @@ static inline struct page_info *get_page_from_gfn( } /* General conversion function from mfn to gfn */ -static inline unsigned long mfn_to_gfn(struct domain *d, mfn_t mfn) +static inline unsigned long mfn_to_gfn(const struct domain *d, mfn_t mfn) { if ( paging_mode_translate(d) ) return get_gpfn_from_mfn(mfn_x(mfn)); From patchwork Mon Feb 18 11:35:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 158592 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2384340jaa; Mon, 18 Feb 2019 03:37:57 -0800 (PST) X-Google-Smtp-Source: AHgI3IbNT6IiztMKcs7Dn1M5U9TXK8lh/f2JjQSZta9ou+ml4HFzQBCeUPKCdUxlj4MqflOWZrNF X-Received: by 2002:a25:4d02:: with SMTP id a2mr8343480ybb.90.1550489877518; Mon, 18 Feb 2019 03:37:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550489877; cv=none; d=google.com; s=arc-20160816; b=PG0Ob26Z9M/kxihgRmMVOhOfTHD8jzmM0dq4Vsm98TXI7821th+EHAlhh7AJ/DKQTK e/LWfyhn/ovgnD3uuleKUEp4qjFwV0A8DKSIGH1qL18xi8bO0HI+uga0h/UryB9OUODn iUqfk2IXX64S06jV2muLqkEyQU/ETxj9NhftcVGHmZbuyMcKG4Gk2rCdtTKeqVGF5e8H RSIG1u4ohYJDO12JjNId7EADk8Y2eDwEXQSJYptQc56wfVoB1dG7EXSfGHtaukeQGBLB JXZxkKCypiHxs2WivDayWhV1zQvQ8UpK5xHa3kaLR1y2hhuBCIxb2I1D6YyE5voWzEJb Tjeg== 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=xMIIpfnNk68CK+qbhJeZY/buOSpWJUy7X+0haeLc6W0=; b=eFEQ0jZAlCaCMPl12OlHNrDTtqMSWiLukDc0X5ovBrvkgn1gd/5BuJK60HEh4YploR J2LsYKNqG8u0D61d0Iyy1QHQZCCstv9rCT2dzldHHSCiDVsKOCgaEhq259bQo2pl8ZuZ hyKGfk96ZWrIs6bLvbXNgLSTYrAnIymF4cR2kf5NGnc3feHY6ftjfkESveC78JwXITHW ri0eZYLaCpj4wKxugsXC1fHF8q1iybTz47uzsj2mocUfuv/3MH5Ivm2DhJ5V7mUKiZm4 d9knjXkFe9yWIRFBS+S68lx5X8uscvL7Vh6YKpiXPXU/yF/PXNc2GPwKx1sqCRMk5Qeg kpIQ== 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 h8si7165289ywm.62.2019.02.18.03.37.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Feb 2019 03:37:57 -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 1gvhDm-00027f-1V; Mon, 18 Feb 2019 11:36: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.89) (envelope-from ) id 1gvhDk-000269-T9 for xen-devel@lists.xenproject.org; Mon, 18 Feb 2019 11:36:24 +0000 X-Inumbo-ID: 6a8be440-3371-11e9-8664-d3c7feba5192 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 6a8be440-3371-11e9-8664-d3c7feba5192; Mon, 18 Feb 2019 11:36:24 +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 161771688; Mon, 18 Feb 2019 03:36:22 -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 B15C93F73F; Mon, 18 Feb 2019 03:36:10 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 18 Feb 2019 11:35:54 +0000 Message-Id: <20190218113600.9540-4-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 3/9] xen/x86: Use mfn_to_gfn rather than mfn_to_gmfn 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 , Andrew Cooper , Julien Grall , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" mfn_to_gfn and mfn_to_gmfn are doing exactly the same except the former is using mfn_t. Furthermore, the naming of the former is more consistent with the current naming scheme (GFN/MFN). So use replace mfn_to_gmfn with mfn_to_gfn in x86 code. No functional changes. Signed-off-by: Julien Grall --- xen/arch/x86/domain.c | 2 +- xen/arch/x86/mm.c | 2 +- xen/arch/x86/pv/emul-priv-op.c | 4 ++-- xen/drivers/passthrough/x86/iommu.c | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 32dc4253ff..ab1f25f49d 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -714,7 +714,7 @@ int arch_domain_soft_reset(struct domain *d) ASSERT( owner == d ); mfn = page_to_mfn(page); - gfn = mfn_to_gmfn(d, mfn_x(mfn)); + gfn = mfn_to_gfn(d, mfn); /* * gfn == INVALID_GFN indicates that the shared_info page was never mapped diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 7ec5954b03..df6e5bdd31 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -2518,7 +2518,7 @@ int free_page_type(struct page_info *page, unsigned long type, ASSERT(!shadow_mode_refcounts(owner)); - gmfn = mfn_to_gmfn(owner, mfn_x(page_to_mfn(page))); + gmfn = mfn_to_gfn(owner, page_to_mfn(page)); if ( VALID_M2P(gmfn) ) shadow_remove_all_shadows(owner, _mfn(gmfn)); } diff --git a/xen/arch/x86/pv/emul-priv-op.c b/xen/arch/x86/pv/emul-priv-op.c index 942ece2ca0..0da1e29782 100644 --- a/xen/arch/x86/pv/emul-priv-op.c +++ b/xen/arch/x86/pv/emul-priv-op.c @@ -711,7 +711,7 @@ static int read_cr(unsigned int reg, unsigned long *val, if ( !is_pv_32bit_domain(currd) ) { mfn = pagetable_get_mfn(curr->arch.guest_table); - *val = xen_pfn_to_cr3(mfn_to_gmfn(currd, mfn_x(mfn))); + *val = xen_pfn_to_cr3(mfn_to_gfn(currd, mfn)); } else { @@ -720,7 +720,7 @@ static int read_cr(unsigned int reg, unsigned long *val, mfn = l4e_get_mfn(*pl4e); unmap_domain_page(pl4e); - *val = compat_pfn_to_cr3(mfn_to_gmfn(currd, mfn_x(mfn))); + *val = compat_pfn_to_cr3(mfn_to_gfn(currd, mfn)); } /* PTs should not be shared */ BUG_ON(page_get_owner(mfn_to_page(mfn)) == dom_cow); diff --git a/xen/drivers/passthrough/x86/iommu.c b/xen/drivers/passthrough/x86/iommu.c index a88ef9b189..2b1915548a 100644 --- a/xen/drivers/passthrough/x86/iommu.c +++ b/xen/drivers/passthrough/x86/iommu.c @@ -59,15 +59,15 @@ int arch_iommu_populate_page_table(struct domain *d) if ( is_hvm_domain(d) || (page->u.inuse.type_info & PGT_type_mask) == PGT_writable_page ) { - unsigned long mfn = mfn_x(page_to_mfn(page)); - unsigned long gfn = mfn_to_gmfn(d, mfn); + mfn_t mfn = page_to_mfn(page); + unsigned long gfn = mfn_to_gfn(d, mfn); unsigned int flush_flags = 0; if ( gfn != gfn_x(INVALID_GFN) ) { ASSERT(!(gfn >> DEFAULT_DOMAIN_ADDRESS_WIDTH)); BUG_ON(SHARED_M2P(gfn)); - rc = iommu_map(d, _dfn(gfn), _mfn(mfn), PAGE_ORDER_4K, + rc = iommu_map(d, _dfn(gfn), mfn, PAGE_ORDER_4K, IOMMUF_readable | IOMMUF_writable, &flush_flags); } 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) From patchwork Mon Feb 18 11:35:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 158595 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2384481jaa; Mon, 18 Feb 2019 03:38:08 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ9b5z1DtpcjoO9B9QO7BLvtCbb3Dz8KbmSf3/7O49i+HLMbNYmYTD1t1whnY4omxEeUAKA X-Received: by 2002:a25:b9c1:: with SMTP id y1mr18270451ybj.57.1550489888481; Mon, 18 Feb 2019 03:38:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550489888; cv=none; d=google.com; s=arc-20160816; b=WG7KW0a+CmJHVQRlSFaPt0UkYwUZ4XX+MDq7d1yFm3rQA2m6L/EDYFR4E4y6WfEBLT H64g6/azV2AEh/BA8TuQXzZOgHIZjbHCHq/iUaJMwvikq5u/qs3tu7pRqpRy/WvPcXEz Nvtf314fjf9mU7tbgGGa+M8cNEs5l5zanjDIfrbaeLTW7+Hsj3zT4Ve+9tAx+HapUXl0 XXx6RS9zxYqy+CtR7mpbnEtarYhRIBskqaCpxOu5FNPxiqRh794l3g7K+LPem7QQxU86 9dMakOHtH3IqvAPJdPtnrTJQWjDPCis5AQXjYs1p/e3JvDkZkrAAAFbiRoYS09m9sMNz uXnA== 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=R+k87lOV4Bu5m4XN2CM1ClsI2Mh1Jfh22kJT58FMd20=; b=g72Z+ijkVHDcQFcvnni47Wi9RCZrlrYJSIBAlK5YzCsNezr4XV6/z3cN4ekXhmgzkG iICguldHMKsVlMCOjiDaeMgfoj+b2Q8w5wosizlyNpol17ZXvTuBRcDse5sMECwsmGdW fDJmA9SKIxwvJx0/9p0DQaTXCAq3Xvd4u7AibaIhFy6U+g0oyckOK3DlTBs9iWAwxJtY ZsWlrDq4e0AEq0pug4Z54lXtBugv/aLSEkA2sqRzSXv0Ox8TmHqTwKiY6v4I5iviqZ0D OnlmpicWwbxtokIpKuGhwKvLW0nxXBhyKR2BWgBKBeNxYo2ghbxvBqOBI4zEVnamh2Ee xOoQ== 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 u5si7457711ywd.303.2019.02.18.03.38.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Feb 2019 03:38:08 -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 1gvhDj-00024b-Q7; Mon, 18 Feb 2019 11:36:23 +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 1gvhDi-00023l-MJ for xen-devel@lists.xenproject.org; Mon, 18 Feb 2019 11:36:22 +0000 X-Inumbo-ID: 6a321c94-3371-11e9-a898-0760cb0a41f5 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 6a321c94-3371-11e9-a898-0760cb0a41f5; Mon, 18 Feb 2019 11:36:21 +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 94AEA1684; Mon, 18 Feb 2019 03:36:21 -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 801EF3F720; Mon, 18 Feb 2019 03:36:14 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 18 Feb 2019 11:35:56 +0000 Message-Id: <20190218113600.9540-6-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 5/9] xen: Convert hotplug page function to use typesafe MFN 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" Convert online_page, offline_page and query_page_offline to use typesafe MFN. No functional changes. Signed-off-by: Julien Grall Acked-by: Jan Beulich --- xen/arch/x86/cpu/mcheck/mcaction.c | 18 ++++++++++-------- xen/common/page_alloc.c | 24 ++++++++++++------------ xen/common/sysctl.c | 14 +++++++------- xen/include/xen/mm.h | 6 +++--- 4 files changed, 32 insertions(+), 30 deletions(-) diff --git a/xen/arch/x86/cpu/mcheck/mcaction.c b/xen/arch/x86/cpu/mcheck/mcaction.c index e42267414e..69332fb84d 100644 --- a/xen/arch/x86/cpu/mcheck/mcaction.c +++ b/xen/arch/x86/cpu/mcheck/mcaction.c @@ -6,7 +6,7 @@ static struct mcinfo_recovery * mci_action_add_pageoffline(int bank, struct mc_info *mi, - uint64_t mfn, uint32_t status) + mfn_t mfn, uint32_t status) { struct mcinfo_recovery *rec; @@ -22,7 +22,7 @@ mci_action_add_pageoffline(int bank, struct mc_info *mi, rec->mc_bank = bank; rec->action_types = MC_ACTION_PAGE_OFFLINE; - rec->action_info.page_retire.mfn = mfn; + rec->action_info.page_retire.mfn = mfn_x(mfn); rec->action_info.page_retire.status = status; return rec; } @@ -42,7 +42,8 @@ mc_memerr_dhandler(struct mca_binfo *binfo, struct mcinfo_bank *bank = binfo->mib; struct mcinfo_global *global = binfo->mig; struct domain *d; - unsigned long mfn, gfn; + mfn_t mfn; + unsigned long gfn; uint32_t status; int vmce_vcpuid; unsigned int mc_vcpuid; @@ -54,11 +55,12 @@ mc_memerr_dhandler(struct mca_binfo *binfo, return; } - mfn = bank->mc_addr >> PAGE_SHIFT; + mfn = maddr_to_mfn(bank->mc_addr); if ( offline_page(mfn, 1, &status) ) { dprintk(XENLOG_WARNING, - "Failed to offline page %lx for MCE error\n", mfn); + "Failed to offline page %"PRI_mfn" for MCE error\n", + mfn_x(mfn)); return; } @@ -89,10 +91,10 @@ mc_memerr_dhandler(struct mca_binfo *binfo, ASSERT(d); gfn = get_gpfn_from_mfn((bank->mc_addr) >> PAGE_SHIFT); - if ( unmmap_broken_page(d, _mfn(mfn), gfn) ) + if ( unmmap_broken_page(d, mfn, gfn) ) { - printk("Unmap broken memory %lx for DOM%d failed\n", - mfn, d->domain_id); + printk("Unmap broken memory %"PRI_mfn" for DOM%d failed\n", + mfn_x(mfn), d->domain_id); goto vmce_failed; } diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index f71d3bb7a1..5684a13557 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -1568,23 +1568,23 @@ static int reserve_heap_page(struct page_info *pg) } -int offline_page(unsigned long mfn, int broken, uint32_t *status) +int offline_page(mfn_t mfn, int broken, uint32_t *status) { unsigned long old_info = 0; struct domain *owner; struct page_info *pg; - if ( !mfn_valid(_mfn(mfn)) ) + if ( !mfn_valid(mfn) ) { dprintk(XENLOG_WARNING, - "try to offline page out of range %lx\n", mfn); + "try to offline page out of range %"PRI_mfn"\n", mfn_x(mfn)); return -EINVAL; } *status = 0; - pg = mfn_to_page(_mfn(mfn)); + pg = mfn_to_page(mfn); - if ( is_xen_fixed_mfn(mfn) ) + if ( is_xen_fixed_mfn(mfn_x(mfn)) ) { *status = PG_OFFLINE_XENPAGE | PG_OFFLINE_FAILED | (DOMID_XEN << PG_OFFLINE_OWNER_SHIFT); @@ -1595,7 +1595,7 @@ int offline_page(unsigned long mfn, int broken, uint32_t *status) * N.B. xen's txt in x86_64 is marked reserved and handled already. * Also kexec range is reserved. */ - if ( !page_is_ram_type(mfn, RAM_TYPE_CONVENTIONAL) ) + if ( !page_is_ram_type(mfn_x(mfn), RAM_TYPE_CONVENTIONAL) ) { *status = PG_OFFLINE_FAILED | PG_OFFLINE_NOT_CONV_RAM; return -EINVAL; @@ -1677,19 +1677,19 @@ int offline_page(unsigned long mfn, int broken, uint32_t *status) * The caller should make sure end_pfn <= max_page, * if not, expand_pages() should be called prior to online_page(). */ -unsigned int online_page(unsigned long mfn, uint32_t *status) +unsigned int online_page(mfn_t mfn, uint32_t *status) { unsigned long x, nx, y; struct page_info *pg; int ret; - if ( !mfn_valid(_mfn(mfn)) ) + if ( !mfn_valid(mfn) ) { dprintk(XENLOG_WARNING, "call expand_pages() first\n"); return -EINVAL; } - pg = mfn_to_page(_mfn(mfn)); + pg = mfn_to_page(mfn); spin_lock(&heap_lock); @@ -1730,11 +1730,11 @@ unsigned int online_page(unsigned long mfn, uint32_t *status) return ret; } -int query_page_offline(unsigned long mfn, uint32_t *status) +int query_page_offline(mfn_t mfn, uint32_t *status) { struct page_info *pg; - if ( !mfn_valid(_mfn(mfn)) || !page_is_ram_type(mfn, RAM_TYPE_CONVENTIONAL) ) + if ( !mfn_valid(mfn) || !page_is_ram_type(mfn_x(mfn), RAM_TYPE_CONVENTIONAL) ) { dprintk(XENLOG_WARNING, "call expand_pages() first\n"); return -EINVAL; @@ -1743,7 +1743,7 @@ int query_page_offline(unsigned long mfn, uint32_t *status) *status = 0; spin_lock(&heap_lock); - pg = mfn_to_page(_mfn(mfn)); + pg = mfn_to_page(mfn); if ( page_state_is(pg, offlining) ) *status |= PG_OFFLINE_STATUS_OFFLINE_PENDING; diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c index c0aa6bde4e..ab161793e5 100644 --- a/xen/common/sysctl.c +++ b/xen/common/sysctl.c @@ -186,7 +186,7 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) case XEN_SYSCTL_page_offline_op: { uint32_t *status, *ptr; - unsigned long pfn; + mfn_t mfn; ret = xsm_page_offline(XSM_HOOK, op->u.page_offline.cmd); if ( ret ) @@ -205,21 +205,21 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) memset(status, PG_OFFLINE_INVALID, sizeof(uint32_t) * (op->u.page_offline.end - op->u.page_offline.start + 1)); - for ( pfn = op->u.page_offline.start; - pfn <= op->u.page_offline.end; - pfn ++ ) + for ( mfn = _mfn(op->u.page_offline.start); + mfn_x(mfn) <= op->u.page_offline.end; + mfn = mfn_add(mfn, 1) ) { switch ( op->u.page_offline.cmd ) { /* Shall revert her if failed, or leave caller do it? */ case sysctl_page_offline: - ret = offline_page(pfn, 0, ptr++); + ret = offline_page(mfn, 0, ptr++); break; case sysctl_page_online: - ret = online_page(pfn, ptr++); + ret = online_page(mfn, ptr++); break; case sysctl_query_page_offline: - ret = query_page_offline(pfn, ptr++); + ret = query_page_offline(mfn, ptr++); break; default: ret = -EINVAL; diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index e971147234..3ba7168cc9 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -206,9 +206,9 @@ unsigned long avail_domheap_pages(void); unsigned long avail_node_heap_pages(unsigned int); #define alloc_domheap_page(d,f) (alloc_domheap_pages(d,0,f)) #define free_domheap_page(p) (free_domheap_pages(p,0)) -unsigned int online_page(unsigned long mfn, uint32_t *status); -int offline_page(unsigned long mfn, int broken, uint32_t *status); -int query_page_offline(unsigned long mfn, uint32_t *status); +unsigned int online_page(mfn_t mfn, uint32_t *status); +int offline_page(mfn_t mfn, int broken, uint32_t *status); +int query_page_offline(mfn_t mfn, uint32_t *status); unsigned long total_free_pages(void); void heap_init_late(void); From patchwork Mon Feb 18 11:35:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 158594 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2384473jaa; Mon, 18 Feb 2019 03:38:08 -0800 (PST) X-Google-Smtp-Source: AHgI3Ian5bKmo1/V4DNa/5HFuwuGzcfJBBgN2P/qZwS4nYRQeJwmD/85NK/N34RWO0QSePA4hLiY X-Received: by 2002:a81:4ccb:: with SMTP id z194mr18484698ywa.65.1550489888152; Mon, 18 Feb 2019 03:38:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550489888; cv=none; d=google.com; s=arc-20160816; b=MkdYebk1Xp0xfR6GdFLqD8NodV/XE5lZWZ897cDN/m2beeYDRkqaruNSky+TenZRg3 5ggucmSFGdYHgZE4g7hwq5cgORTtgJRDuYX65Fwh7aMuywyQ2bTpL8YH5mQvL3zMQULX aT4sLIaBJaRyupveOjfzH9M/eBxVf2vbpnYb7ZVYew4+W7UbNMxcy+8K6Q/o3MWaERBR 7lmilB1WvZtxZtSw5X8r9TmFhXPo5pCvdgkuqK3M0yEYXKrynW9QhLnSrkzC4aYDMNIm BcgdyTjIeqbluJIEZmWR7mDzmRUv7NXMNEo/fpCdxn/g02JIajAiEcLRKG+Uy895+ev1 2fXg== 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=G6ztCpdYXUQL7uvpm+BkZOVBrzvW+nZWDRDkv8d+sGA=; b=PIIWKyb0g2H2/sTYi0EBUYljkkgZep0B/LXTMLrpZDnzhinqnf8LDSeH2NJ2rRAis2 Z0riP2iwGJbPiA7PvLb1+r4+vaZm7KFGV4zXXDWG5Zb/kKYJeDOKB3T9pdF/f8PDD4Km StqlolSNFXWQ7D21TPr2nQk6KBRrgiDeFQi6ZUWuq4Jy+CWf3RXGunQAo2I/RZ9maoYA dj2tz4asSVMrdIKd3pE0zkRktACj40k99AoFbQryk4lw9GH0sVftAwK8YmVX4vGw3c1p j9fvIn05f7BvmsCPm0h8hGJG0LSeU6vRQ1RkMJG6/+JonEPVFKYrNqkvJnfbFQjuDOXh e9qQ== 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 q6si7510773ywq.199.2019.02.18.03.38.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Feb 2019 03:38:07 -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 1gvhDl-00027C-Mf; Mon, 18 Feb 2019 11:36:25 +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 1gvhDk-000268-T0 for xen-devel@lists.xenproject.org; Mon, 18 Feb 2019 11:36:24 +0000 X-Inumbo-ID: 6baf4484-3371-11e9-a443-affc41b004c2 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 6baf4484-3371-11e9-a443-affc41b004c2; Mon, 18 Feb 2019 11:36:24 +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 1A1CC16A3; Mon, 18 Feb 2019 03:36:24 -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 D3B303F915; Mon, 18 Feb 2019 03:36:16 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 18 Feb 2019 11:35:57 +0000 Message-Id: <20190218113600.9540-7-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 6/9] xen: Convert is_xen_fixed_mfn to use typesafe MFN 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 , Shane Wang , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , Andrew Cooper , Gang Wei , =?utf-8?q?Roger_Pau_Monn=C3=A9?= MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" No functional changes. Signed-off-by: Julien Grall Reviewed-by: Jan Beulich Acked-by: Stefano Stabellini --- xen/arch/x86/tboot.c | 2 +- xen/common/page_alloc.c | 2 +- xen/include/asm-arm/mm.h | 4 ++-- xen/include/asm-x86/mm.h | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/tboot.c b/xen/arch/x86/tboot.c index f3fdee4d39..30d159cc62 100644 --- a/xen/arch/x86/tboot.c +++ b/xen/arch/x86/tboot.c @@ -280,7 +280,7 @@ static void tboot_gen_xenheap_integrity(const uint8_t key[TB_KEY_SIZE], if ( !mfn_valid(_mfn(mfn)) ) continue; - if ( is_xen_fixed_mfn(mfn) ) + if ( is_xen_fixed_mfn(_mfn(mfn)) ) continue; /* skip Xen */ if ( (mfn >= PFN_DOWN(g_tboot_shared->tboot_base - 3 * PAGE_SIZE)) && (mfn < PFN_UP(g_tboot_shared->tboot_base diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 5684a13557..5de3686d85 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -1584,7 +1584,7 @@ int offline_page(mfn_t mfn, int broken, uint32_t *status) *status = 0; pg = mfn_to_page(mfn); - if ( is_xen_fixed_mfn(mfn_x(mfn)) ) + if ( is_xen_fixed_mfn(mfn) ) { *status = PG_OFFLINE_XENPAGE | PG_OFFLINE_FAILED | (DOMID_XEN << PG_OFFLINE_OWNER_SHIFT); diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h index 7b6aaf5e3f..b56018aace 100644 --- a/xen/include/asm-arm/mm.h +++ b/xen/include/asm-arm/mm.h @@ -151,8 +151,8 @@ extern vaddr_t xenheap_virt_start; #endif #define is_xen_fixed_mfn(mfn) \ - ((pfn_to_paddr(mfn) >= virt_to_maddr(&_start)) && \ - (pfn_to_paddr(mfn) <= virt_to_maddr(&_end))) + ((mfn_to_maddr(mfn) >= virt_to_maddr(&_start)) && \ + (mfn_to_maddr(mfn) <= virt_to_maddr(&_end))) #define page_get_owner(_p) (_p)->v.inuse.domain #define page_set_owner(_p,_d) ((_p)->v.inuse.domain = (_d)) diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h index 6faa563167..f124f57964 100644 --- a/xen/include/asm-x86/mm.h +++ b/xen/include/asm-x86/mm.h @@ -280,8 +280,8 @@ struct page_info #define is_xen_heap_mfn(mfn) \ (__mfn_valid(mfn) && is_xen_heap_page(mfn_to_page(_mfn(mfn)))) #define is_xen_fixed_mfn(mfn) \ - ((((mfn) << PAGE_SHIFT) >= __pa(&_stext)) && \ - (((mfn) << PAGE_SHIFT) <= __pa(&__2M_rwdata_end))) + (((mfn_to_maddr(mfn)) >= __pa(&_stext)) && \ + ((mfn_to_maddr(mfn)) <= __pa(&__2M_rwdata_end))) #define PRtype_info "016lx"/* should only be used for printk's */ From patchwork Mon Feb 18 11:35:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 158591 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2384330jaa; Mon, 18 Feb 2019 03:37:56 -0800 (PST) X-Google-Smtp-Source: AHgI3IanqfXocsufmlcriAMLhETyqUxj4OHsAqNaIoUCtIAGY03Uv4AhSmWvDzsXs4cz9ZHN/r7r X-Received: by 2002:a25:dc49:: with SMTP id y70mr18892453ybe.288.1550489876916; 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=Hq1H63jF5PIyQuhp3hBvoJe0jQdG6HSxRHfaMyHBhzM02O9RwwCrA92q8lkoYjy5+L YQOI7wOCTwW0lQmZ9BdWloPC8/QVVb+SnNeqUpT1jh7wsQjjotX3/Ng3/D6m9MdsNp4M mFG8dWPkJ95rulFgzcRmBER/JgKgNRcy0jW8FbNO4lbez+OZS09CnW1dziyowXzb7b1k MZ81J8T7RNZfGEuDTZtSiR5PL8qyV2uUap8Et4sD6SQoO/fzaqf9xGUSYk34MratQCTJ 6cKUzcXqd9J/zgu35ynwEN6b2YS1hi4EE9VC82aQEo4oaATskD7SwOjAmiCzatATay6w /Q+A== 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=0RWDfisMTeSRsazntKGGt7YCAsaRGZUZzFIZMvZeK34=; b=a3dpFPmVBuRWYw/aPfNr/FpGws9NjqTnVlGqox6w7b3oAZdUyI8eoVLANfr5WlDef4 kSXaIBLOiRHAlM00wecQ6G8FHa4rGnQYOpArpmkGWkB/6XRwe1QXsafP/IIG3ohserWU B+XYdzb+g70FpHdORF3WC9LRt6MNQtSPctGsiOpBBRVqeMfF26Q6aodxf8TPnAVVxQ8U NNtJIJpvPT4cSH6u7PEpawe+qu6sqaUYeDPRw3jPFrZmzlhbv+/8/wIwL9J5Qt+QENMw CFZ7wkC8Csi6XC0e9qudhrGoFE3uoJz1+KX5EZNWr99TjVP8QivM+uvaiUzIzkRPhavG swHA== 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 z128si2409796ywd.210.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 1gvhDk-000250-5S; Mon, 18 Feb 2019 11:36:24 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1gvhDi-00023m-M9 for xen-devel@lists.xenproject.org; Mon, 18 Feb 2019 11:36:22 +0000 X-Inumbo-ID: 6a006eb2-3371-11e9-bc90-bc764e045a96 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 6a006eb2-3371-11e9-bc90-bc764e045a96; Mon, 18 Feb 2019 11:36:21 +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 475E41650; Mon, 18 Feb 2019 03:36:21 -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 565FE3F9E0; Mon, 18 Feb 2019 03:36:19 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 18 Feb 2019 11:35:58 +0000 Message-Id: <20190218113600.9540-8-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 7/9] xen: Convert is_xen_heap_mfn to use typesafe MFN 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. Signed-off-by: Julien Grall Reviewed-by: Jan Beulich Acked-by: Stefano Stabellini --- xen/arch/x86/mm.c | 9 +++++---- xen/arch/x86/mm/p2m.c | 2 +- xen/arch/x86/mm/shadow/multi.c | 2 +- xen/common/page_alloc.c | 4 ++-- xen/include/asm-arm/mm.h | 8 ++++---- xen/include/asm-x86/mm.h | 2 +- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index df6e5bdd31..a1cd2fb421 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -4300,7 +4300,8 @@ int xenmem_add_to_physmap_one( { struct page_info *page = NULL; unsigned long gfn = 0; /* gcc ... */ - unsigned long prev_mfn, old_gpfn; + mfn_t prev_mfn; + unsigned long old_gpfn; int rc = 0; mfn_t mfn = INVALID_MFN; p2m_type_t p2mt; @@ -4349,12 +4350,12 @@ int xenmem_add_to_physmap_one( } /* Remove previously mapped page if it was present. */ - prev_mfn = mfn_x(get_gfn(d, gfn_x(gpfn), &p2mt)); - if ( mfn_valid(_mfn(prev_mfn)) ) + prev_mfn = get_gfn(d, gfn_x(gpfn), &p2mt); + if ( mfn_valid(prev_mfn) ) { if ( is_xen_heap_mfn(prev_mfn) ) /* Xen heap frames are simply unhooked from this phys slot. */ - rc = guest_physmap_remove_page(d, gpfn, _mfn(prev_mfn), PAGE_ORDER_4K); + rc = guest_physmap_remove_page(d, gpfn, prev_mfn, PAGE_ORDER_4K); else /* Normal domain memory is freed, to avoid leaking memory. */ rc = guest_remove_page(d, gfn_x(gpfn)); diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index d14ce57dd5..40fed111b9 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -2910,7 +2910,7 @@ int p2m_add_foreign(struct domain *tdom, unsigned long fgfn, prev_mfn = get_gfn(tdom, gpfn, &p2mt_prev); if ( mfn_valid(prev_mfn) ) { - if ( is_xen_heap_mfn(mfn_x(prev_mfn)) ) + if ( is_xen_heap_mfn(prev_mfn) ) /* Xen heap frames are simply unhooked from this phys slot */ rc = guest_physmap_remove_page(tdom, _gfn(gpfn), prev_mfn, 0); else diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c index 7e9cbc69be..2d25e356d3 100644 --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -602,7 +602,7 @@ _sh_propagate(struct vcpu *v, * caching attributes in the shadows to match what was asked for. */ if ( (level == 1) && is_hvm_domain(d) && - !is_xen_heap_mfn(mfn_x(target_mfn)) ) + !is_xen_heap_mfn(target_mfn) ) { int type; diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 5de3686d85..e43c98d5cb 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -2121,9 +2121,9 @@ void init_xenheap_pages(paddr_t ps, paddr_t pe) * Yuk! Ensure there is a one-page buffer between Xen and Dom zones, to * prevent merging of power-of-two blocks across the zone boundary. */ - if ( ps && !is_xen_heap_mfn(paddr_to_pfn(ps)-1) ) + if ( ps && !is_xen_heap_mfn(_mfn(paddr_to_pfn(ps)-1)) ) ps += PAGE_SIZE; - if ( !is_xen_heap_mfn(paddr_to_pfn(pe)) ) + if ( !is_xen_heap_mfn(maddr_to_mfn(pe)) ) pe -= PAGE_SIZE; memguard_guard_range(maddr_to_virt(ps), pe - ps); diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h index b56018aace..a9c8352b94 100644 --- a/xen/include/asm-arm/mm.h +++ b/xen/include/asm-arm/mm.h @@ -138,16 +138,16 @@ extern vaddr_t xenheap_virt_start; #endif #ifdef CONFIG_ARM_32 -#define is_xen_heap_page(page) is_xen_heap_mfn(mfn_x(page_to_mfn(page))) +#define is_xen_heap_page(page) is_xen_heap_mfn(page_to_mfn(page)) #define is_xen_heap_mfn(mfn) ({ \ - unsigned long mfn_ = (mfn); \ + unsigned long mfn_ = mfn_x(mfn); \ (mfn_ >= mfn_x(xenheap_mfn_start) && \ mfn_ < mfn_x(xenheap_mfn_end)); \ }) #else #define is_xen_heap_page(page) ((page)->count_info & PGC_xen_heap) #define is_xen_heap_mfn(mfn) \ - (mfn_valid(_mfn(mfn)) && is_xen_heap_page(mfn_to_page(_mfn(mfn)))) + (mfn_valid(mfn) && is_xen_heap_page(mfn_to_page(mfn))) #endif #define is_xen_fixed_mfn(mfn) \ @@ -246,7 +246,7 @@ static inline paddr_t __virt_to_maddr(vaddr_t va) #ifdef CONFIG_ARM_32 static inline void *maddr_to_virt(paddr_t ma) { - ASSERT(is_xen_heap_mfn(ma >> PAGE_SHIFT)); + ASSERT(is_xen_heap_mfn(maddr_to_mfn(ma))); ma -= mfn_to_maddr(xenheap_mfn_start); return (void *)(unsigned long) ma + XENHEAP_VIRT_START; } diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h index f124f57964..1ca4154382 100644 --- a/xen/include/asm-x86/mm.h +++ b/xen/include/asm-x86/mm.h @@ -278,7 +278,7 @@ struct page_info #define is_xen_heap_page(page) ((page)->count_info & PGC_xen_heap) #define is_xen_heap_mfn(mfn) \ - (__mfn_valid(mfn) && is_xen_heap_page(mfn_to_page(_mfn(mfn)))) + (__mfn_valid(mfn_x(mfn)) && is_xen_heap_page(mfn_to_page(mfn))) #define is_xen_fixed_mfn(mfn) \ (((mfn_to_maddr(mfn)) >= __pa(&_stext)) && \ ((mfn_to_maddr(mfn)) <= __pa(&__2M_rwdata_end))) From patchwork Mon Feb 18 11:35:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 158597 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2384597jaa; Mon, 18 Feb 2019 03:38:16 -0800 (PST) X-Google-Smtp-Source: AHgI3Ia7UHpNFhjLbBGIjJXPqT40PFCcf0ifHUjiO31cd75YrI+tiuiCdPlnr0yQxc2U1RJWh9Kc X-Received: by 2002:a25:e68d:: with SMTP id d135mr10524475ybh.265.1550489896085; Mon, 18 Feb 2019 03:38:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550489896; cv=none; d=google.com; s=arc-20160816; b=MVeNAE90af5A6xm6UPyvwNL24CYC1L6IwCrxdc0st7ZBAcVaVhGmVRJlctCACv1Cz+ 5Ymv/4qq1sS/ESMC9XSi7Ll+N34yPe4zxjO4ueHxk9KPpVi9jy9ZqV87Mm6yCqGE1r2W d+neQiG0syY+0eOWlwQkcz/slxEjc7glZOp448ZkzZJoN9E6P9uKda4oH3cTKm5DUsJm XIhkqtKTykfWr/0nS6Gd8qT8WPwMQ1mTxam6qK0sZQiWsKKeeCzz22HkzFpRmfkt+DZb GHuf24tISOD3jn9AnSVKrrfGHfTlPiwcsBPUylRzf0JCLk0svmk4gnxBFs/5XLolUJmS af6Q== 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=U8NpYj3ypCXYCe/dq5x6vYTGxfoioiChBycIe3b+uec=; b=C4s32DuHXCQW7xQYO6EVMBXAU5H2nPtZnNV4Frl1GQ61NVo+QolYKXwEEYB5vIc2y4 orSRBdKJ1atcq9eVwb0Urzd+zeGmCng2wABtIKOuLSsQfzhPHbBu7makuTs8LdSXuY1P mn5GmGOhRx96xpXZsrynCU2frDCmB1DbeUkEMnGCHb1guAyLlI07d3qsfUvdHMFo/RFc ED5mSA8KbMun8rNaWMuNetwkzS9I385KHCbv7KFcm1g7ddRyiU1WaSUKuUCnVShK1fPJ XPHkiK1UkEhic4aTTBxZrVPUAeQ5J/bihRwnAClRYQbaNKsvFbH0D3s+YvbatRsgVvlu 6SCg== 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 v199si7405165ybv.44.2019.02.18.03.38.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Feb 2019 03:38:16 -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 1gvhDv-0002GQ-Np; Mon, 18 Feb 2019 11:36:35 +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 1gvhDu-0002Fj-Tv for xen-devel@lists.xenproject.org; Mon, 18 Feb 2019 11:36:34 +0000 X-Inumbo-ID: 7173408c-3371-11e9-b5c8-fbafdf789c1c Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 7173408c-3371-11e9-b5c8-fbafdf789c1c; Mon, 18 Feb 2019 11:36:34 +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 C01D280D; Mon, 18 Feb 2019 03:36:33 -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 864723F9E0; Mon, 18 Feb 2019 03:36:21 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 18 Feb 2019 11:35:59 +0000 Message-Id: <20190218113600.9540-9-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 8/9] xen: Introduce HAS_M2P config and use to protect mfn_to_gmfn call 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 , oleksandr_tyshchenko@epam.com, Julien Grall , Jan Beulich , andrii_anisov@epam.com, =?utf-8?q?Roger_Pau_Monn=C3=A9?= MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" 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 3 callers: - iommu_hwdom_init: mfn_to_gmfn is used for creating IOMMU page-tables when the P2M is not shared with the IOMMU. No issues so far as Arm does not yet support non-shared P2M case. - memory_exchange: Arm cannot not use it because steal_page is not implemented. - 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 significant amount of VA address (very tough on 32-bit) that can hardly be justified with the current use of mfn_to_gmfn. - iommu_hwdom_init: mfn_to_gmfn is used because the creating of the IOMMU page-tables is delayed until the first device is assigned. In the embedded case, we will known in most of the times what devices are assigned during the domain creation. So it is possible to take to enable the IOMMU from start. See [1] for the patch. - 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. - iommu_hwdom_init: For now, we require the M2P support when the IOMMU is not sharing the P2M. - memory_exchange: The hypercall is marked as not supported when the M2P does not exist. - getdomaininfo: A new helper is introduced to wrap the call to mfn_to_gfn/mfn_to_gmfn. For Arm, it returns an invalid GFN so the mapping will fail. [1] https://patchwork.kernel.org/patch/9719913/ Signed-off-by Julien Grall --- Cc: oleksandr_tyshchenko@epam.com Cc: andrii_anisov@epam.com --- xen/arch/x86/Kconfig | 1 + xen/common/Kconfig | 3 +++ xen/common/domctl.c | 2 +- xen/common/memory.c | 4 ++++ xen/drivers/passthrough/iommu.c | 6 +++++- xen/include/asm-arm/domain.h | 5 +++++ xen/include/xen/domain.h | 9 +++++++++ 7 files changed, 28 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig index 5c2d1070b6..1892bc3895 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_MEM_SHARING select HAS_NS16550 diff --git a/xen/common/Kconfig b/xen/common/Kconfig index 04384628bb..65c0282e90 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -52,6 +52,9 @@ config HAS_GDBSX config HAS_IOPORTS bool +config HAS_M2P + bool + config NEEDS_LIBELF bool diff --git a/xen/common/domctl.c b/xen/common/domctl.c index d08b6274e2..ce157e11fe 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -205,7 +205,7 @@ void getdomaininfo(struct domain *d, struct xen_domctl_getdomaininfo *info) info->outstanding_pages = d->outstanding_pages; info->shr_pages = atomic_read(&d->shr_pages); info->paged_pages = atomic_read(&d->paged_pages); - info->shared_info_frame = mfn_to_gmfn(d, virt_to_mfn(d->shared_info)); + info->shared_info_frame = gfn_x(domain_shared_info_gfn(d)); BUG_ON(SHARED_M2P(info->shared_info_frame)); info->cpupool = d->cpupool ? d->cpupool->cpupool_id : CPUPOOLID_NONE; diff --git a/xen/common/memory.c b/xen/common/memory.c index b6cf09585c..6cbbe4c3c8 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -510,6 +510,7 @@ static bool propagate_node(unsigned int xmf, unsigned int *memflags) return true; } +#ifdef CONFIG_M2P static long memory_exchange(XEN_GUEST_HANDLE_PARAM(xen_memory_exchange_t) arg) { struct xen_memory_exchange exch; @@ -802,6 +803,7 @@ static long memory_exchange(XEN_GUEST_HANDLE_PARAM(xen_memory_exchange_t) arg) rc = -EFAULT; return rc; } +#endif int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp, unsigned int start) @@ -1233,12 +1235,14 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg) break; +#ifdef CONFIG_M2P case XENMEM_exchange: if ( unlikely(start_extent) ) return -EINVAL; rc = memory_exchange(guest_handle_cast(arg, xen_memory_exchange_t)); break; +#endif case XENMEM_maximum_ram_page: if ( unlikely(start_extent) ) diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c index 5ecaa10bb4..5742cd05b8 100644 --- a/xen/drivers/passthrough/iommu.c +++ b/xen/drivers/passthrough/iommu.c @@ -186,9 +186,10 @@ void __hwdom_init iommu_hwdom_init(struct domain *d) hd->need_sync = iommu_hwdom_strict && !iommu_use_hap_pt(d); if ( need_iommu_pt_sync(d) ) { + int rc = 0; +#ifdef CONFIG_HAS_M2P struct page_info *page; unsigned int i = 0, flush_flags = 0; - int rc = 0; page_list_for_each ( page, &d->page_list ) { @@ -215,6 +216,9 @@ void __hwdom_init iommu_hwdom_init(struct domain *d) /* Use while-break to avoid compiler warning */ while ( iommu_iotlb_flush_all(d, flush_flags) ) break; +#else + rc = -ENOSYS; +#endif if ( rc ) printk(XENLOG_WARNING "d%d: IOMMU mapping failed: %d\n", diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h index 312fec8932..d61b0188da 100644 --- a/xen/include/asm-arm/domain.h +++ b/xen/include/asm-arm/domain.h @@ -267,6 +267,11 @@ static inline void free_vcpu_guest_context(struct vcpu_guest_context *vgc) static inline void arch_vcpu_block(struct vcpu *v) {} +static inline gfn_t domain_shared_info_gfn(struct domain *d) +{ + return INVALID_GFN; +} + #endif /* __ASM_DOMAIN_H__ */ /* diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index d1bfc82f57..00d8b09794 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -118,4 +118,13 @@ struct vnuma_info { void vnuma_destroy(struct vnuma_info *vnuma); +#ifdef CONFIG_HAS_M2P +#define domain_shared_info_gfn(d_) ({ \ + struct domain *d = (d_); \ + \ + _gfn(mfn_to_gfn(d, _mfn(__virt_to_mfn(d->shared_info)))); \ +}) + +#endif + #endif /* __XEN_DOMAIN_H__ */ From patchwork Mon Feb 18 11:36:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 158596 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2384598jaa; Mon, 18 Feb 2019 03:38:16 -0800 (PST) X-Google-Smtp-Source: AHgI3IZsTPT/JI8FG7YBVxRqNQcamOQ2c1ge5K+ABLMGKav8sbml7+m4IpTeaBqm7v5ZtpNei0BN X-Received: by 2002:a81:210b:: with SMTP id h11mr18166006ywh.299.1550489896110; Mon, 18 Feb 2019 03:38:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550489896; cv=none; d=google.com; s=arc-20160816; b=0lUqycRdOanjAP4LS0rwII0U2ssINcSp9bXp0PiERQ2StC0EF/9BUkJNwtwS1FKb2R 9SYpvN9gRGA0WvQDTMXZz/TOh8aHQqEAsQxAAdTQfw0bKxWYT/MnOdPfVeCoKyL2DZjJ 0VPL3EtOhOimEwTEIILFxb4TnWP2z8vmFrO3QSBhC5zW6tlyZrnxboeeEaSnM/kFe9bc MgYnnldGZa/o7SZVnHv54olc9phMviSxbbyURnAo00BB1SJ/GyjcX2BHs9wL4NXjtlL6 CKi4Bl9U2xcKmQng3TGyEo/r8pHWzwjzyedydfRqCZd9qjvPfms7XOj0ghsEKl04LDA5 rbnw== 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=zSn7CG4UT3+WK5R2VQhdLUFGCYiQEntDqQ0tv0L/85c=; b=tN1oa/AgVFwdOFEZOHixqYaIplR0XxHt+o0c0hDLh8oYH29iZ/4Wo974gL0hjDsSWT ZK0mL+hdXxBZxv3juf/zWuvvtXSovxo09u+S22K+l/N5ZzKiCCa5f3EdaTTRgbwii9lE v4gEP5Ta1u1UK68p1U/Qaf0FjU4VWUXgp2gYQKtyPfxU3M7oPDPGp6VBsG4rRty/PGFq EGN93CDfKDSg74IR9NwWLvTN73UaIokjdBI/jcXh57Ozrh2ilxL7L+oK3EIqGADlTfGC 4lPoufFVmn+/65v4H+BLQqoMaUFbBU2NJzYL+PITtvE6doO9lL2yxzuf+ESLPFjGFJZw +Bwg== 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 k8si7443533ybb.470.2019.02.18.03.38.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Feb 2019 03:38:16 -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 1gvhDp-0002B8-D0; Mon, 18 Feb 2019 11:36:29 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1gvhDn-00029F-Al for xen-devel@lists.xenproject.org; Mon, 18 Feb 2019 11:36:27 +0000 X-Inumbo-ID: 6cd9716b-3371-11e9-bc90-bc764e045a96 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 6cd9716b-3371-11e9-bc90-bc764e045a96; Mon, 18 Feb 2019 11:36:26 +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 0B58C1713; Mon, 18 Feb 2019 03:36:26 -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 06CC53F720; Mon, 18 Feb 2019 03:36:23 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 18 Feb 2019 11:36:00 +0000 Message-Id: <20190218113600.9540-10-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 9/9] xen: Remove mfn_to_gmfn macro 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 , Andrew Cooper , Julien Grall , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" 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 Acked-by: Jan Beulich Acked-by: Stefano Stabellini --- xen/drivers/passthrough/iommu.c | 6 +++--- xen/include/asm-arm/mm.h | 4 +--- xen/include/asm-x86/mm.h | 5 ----- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c index 5742cd05b8..04ac46239e 100644 --- a/xen/drivers/passthrough/iommu.c +++ b/xen/drivers/passthrough/iommu.c @@ -193,8 +193,8 @@ void __hwdom_init iommu_hwdom_init(struct domain *d) page_list_for_each ( page, &d->page_list ) { - unsigned long mfn = mfn_x(page_to_mfn(page)); - unsigned long dfn = mfn_to_gmfn(d, mfn); + mfn_t mfn = page_to_mfn(page); + unsigned long dfn = mfn_to_gfn(d, mfn); unsigned int mapping = IOMMUF_readable; int ret; @@ -203,7 +203,7 @@ void __hwdom_init iommu_hwdom_init(struct domain *d) == PGT_writable_page) ) mapping |= IOMMUF_writable; - ret = iommu_map(d, _dfn(dfn), _mfn(mfn), 0, mapping, + ret = iommu_map(d, _dfn(dfn), mfn, 0, mapping, &flush_flags); if ( !rc ) diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h index a9c8352b94..a9cb98a6c7 100644 --- a/xen/include/asm-arm/mm.h +++ b/xen/include/asm-arm/mm.h @@ -321,10 +321,8 @@ struct page_info *get_page_from_gva(struct vcpu *v, vaddr_t va, #define SHARED_M2P_ENTRY (~0UL - 1UL) #define SHARED_M2P(_e) ((_e) == SHARED_M2P_ENTRY) -/* 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); } while (0) -#define mfn_to_gmfn(_d, mfn) (mfn) - /* 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 1ca4154382..3324dd7abf 100644 --- a/xen/include/asm-x86/mm.h +++ b/xen/include/asm-x86/mm.h @@ -506,11 +506,6 @@ extern struct rangeset *mmio_ro_ranges; #define get_gpfn_from_mfn(mfn) (machine_to_phys_mapping[(mfn)]) -#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))