From patchwork Tue Jun 13 16:13:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105401 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp486537qgd; Tue, 13 Jun 2017 09:15:37 -0700 (PDT) X-Received: by 10.157.3.45 with SMTP id 42mr602340otv.234.1497370537528; Tue, 13 Jun 2017 09:15:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497370537; cv=none; d=google.com; s=arc-20160816; b=x2Ex9Ej4zZOdjoru7T4Wqhodxt8Q3cerSThMeC0H0hdtZt1AoRTERC3T3ko3Wfpvir FvgBtfKHk+N3ebbdu+Oo6B2JeGV8jRfOX5s+oc+p1SHauaLtYM26UV2oknRGqxGIW1h7 i2aeBAMnXLo/xoZ0fHsQZqjKRvEtGOCPoVY9aarKrSh5njqbgUJDGaqYhZb+qktwneTO xCm/dwVw1cLzm8eq3uhKFBK5jy2Z9M3Zw+wbu6MJ/1T5Nzrk+ACp6/Ry51nr+YQeY1Vt KSktlr7pId/MAfIawbFRPXFC2BZA03MoEPdq00Mk3fEqZwdagjLeDsgoTOdG/t3uhP2e If6w== 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 :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=9r2W1JENXXOJJe+VnpKmPJd0ugntQitMPv+EIYQGkRk=; b=BYMJxM8s4mEDlqDLnaCxK8Ade4hqA7CabqNq2tXyrCzdNwWl6bSq6yVHQobkcPP+rJ fiWsGNkp9m20R/CXSoYKFQCnYWXk3hyit9LkKcryN0LawYiQBaNDVPIbHh5xsPiFeZFI RpFWAN39CCIUmveJBmoTsFBHcND98jaDnLoWnXsqrsCFV92ZjuXC0uWTaz1fSxVZWH0g oV79fAcBTjn067sysrw/Ddq4yfewJb2/w66S9bhDJWA3W9fgrXx4lwzDHs3xr3pUFZJm DECIfkSxMP7NXeiBWts79Bwpz1HLV3c+bmm07vr/dZ4EZmY2pw6LtEU8WjgYPaZfIEfl DmAA== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id o33si337123oto.103.2017.06.13.09.15.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jun 2017 09:15:37 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoRk-00080K-22; Tue, 13 Jun 2017 16:13:36 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoRj-0007zw-1t for xen-devel@lists.xen.org; Tue, 13 Jun 2017 16:13:35 +0000 Received: from [193.109.254.147] by server-7.bemta-6.messagelabs.com id 7B/88-03620-E2F00495; Tue, 13 Jun 2017 16:13:34 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrOLMWRWlGSWpSXmKPExsVysyfVTVeX3yH S4EaPicWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmrFp007mgrM8FbcXLmJuYDzK1cXIxSEksJlR omXiCnYI5zSjxKY33axdjJwcbAKaEnc+f2ICsUUEpCWufb7MCFLELPCKSeLIw36whLCAn8Tfr ecYQWwWAVWJzqsdYM28ApYSF868AotLCMhL7Gq7CBbnFLCSuPS8CSwuBFTTvHs90wRG7gWMDK sY1YtTi8pSi3TN9ZKKMtMzSnITM3N0DQ3M9HJTi4sT01NzEpOK9ZLzczcxAj3MAAQ7GGde9j/ EKMnBpCTKu+WKTaQQX1J+SmVGYnFGfFFpTmrxIUYZDg4lCV57PodIIcGi1PTUirTMHGCowaQl OHiURHjvswCleYsLEnOLM9MhUqcYFaXEeSeA9AmAJDJK8+DaYOF9iVFWSpiXEegQIZ6C1KLcz BJU+VeM4hyMSsK8LTxAU3gy80rgpr8CWswEtPg6yM28xSWJCCmpBsY6KfHE80GSZ6x3SE7/Ma UrdWvPV8cOA5H8/M/zfVzYmsJzUneE9AvqPXYKWTRp9VbtFV8nTlrmpZh/yPmmz7IowXCnmsc XRDxPZh912f5VI+Il348Dh2rtGDRP3Tmilr84siNjcXHc342C0y7GlEy1ke9d6+IvsHpdmoWy UPLUH33PmUxW71FiKc5INNRiLipOBAAxL3bBagIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-2.tower-27.messagelabs.com!1497370413!47935409!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 38736 invoked from network); 13 Jun 2017 16:13:33 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-2.tower-27.messagelabs.com with SMTP; 13 Jun 2017 16:13:33 -0000 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 F351315A2; Tue, 13 Jun 2017 09:13:32 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 39A3B3F557; Tue, 13 Jun 2017 09:13:31 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 13 Jun 2017 17:13:00 +0100 Message-Id: <20170613161323.25196-2-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170613161323.25196-1-julien.grall@arm.com> References: <20170613161323.25196-1-julien.grall@arm.com> Cc: sstabellini@kernel.org, Wei Liu , George Dunlap , Andrew Cooper , punit.agrawal@arm.com, Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 01/24] xen/mm: Don't use _{g, m}fn for defining INVALID_{G, M}FN X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" INVALID_{G,M}FN are defined using static inline helpers _{g,m}fn. This means, they cannot be used to initialize a build time static variable: In file included from mm.c:24:0: xen/xen/include/xen/mm.h:59:26: error: initializer element is not constant #define INVALID_MFN _mfn(~0UL) Signed-off-by: Julien Grall Acked-by: Tim Deegan --- Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Jan Beulich Cc: Konrad Rzeszutek Wilk Cc: Stefano Stabellini Cc: Tim Deegan Cc: Wei Liu I know that this solution will not work for non-debug build. I would like input from the community on way to fix it nicely. --- xen/include/xen/mm.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index ee50d4cd7b..f0daae6b5c 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -56,7 +56,7 @@ TYPE_SAFE(unsigned long, mfn); #define PRI_mfn "05lx" -#define INVALID_MFN _mfn(~0UL) +#define INVALID_MFN (mfn_t){ ~0UL } #ifndef mfn_t #define mfn_t /* Grep fodder: mfn_t, _mfn() and mfn_x() are defined above */ @@ -85,7 +85,7 @@ static inline bool_t mfn_eq(mfn_t x, mfn_t y) TYPE_SAFE(unsigned long, gfn); #define PRI_gfn "05lx" -#define INVALID_GFN _gfn(~0UL) +#define INVALID_GFN (gfn_t){ ~0UL } #ifndef gfn_t #define gfn_t /* Grep fodder: gfn_t, _gfn() and gfn_x() are defined above */ From patchwork Tue Jun 13 16:13:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105389 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp486377qgd; Tue, 13 Jun 2017 09:15:19 -0700 (PDT) X-Received: by 10.202.68.137 with SMTP id r131mr400391oia.201.1497370519775; Tue, 13 Jun 2017 09:15:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497370519; cv=none; d=google.com; s=arc-20160816; b=M37z9H7NSt2ehFQOLGGwUqgQa9nry0jThURRpJ0vrAsKdh9T32CRWwCsKzufrctuqc ix9ozwKlWObIgzlMacEfwT8mk4wLc0TK9ANtegx8fhZIu11GkrLRdO7wWKZj/67B/+LM An2nQsIpkMDfX2wAs3pbjLTyRMp3pUEfRqMAdXYeN7TFONSFcnUiooQXHKYPmSr1zSmC 69JYEMxiIzz76YW0bH5LykuNAo68D79TXbTXo3M71cTbrojYeK40v1v2baIfZavRJ6iv OtoIYWNytJm8S5DBkChYyQfHbTrma7lZzFk9hoTjAUBltEyQWBNszdl/H2DyO6hnUEM8 8YBw== 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 :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=CA/IMBoEtI9rr/Y1SI1fIfJgyQTFtGN7mtbcVUs+SGw=; b=zEjAheeezhszp626w/8NeTJSW6W5l7/BPWPwZAALOIXK23CIjnS37Tzk1xxPx4xHs3 +SqXoyiSEfno6s7AvZsuDehdg0+3Bk73g06OgVOVAHn+g3D+y21uB7AuN+pqCxPZJY73 WUCgiKZL5RFfADGzfkQvJMKkPMne7mcZyukj9GxfnRokCt+IUPymWiTwz4q31B22z3HF E1H/P6PA0K3CpLCJ1TYKa7fXsBarUNjUKjDJ3ObMJvHUAMwZQuSxkhG3NroqTY2vo3Uz wBmuM9daaO2JlpA7RSph+GLoTF1rakWnWzjmGHSBIbXZqrocS2VjEcDhOG4kj23i9jHp 9w9A== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 61si303851otl.278.2017.06.13.09.15.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jun 2017 09:15:19 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoRl-00081z-Jt; Tue, 13 Jun 2017 16:13:37 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoRk-00080H-Dl for xen-devel@lists.xen.org; Tue, 13 Jun 2017 16:13:36 +0000 Received: from [85.158.137.68] by server-17.bemta-3.messagelabs.com id A5/31-02955-F2F00495; Tue, 13 Jun 2017 16:13:35 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTVeP3yH S4OoXC4slHxezODB6HN39mymAMYo1My8pvyKBNWPVim/sBX/YKq7emcbcwNjB2sXIxSEksJlR 4seEJ2wQzmlGiRVTVwA5nBxsApoSdz5/YgKxRQSkJa59vswIYjMLREg0LdgLFhcWiJT40dzLD mKzCKhKbPt5GKyGV8BSoq/3DViNhIC8xK62i6wgNqeAlcSl501gNUJANc271zNNYORewMiwil GjOLWoLLVI19BQL6koMz2jJDcxM0fX0MBYLze1uDgxPTUnMalYLzk/dxMj0MMMQLCDcfVvp0O MkhxMSqK8W67YRArxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4LXnc4gUEixKTU+tSMvMAYYaTFqC g0dJhPc+C1Cat7ggMbc4Mx0idYpRl6Ppw5YvTEIsefl5qVLivH94gYoEQIoySvPgRsDC/hKjr JQwLyPQUUI8BalFuZklqPKvGMU5GJWEeVt4gKbwZOaVwG16BXQEE9AR10Hu5y0uSURISTUwaj xb/7TqXckJOZnlPudz7da+VJ0acP/BzXeGbbJy5/YsUfdYqlN0s2D/o56VzftOf5iUVnZbcbt A2DXFrJyCUMkpGqvPbne+yacWUPbfljdqUVzcmgnhDj6ixmdbFn55fJtFJKBvosRB130PvB/u 59jpu6T+TP2L9dMmspouMlgXtqO4p0PSR4mlOCPRUIu5qDgRAHjPy7p2AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-7.tower-31.messagelabs.com!1497370414!97906654!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 48970 invoked from network); 13 Jun 2017 16:13:34 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-7.tower-31.messagelabs.com with SMTP; 13 Jun 2017 16:13:34 -0000 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 004CB1596; Tue, 13 Jun 2017 09:13:34 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3BA883F557; Tue, 13 Jun 2017 09:13:33 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 13 Jun 2017 17:13:01 +0100 Message-Id: <20170613161323.25196-3-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170613161323.25196-1-julien.grall@arm.com> References: <20170613161323.25196-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org, punit.agrawal@arm.com Subject: [Xen-devel] [PATCH 02/24] xen/arm: gic-v2: Fix indentation in gicv2_map_hwdom_extra_mappings X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/gic-v2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c index 270a1362ec..f8124e5e54 100644 --- a/xen/arch/arm/gic-v2.c +++ b/xen/arch/arm/gic-v2.c @@ -598,8 +598,8 @@ static int gicv2_map_hwdown_extra_mappings(struct domain *d) v2m_data->spi_start, v2m_data->nr_spis); ret = map_mmio_regions(d, _gfn(paddr_to_pfn(v2m_data->addr)), - DIV_ROUND_UP(v2m_data->size, PAGE_SIZE), - _mfn(paddr_to_pfn(v2m_data->addr))); + DIV_ROUND_UP(v2m_data->size, PAGE_SIZE), + _mfn(paddr_to_pfn(v2m_data->addr))); if ( ret ) { printk(XENLOG_ERR "GICv2: Map v2m frame to d%d failed.\n", From patchwork Tue Jun 13 16:13:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105392 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp486435qgd; Tue, 13 Jun 2017 09:15:28 -0700 (PDT) X-Received: by 10.157.12.156 with SMTP id b28mr534360otb.94.1497370528207; Tue, 13 Jun 2017 09:15:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497370528; cv=none; d=google.com; s=arc-20160816; b=AZdsIYUfETuFqftusdE0sqbhlE8RoHNy3p9dm/SIiMQZryGxh+e/jcgva69rXvVW3c e+NqlxgdxCrxmDwhC9pC+2beIU+IbqhXeHYP1YbdGF9RfcwjSdmwseyX7907Xy8FGwcQ ieOF62kaMd/tVn7iYsFTUZdffJMO0TsKJiqKYDcS7Zh6nLN2PzMHmWHaQz3FBruASfvP WOcJqwO2QGWoOSBi6k/TljN9aVtq0YvhGB1kRDz+u7vZOxxGmAM1LnFjQWc39iuXnd6w VFLGVTFSbcu7VlMdCANzRFJd8FQ2tZgx9AGZKncFXmTobIumoVEaPH7XvlzUJWTaWn3+ b3Dw== 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 :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=dh96HDfaeUCDxvgVsqOOiquy3k7uYzIHdjEG/0DH5ek=; b=KDVALtmBQHBiph2+1DxBjuQC8SoOp7IkrRoyRL1BfXpf18ybnNNPGjbm1gu7oXYHTg rTO6bmy753nufnm9hTH0oqdtzFREL3HvcdTXKvBEFHDF43i8Ks6HI/qqyaTOXG2wEogt IMIw9uqLyhDgXhpYLK9Jej6YgR5g1kjB4P4KneT7rmoh0tqEUORTf62PraLalnF7EMcO L19I2wIcChnvJ5U03l0X4u7onuPguMN+zdwHPUthfhY8Rl3RQKCNPn9wCkcJjetPOB82 YksOItbVd4MUhL4K9fTRR9QKmaGUoMfaAEVWQ4sz2PVIiEloE9debjo6icOafWHsGHqh 9qKg== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id w64si308073oie.310.2017.06.13.09.15.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jun 2017 09:15:28 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoRl-00082Q-R2; Tue, 13 Jun 2017 16:13:37 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoRk-00080j-Qa for xen-devel@lists.xen.org; Tue, 13 Jun 2017 16:13:36 +0000 Received: from [193.109.254.147] by server-3.bemta-6.messagelabs.com id F7/49-03058-03F00495; Tue, 13 Jun 2017 16:13:36 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrELMWRWlGSWpSXmKPExsVysyfVTVef3yH SoHmRlsWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmtH+s5+lYBtrxY+zi1kaGPtZuhg5OYQENjNK 3Hke2cXIBWSfZpT4tvM7I0iCTUBT4s7nT0wgtoiAtMS1z5fB4swCERJNC/aCxYUFIiUWnz/ND GKzCKhKvDiwiRXE5hWwlOh7fh+sXkJAXmJX20WwOKeAlcSl502MEIstJZp3r2eawMi9gJFhFa NGcWpRWWqRrqGBXlJRZnpGSW5iZg6QZ6aXm1pcnJiempOYVKyXnJ+7iRHoXwYg2MF4b1nAIUZ JDiYlUd4tV2wihfiS8lMqMxKLM+KLSnNSiw8xynBwKEnw2vM5RAoJFqWmp1akZeYAAw0mLcHB oyTCe58FKM1bXJCYW5yZDpE6xajL0fRhyxcmIZa8/LxUKXHeP7xARQIgRRmleXAjYEF/iVFWS piXEegoIZ6C1KLczBJU+VeM4hyMSsK8S0Au4cnMK4Hb9AroCCagI66D3M9bXJKIkJJqYNz8S4 cpxDJ/+VKbT0z9rg/yw70zz00zvfe9vXxLhPEBg2xFhqWhCxZJr+nh3bnS5vcb2/iAa5bHNrk yPlZtPJG55OXVyiesh9Y4WsccWlDLNHHT4+J+8YM1Z5Svqq97tJiLZ67Aikb7/6+CtbzfTPoo pG94703hQpOjLNMfR5zaGWJ5ftKnpolKLMUZiYZazEXFiQBShMnxdQIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-5.tower-27.messagelabs.com!1497370415!102003622!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 48237 invoked from network); 13 Jun 2017 16:13:35 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-5.tower-27.messagelabs.com with SMTP; 13 Jun 2017 16:13:35 -0000 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 010A115B2; Tue, 13 Jun 2017 09:13:35 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3CDD23F557; Tue, 13 Jun 2017 09:13:34 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 13 Jun 2017 17:13:02 +0100 Message-Id: <20170613161323.25196-4-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170613161323.25196-1-julien.grall@arm.com> References: <20170613161323.25196-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org, punit.agrawal@arm.com Subject: [Xen-devel] [PATCH 03/24] xen/arm: setup: Remove bogus xenheap_mfn_end in setup_mm for arm64 X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" xenheap_mfn_end is storing an MFN and not a physical address. Thankfully xenheap_mfn_end is not used in the arm64 code. So drop it. Signed-off-by: Julien Grall --- xen/arch/arm/setup.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index f00f29a45b..ab4d8e4218 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -654,8 +654,6 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size) if ( e > bank_end ) e = bank_end; - xenheap_mfn_end = e; - dt_unreserved_regions(s, e, init_boot_pages, 0); s = n; } From patchwork Tue Jun 13 16:13:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105391 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp486429qgd; Tue, 13 Jun 2017 09:15:27 -0700 (PDT) X-Received: by 10.107.6.211 with SMTP id f80mr935323ioi.188.1497370527074; Tue, 13 Jun 2017 09:15:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497370527; cv=none; d=google.com; s=arc-20160816; b=AHeXKNcKmdjFm6Z0xjoBS+Ewnia0PwtUS3lxk0glM790PVAMCROEH2Coz9ExdJaYnL VzK1mZtRjgLxN+FppVVRaaX6/FosHqtD0J573cDLXsAFsgyYnikwmm3T+vVgIBe6Xi8C MAsxb6KSosW12zqkO6ei8apMheS5z6o93nx5WdIYWDfVPz7w2vWxBOTCjYN247YOSGO6 A19sQDeSXz5mGtGywARA3DJggPmJvRfWnNoWCgRQGHnvl25NY89decB9jMUKUed2mcSp PsUQbhLpsQu7YufjQoOCtayb07FprYnPAg/OwSBZc4ZHwAlfkBV3NGy1aUsDzbxj0fi0 8jbw== 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 :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=//RLEGdqLEh8UJfkioWf2QmgrQgK/ivWXm39AUh2YC0=; b=ccw1qytnp4OuJNZNpjkWpvAhb/xJYAA3/jjNcaOaIQ/UUgFHwPjQVQ6RR1zVgaK1T9 vp8lu1rxejnuwinM2HBVnB6LTPbzEviiDHmWhfA5FH80Lz5gNmgq5uSNrp+TdqtnycIF B+6mI60Kw9SKm7GTNW6Uv1+JP2gqVoca4bMS889dOQZ9BuadWvhwwvIyQ2/jGAaaMiya 15xwt7bxB+2jiDFcdrxkaqlas8Kv+XKK+uregckq0dURWt9MFE8if6endeqqCZQ8cmbN Gpn5cx4rq0hiP3DtErqUbAaj+STGUX8Zm9Ks5PAcn2+VjAFa3Pces1y/54dPqd7/fMiE qRxA== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id y195si1139554itc.0.2017.06.13.09.15.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jun 2017 09:15:27 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoRn-00083i-2V; Tue, 13 Jun 2017 16:13:39 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoRl-00081e-OV for xen-devel@lists.xen.org; Tue, 13 Jun 2017 16:13:37 +0000 Received: from [85.158.143.35] by server-10.bemta-6.messagelabs.com id 16/B3-03613-13F00495; Tue, 13 Jun 2017 16:13:37 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKLMWRWlGSWpSXmKPExsVysyfVTdeA3yH S4O0jLYslHxezODB6HN39mymAMYo1My8pvyKBNePKoglMBcf5Kh4+Wc7awLiAp4uRi0NIYDOj xLTN81m7GDmBnNOMEqe+u4LYbAKaEnc+f2ICsUUEpCWufb7MCGIzC0RINC3YCxYXFnCR2LWlm wXEZhFQlbg2vw8ozsHBK2ApMXdKMUhYQkBeYlfbRbDxnAJWEpeeNzFCrLKUaN69nmkCI/cCRo ZVjBrFqUVlqUW6RoZ6SUWZ6RkluYmZObqGBmZ6uanFxYnpqTmJScV6yfm5mxiB3mUAgh2Mf5Y FHGKU5GBSEuX1FLCLFOJLyk+pzEgszogvKs1JLT7EKMPBoSTBa8/nECkkWJSanlqRlpkDDDOY tAQHj5II730WoDRvcUFibnFmOkTqFKOilDjvH16ghABIIqM0D64NFtqXGGWlhHkZgQ4R4ilIL crNLEGVf8UozsGoJMzbwgM0hSczrwRu+iugxUxAi69fsQFZXJKIkJJqYJzmHr//xNP1oVpn4u +JNGgstW5MeNLxuY3DYN/y0PYjths9aiOnOb1gmmDT/8puyYv2sye73y1v2KTM/Gbdzdii3w8 4ZctYxMMja4oCqhJW/HlhvsPhZ1TcGdY66y03OS0XblouYslxXc6iZekfU5HHey/UX/i9paqm /H/Yik0vXGXEDustP6zEUpyRaKjFXFScCAAZ9Y04aAIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-8.tower-21.messagelabs.com!1497370416!73580866!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 54503 invoked from network); 13 Jun 2017 16:13:36 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-8.tower-21.messagelabs.com with SMTP; 13 Jun 2017 16:13:36 -0000 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 018AB1596; Tue, 13 Jun 2017 09:13:36 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3D9643F557; Tue, 13 Jun 2017 09:13:35 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 13 Jun 2017 17:13:03 +0100 Message-Id: <20170613161323.25196-5-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170613161323.25196-1-julien.grall@arm.com> References: <20170613161323.25196-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org, punit.agrawal@arm.com Subject: [Xen-devel] [PATCH 04/24] xen/arm: mm: Introduce clear_table and use it X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Add a new helper clear_table to clear a page table entry and invalidate the cache. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/mm.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 082c872c72..b4ff777b55 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -529,6 +529,13 @@ void __init remove_early_mappings(void) extern void relocate_xen(uint64_t ttbr, void *src, void *dst, size_t len); +/* Clear a translation table and clean & invalidate the cache */ +static void clear_table(void *table) +{ + clear_page(table); + clean_and_invalidate_dcache_va_range(table, PAGE_SIZE); +} + /* Boot-time pagetable setup. * Changes here may need matching changes in head.S */ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr) @@ -604,18 +611,13 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr) /* Clear the copy of the boot pagetables. Each secondary CPU * rebuilds these itself (see head.S) */ - memset(boot_pgtable, 0x0, PAGE_SIZE); - clean_and_invalidate_dcache(boot_pgtable); + clear_table(boot_pgtable); #ifdef CONFIG_ARM_64 - memset(boot_first, 0x0, PAGE_SIZE); - clean_and_invalidate_dcache(boot_first); - memset(boot_first_id, 0x0, PAGE_SIZE); - clean_and_invalidate_dcache(boot_first_id); + clear_table(boot_first); + clear_table(boot_first_id); #endif - memset(boot_second, 0x0, PAGE_SIZE); - clean_and_invalidate_dcache(boot_second); - memset(boot_third, 0x0, PAGE_SIZE); - clean_and_invalidate_dcache(boot_third); + clear_table(boot_second); + clear_table(boot_third); /* Break up the Xen mapping into 4k pages and protect them separately. */ for ( i = 0; i < LPAE_ENTRIES; i++ ) From patchwork Tue Jun 13 16:13:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105405 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp486566qgd; Tue, 13 Jun 2017 09:15:41 -0700 (PDT) X-Received: by 10.107.9.93 with SMTP id j90mr831487ioi.172.1497370541404; Tue, 13 Jun 2017 09:15:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497370541; cv=none; d=google.com; s=arc-20160816; b=jYYPHX6LkTiKGlS6o0Q8eyAZDOm8cj1pd/sU6h0On0DQO65vUyBNWhm9hBBeWZ4ufj r7WD9LSyG9HxNF2nQVVFlSH9ZFrWhIo1OYmoWdleFsPBVNjIYdBfqHp8mRHZoRIXhpgd aq0qoWjK7hH/aPfWOpM+kK43Z7yc6SeeHp8mD2nvicQrnqlb9pMvSVZalpTFgTGb+Ag0 DV5Y61nQ7Exr4iFHsM1LcRBUbwecpeDilKC4EnTmtTxkEaLg5xmf+ciJnwc/m3e6/jXP YTZweFDhfZSs10RU6XzpCKM+1Cu8gfYiQ3MvMQ444JrG6yzKcTjLJ8Je73bFObKMsq2J XNXQ== 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 :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=KJkwyF6bj+83oWW2cA1PEmPiyyqOSBYaG+At9r4U2sA=; b=lFjHiQcVoNuoraXoU+ZA2VB1wQBIuy7lzGQ8NEIlQPRAY8IHtIXdqJ6TffVYga3+1O WKbGUOAm9YjJVkgfaiOOsSpNZgNgSVtgFAJOR0QOE/+w3xP1K7ee8J7gKqK3gFsAwEus hkKQ0MO2ullJh7QqLnMC88FDLwm5I1mykoNFDWXyMCUXVJdxLYvPiVyj25ucQ37Kj3+8 6i2GVj0yUSXg5/WcCM7SbVC1fBqVEcZmEN0ATCdl/bZc1ZNsEKKTzcJwGFNyaYZVyu3r TzisGNLGxeDe9naP9+aTgvhV5OZ2R0iAy8zFSZl2v8xCpH7lReTyFWXMJ44b24o+B7RS JEPw== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id m9si419921iti.21.2017.06.13.09.15.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jun 2017 09:15:41 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoRo-00084z-9f; Tue, 13 Jun 2017 16:13:40 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoRn-00083h-FA for xen-devel@lists.xen.org; Tue, 13 Jun 2017 16:13:39 +0000 Received: from [85.158.139.211] by server-7.bemta-5.messagelabs.com id 84/EC-02181-23F00495; Tue, 13 Jun 2017 16:13:38 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrOLMWRWlGSWpSXmKPExsVysyfVTdeQ3yH SYPZjK4slHxezODB6HN39mymAMYo1My8pvyKBNePN3w+MBXMMK/omHGRsYHyv2MXIxSEksJlR 4u3p98wQzmlGieZ7W1m6GDk52AQ0Je58/sQEYosISEtc+3yZEcRmFoiQaFqwFywuLOArsXLqR rB6FgFViYdrP4LFeQUsJf6e/MkMYksIyEvsarvICmJzClhJXHreBDZHCKimefd6pgmM3AsYGV YxahSnFpWlFukameglFWWmZ5TkJmbm6BoamOrlphYXJ6an5iQmFesl5+duYgR6uJ6BgXEH483 JfocYJTmYlER5t1yxiRTiS8pPqcxILM6ILyrNSS0+xCjDwaEkwWvP5xApJFiUmp5akZaZAww1 mLQEB4+SCO99FqA0b3FBYm5xZjpE6hSjopQ47x9eoIQASCKjNA+uDRbelxhlpYR5GRkYGIR4C lKLcjNLUOVfMYpzMCoJ87bwAE3hycwrgZv+CmgxE9Di6yA38xaXJCKkpBoYZV8/XHdoupPJjZ yXp78fv609yc18ocLeL5xBvgYTrl0/evxQ9ExLYfWUpMvP6hfGOHGzHNxz0Vjo9R9NXfGszSW BS//1rDh2so6/Qt6faZOfrfgx63sp5q+mG9p5vnG3sHpvW247484DmeTQo471BUUf9qmU3dn4 Wb7V21f0wv/nec1MfCxflFiKMxINtZiLihMBa8HfF2oCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-12.tower-206.messagelabs.com!1497370417!66951659!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 20895 invoked from network); 13 Jun 2017 16:13:37 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-12.tower-206.messagelabs.com with SMTP; 13 Jun 2017 16:13:37 -0000 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 02D9915A2; Tue, 13 Jun 2017 09:13:37 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3DCF63F557; Tue, 13 Jun 2017 09:13:36 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 13 Jun 2017 17:13:04 +0100 Message-Id: <20170613161323.25196-6-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170613161323.25196-1-julien.grall@arm.com> References: <20170613161323.25196-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org, punit.agrawal@arm.com Subject: [Xen-devel] [PATCH 05/24] xen/arm: mm: Move mfn_to_xen_entry from page.h to mm.c X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" The file mm.c is the only user of mfn_to_xen_entry. This will also help to use the typesafe MFN. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/mm.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++ xen/include/asm-arm/page.h | 65 ---------------------------------------------- 2 files changed, 65 insertions(+), 65 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index b4ff777b55..587a6b3975 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -254,6 +254,71 @@ void dump_hyp_walk(vaddr_t addr) dump_pt_walk(ttbr, addr, HYP_PT_ROOT_LEVEL, 1); } +/* Standard entry type that we'll use to build Xen's own pagetables. + * We put the same permissions at every level, because they're ignored + * by the walker in non-leaf entries. */ +static inline lpae_t mfn_to_xen_entry(unsigned long mfn, unsigned attr) +{ + paddr_t pa = ((paddr_t) mfn) << PAGE_SHIFT; + lpae_t e = (lpae_t) { + .pt = { + .valid = 1, /* Mappings are present */ + .table = 0, /* Set to 1 for links and 4k maps */ + .ai = attr, + .ns = 1, /* Hyp mode is in the non-secure world */ + .user = 1, /* See below */ + .ro = 0, /* Assume read-write */ + .af = 1, /* No need for access tracking */ + .ng = 1, /* Makes TLB flushes easier */ + .contig = 0, /* Assume non-contiguous */ + .xn = 1, /* No need to execute outside .text */ + .avail = 0, /* Reference count for domheap mapping */ + }};; + /* Setting the User bit is strange, but the ATS1H[RW] instructions + * don't seem to work otherwise, and since we never run on Xen + * pagetables in User mode it's OK. If this changes, remember + * to update the hard-coded values in head.S too */ + + switch ( attr ) + { + case BUFFERABLE: + /* + * ARM ARM: Overlaying the shareability attribute (DDI + * 0406C.b B3-1376 to 1377) + * + * A memory region with a resultant memory type attribute of Normal, + * and a resultant cacheability attribute of Inner Non-cacheable, + * Outer Non-cacheable, must have a resultant shareability attribute + * of Outer Shareable, otherwise shareability is UNPREDICTABLE. + * + * On ARMv8 sharability is ignored and explicitly treated as Outer + * Shareable for Normal Inner Non_cacheable, Outer Non-cacheable. + */ + e.pt.sh = LPAE_SH_OUTER; + break; + case UNCACHED: + case DEV_SHARED: + /* Shareability is ignored for non-Normal memory, Outer is as + * good as anything. + * + * On ARMv8 sharability is ignored and explicitly treated as Outer + * Shareable for any device memory type. + */ + e.pt.sh = LPAE_SH_OUTER; + break; + default: + e.pt.sh = LPAE_SH_INNER; /* Xen mappings are SMP coherent */ + break; + } + + ASSERT(!(pa & ~PAGE_MASK)); + ASSERT(!(pa & ~PADDR_MASK)); + + // XXX shifts + e.bits |= pa; + return e; +} + /* Map a 4k page in a fixmap entry */ void set_fixmap(unsigned map, unsigned long mfn, unsigned attributes) { diff --git a/xen/include/asm-arm/page.h b/xen/include/asm-arm/page.h index 497b4c86ad..3670ab665d 100644 --- a/xen/include/asm-arm/page.h +++ b/xen/include/asm-arm/page.h @@ -205,71 +205,6 @@ typedef union { lpae_walk_t walk; } lpae_t; -/* Standard entry type that we'll use to build Xen's own pagetables. - * We put the same permissions at every level, because they're ignored - * by the walker in non-leaf entries. */ -static inline lpae_t mfn_to_xen_entry(unsigned long mfn, unsigned attr) -{ - paddr_t pa = ((paddr_t) mfn) << PAGE_SHIFT; - lpae_t e = (lpae_t) { - .pt = { - .valid = 1, /* Mappings are present */ - .table = 0, /* Set to 1 for links and 4k maps */ - .ai = attr, - .ns = 1, /* Hyp mode is in the non-secure world */ - .user = 1, /* See below */ - .ro = 0, /* Assume read-write */ - .af = 1, /* No need for access tracking */ - .ng = 1, /* Makes TLB flushes easier */ - .contig = 0, /* Assume non-contiguous */ - .xn = 1, /* No need to execute outside .text */ - .avail = 0, /* Reference count for domheap mapping */ - }};; - /* Setting the User bit is strange, but the ATS1H[RW] instructions - * don't seem to work otherwise, and since we never run on Xen - * pagetables in User mode it's OK. If this changes, remember - * to update the hard-coded values in head.S too */ - - switch ( attr ) - { - case BUFFERABLE: - /* - * ARM ARM: Overlaying the shareability attribute (DDI - * 0406C.b B3-1376 to 1377) - * - * A memory region with a resultant memory type attribute of Normal, - * and a resultant cacheability attribute of Inner Non-cacheable, - * Outer Non-cacheable, must have a resultant shareability attribute - * of Outer Shareable, otherwise shareability is UNPREDICTABLE. - * - * On ARMv8 sharability is ignored and explicitly treated as Outer - * Shareable for Normal Inner Non_cacheable, Outer Non-cacheable. - */ - e.pt.sh = LPAE_SH_OUTER; - break; - case UNCACHED: - case DEV_SHARED: - /* Shareability is ignored for non-Normal memory, Outer is as - * good as anything. - * - * On ARMv8 sharability is ignored and explicitly treated as Outer - * Shareable for any device memory type. - */ - e.pt.sh = LPAE_SH_OUTER; - break; - default: - e.pt.sh = LPAE_SH_INNER; /* Xen mappings are SMP coherent */ - break; - } - - ASSERT(!(pa & ~PAGE_MASK)); - ASSERT(!(pa & ~PADDR_MASK)); - - // XXX shifts - e.bits |= pa; - return e; -} - #if defined(CONFIG_ARM_32) # include #elif defined(CONFIG_ARM_64) From patchwork Tue Jun 13 16:13:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105400 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp486519qgd; Tue, 13 Jun 2017 09:15:35 -0700 (PDT) X-Received: by 10.202.87.84 with SMTP id l81mr525458oib.216.1497370535691; Tue, 13 Jun 2017 09:15:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497370535; cv=none; d=google.com; s=arc-20160816; b=XiEZfQlPQT8dmFfs2lqGSKAjfDdhZsYs5hYcNubbZtGty+B77jY0IlFgk7VIcXkq9d I+zvAMusE9Enokli3Ta03l3Qc22gS58kDcYWRS1H+/oyd+BB36/pWGU+5O/uBZen8s1j BbSnaEcjEv9+kMp7MaZkNFr+HAb9OSrYQXaloh5fP7IXeppCcEREEt2fcUyYM+36uvUg HshnZW5PpAFuhGlAiN1KLShYwboyZQMvwU8GlhxQQ685mwMeoE0VOky1mh86Ce0P2722 +jwJXFY4BvEi9hDuaWOsj+vWL1MSw3/YHVrY/2ipCpQQ+7UUOEL+5qI+x2RrnWwRbI72 oK8g== 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 :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=d18z22PlWt4cd57WKgzi5W6F6/VEA/lBruUCti0+a1A=; b=TB4rx3wBscznN6PZTgugrwK6N4iQtsE11auKzBfIbTd1rr7Mj9L9okpyOUNctKEEO0 ehv7BhrhMEg5JfAcWjNTwNRwMIiBA2a/67t+PMO2HURjaA5xpb3mS2Qc8AbvrDVjECTQ 9Deule3nG1dFjqS0gvmVdjRJ/bhboVi4T9eoC53OYuKVdtvtC58hGmBAivlnHjel4i4W pdqT7MEfFJsCdAgbGXm7oeDYdVNi7mP9EMV2k0c9BhJwzL3Zjk5Edkmg8kWXLboSgJV0 gEKPxEz5x2A+l9H+m4G/IwsCb+EnMkGc446Fcgum0IQ13WwmZN+/YwqU6hnd7cwe4hUe d3aA== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id a19si238461oth.317.2017.06.13.09.15.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jun 2017 09:15:35 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoRs-00089z-T6; Tue, 13 Jun 2017 16:13:44 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoRr-00087f-4H for xen-devel@lists.xen.org; Tue, 13 Jun 2017 16:13:43 +0000 Received: from [85.158.139.211] by server-16.bemta-5.messagelabs.com id 60/86-01752-63F00495; Tue, 13 Jun 2017 16:13:42 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrOLMWRWlGSWpSXmKPExsVysyfVTdeI3yH SYGeDocWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmvHh8XrWgpuCFXsaj7E3MK7i7WLk4hAS2Mwo cePDDyYI5zSjxKrVb5m7GDk52AQ0Je58/sQEYosISEtc+3yZEcRmFoiQaFqwFywuLOAh0Tz5N BuIzSKgKtFwvx/M5hWwlNj6aR3YHAkBeYldbRdZQWxOASuJS8+bwOYIAdU0717PNIGRewEjwy pGjeLUorLUIl0jM72kosz0jJLcxMwcXUMDU73c1OLixPTUnMSkYr3k/NxNjEAP1zMwMO5gvD3 Z7xCjJAeTkijvlis2kUJ8SfkplRmJxRnxRaU5qcWHGGU4OJQkeHfwOkQKCRalpqdWpGXmAEMN Ji3BwaMkwnufBSjNW1yQmFucmQ6ROsWoKCXO2wzSJwCSyCjNg2uDhfclRlkpYV5GBgYGIZ6C1 KLczBJU+VeM4hyMSsK8LTxAU3gy80rgpr8CWswEtPg6yM28xSWJCCmpBsYFDWJP8u/cLvqrEj O/YEXHF/WdFzabJ3OlWB/IXcaz51avGuPP9uVmtcaMTH5PVrSyHVp57/XEg9or7l7P+XDp8J5 Xy42zkkMd5K6wrFTfO5eF9cZVz55Z7hVK8zg8VKQ+5blGvD/52nPHR7cZZ/rn1E+VY7GLtXPr 8A5cf/NXj5vP7Vk74+YpsRRnJBpqMRcVJwIAYWGfyWoCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-2.tower-206.messagelabs.com!1497370418!82613426!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 50933 invoked from network); 13 Jun 2017 16:13:38 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-2.tower-206.messagelabs.com with SMTP; 13 Jun 2017 16:13:38 -0000 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 0611B1596; Tue, 13 Jun 2017 09:13:38 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3F4853F557; Tue, 13 Jun 2017 09:13:37 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 13 Jun 2017 17:13:05 +0100 Message-Id: <20170613161323.25196-7-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170613161323.25196-1-julien.grall@arm.com> References: <20170613161323.25196-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org, punit.agrawal@arm.com Subject: [Xen-devel] [PATCH 06/24] xen/arm: mm: Fix coding style of mfn_to_xen_entry X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Fix the comment coding style and add a newline before the return. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/mm.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 587a6b3975..6f63e4315a 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -254,9 +254,11 @@ void dump_hyp_walk(vaddr_t addr) dump_pt_walk(ttbr, addr, HYP_PT_ROOT_LEVEL, 1); } -/* Standard entry type that we'll use to build Xen's own pagetables. +/* + * Standard entry type that we'll use to build Xen's own pagetables. * We put the same permissions at every level, because they're ignored - * by the walker in non-leaf entries. */ + * by the walker in non-leaf entries. + */ static inline lpae_t mfn_to_xen_entry(unsigned long mfn, unsigned attr) { paddr_t pa = ((paddr_t) mfn) << PAGE_SHIFT; @@ -274,10 +276,12 @@ static inline lpae_t mfn_to_xen_entry(unsigned long mfn, unsigned attr) .xn = 1, /* No need to execute outside .text */ .avail = 0, /* Reference count for domheap mapping */ }};; - /* Setting the User bit is strange, but the ATS1H[RW] instructions + /* + * Setting the User bit is strange, but the ATS1H[RW] instructions * don't seem to work otherwise, and since we never run on Xen * pagetables in User mode it's OK. If this changes, remember - * to update the hard-coded values in head.S too */ + * to update the hard-coded values in head.S too. + */ switch ( attr ) { @@ -298,7 +302,8 @@ static inline lpae_t mfn_to_xen_entry(unsigned long mfn, unsigned attr) break; case UNCACHED: case DEV_SHARED: - /* Shareability is ignored for non-Normal memory, Outer is as + /* + * Shareability is ignored for non-Normal memory, Outer is as * good as anything. * * On ARMv8 sharability is ignored and explicitly treated as Outer @@ -314,8 +319,9 @@ static inline lpae_t mfn_to_xen_entry(unsigned long mfn, unsigned attr) ASSERT(!(pa & ~PAGE_MASK)); ASSERT(!(pa & ~PADDR_MASK)); - // XXX shifts + /* XXX shifts */ e.bits |= pa; + return e; } From patchwork Tue Jun 13 16:13:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105394 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp486442qgd; Tue, 13 Jun 2017 09:15:29 -0700 (PDT) X-Received: by 10.36.74.195 with SMTP id k186mr846655itb.63.1497370528990; Tue, 13 Jun 2017 09:15:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497370528; cv=none; d=google.com; s=arc-20160816; b=ZNmmGxONF4KYMcpyIyb01gxLmjTYFLUQNakjC7O9JxdCVZUBAD+4VO7YhAJZgRrVh9 U8v0Z3s+UMwyhtw6JHbPzqzUcYhY2RmmpAdSDV9kFLgFnptf0b+MZQmntr8p1SrRu47X rso5lKcTWCWgqs41Mg7+jpYA7ma6b/UYbRvdbY8bUeTXej8N2hkObC7J/5BEXqJxiHdw LGMZok6TX3x/GNUH1Yg2b1it0IFUAfFPg7OzwxcQWZssaiD6gVqkXTYAJ3lJqZQ6VxAm hlgMRyxqLwCCzWZdicv3qEPzUxY89ZFbMNkRQtM052M+Z5F+RUi72uk8uUoQ85kQoKpG 8Cxw== 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 :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=Muh2gAxwrfE8NIaKADxwjOsBoVjeD+Vcd0M1QyBjwv4=; b=kcNyMDuWGIw6tu8f7cqvV3RuDwn302NxKt1HETIGZaVyjYUUpGTser8no/9aZ1wL20 iRh3LvLFz/Gpm4msjv+NWTT6eXXbWkvEkleLBxs73wTZt0npPKflLzxJ8pLU0N2Nh5i8 cYqL95djQhCJVX74A74uj/kNGbX3Xo8iRI0KP5ysnj5oR745jdn4d/jIufVYs1jYpRMF 3rIEbKGphXotaxfuyFuyeYp2Dr4/qEJ5RIPTrF3w35KA8cwqxcw0qCVR67gIHxofUd+S EIcbeaQ01GYyTxCnS3bY4R54kQOqi8ebDNo3vWwoOqbAyEYZXQFLp4/jve8TKlX87cKU ZJBA== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id v188si399242ioe.165.2017.06.13.09.15.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jun 2017 09:15:28 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoRp-00086T-HR; Tue, 13 Jun 2017 16:13:41 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoRo-00080j-CZ for xen-devel@lists.xen.org; Tue, 13 Jun 2017 16:13:40 +0000 Received: from [193.109.254.147] by server-3.bemta-6.messagelabs.com id 55/69-03058-43F00495; Tue, 13 Jun 2017 16:13:40 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKLMWRWlGSWpSXmKPExsVysyfVTdeY3yH SoGGNjsWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmtF00LLgBmdF5+6FbA2M59m7GLk4hAQ2M0rs OHaIDcI5zSixf9JloAwnB5uApsSdz5+YQGwRAWmJa58vM4LYzAIREk0L9oLFhQVsJW5+38ACY rMIqEpcW/EAqJeDg1fAUmLyDHuQsISAvMSutousIDangJXEpedNYGOEgEqad69nmsDIvYCRYR WjRnFqUVlqka6RiV5SUWZ6RkluYmaOrqGBmV5uanFxYnpqTmJSsV5yfu4mRqB3GYBgB+O+j5G HGCU5mJREeT0F7CKF+JLyUyozEosz4otKc1KLDzHKcHAoSfDa8zlECgkWpaanVqRl5gDDDCYt wcGjJMJ7nwUozVtckJhbnJkOkTrFqCglzvuHFyghAJLIKM2Da4OF9iVGWSlhXkagQ4R4ClKLc jNLUOVfMYpzMCoJ87bwAE3hycwrgZv+CmgxE9Di61dsQBaXJCKkpBoYGc05D04oebQrcMnyN7 vWHLPzV+Te3lccqSMivmIb85LOhGLOr4nXXGQuH41kYq558kTbc9OyTBl2a4vAN1NnnTLra4i fsm6h4ZGtGpNSFLdnRLxKODrfT+T5EQ0J1pTkxxp3Oqe+v/1c7Lc4V2HcytV3D4jbGnzirfjC 23/++rvv9aZdbgtmK7EUZyQaajEXFScCAHxV48poAgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-7.tower-27.messagelabs.com!1497370419!102885154!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 54640 invoked from network); 13 Jun 2017 16:13:39 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-7.tower-27.messagelabs.com with SMTP; 13 Jun 2017 16:13:39 -0000 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 081E615B2; Tue, 13 Jun 2017 09:13:39 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 41FBD3F557; Tue, 13 Jun 2017 09:13:38 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 13 Jun 2017 17:13:06 +0100 Message-Id: <20170613161323.25196-8-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170613161323.25196-1-julien.grall@arm.com> References: <20170613161323.25196-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org, punit.agrawal@arm.com Subject: [Xen-devel] [PATCH 07/24] xen/arm: mm: Clean-up mfn_to_xen_entry X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" The physical address is computed from the machine frame number, so checking if the physical address is page aligned is pointless. Furthermore, directly assigned the MFN to the corresponding field in the entry rather than converting to a physical address and orring the value. It will avoid to rely on the field position and make the code clearer. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/mm.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 6f63e4315a..d164ed2eda 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -261,7 +261,6 @@ void dump_hyp_walk(vaddr_t addr) */ static inline lpae_t mfn_to_xen_entry(unsigned long mfn, unsigned attr) { - paddr_t pa = ((paddr_t) mfn) << PAGE_SHIFT; lpae_t e = (lpae_t) { .pt = { .valid = 1, /* Mappings are present */ @@ -316,11 +315,9 @@ static inline lpae_t mfn_to_xen_entry(unsigned long mfn, unsigned attr) break; } - ASSERT(!(pa & ~PAGE_MASK)); - ASSERT(!(pa & ~PADDR_MASK)); + ASSERT(!(pfn_to_paddr(mfn) & ~PADDR_MASK)); - /* XXX shifts */ - e.bits |= pa; + e.pt.base = mfn; return e; } From patchwork Tue Jun 13 16:13:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105381 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp486295qgd; Tue, 13 Jun 2017 09:15:09 -0700 (PDT) X-Received: by 10.107.18.15 with SMTP id a15mr758540ioj.189.1497370509603; Tue, 13 Jun 2017 09:15:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497370509; cv=none; d=google.com; s=arc-20160816; b=NifalP+jKhbnwSdcb1t4sD94sGLeBhGjqQXfG/OKO9c42MD6ruiXPEABNxqmjIOcM2 KTpx4fY7mx207//coKjb6kHnGYVfBiQ9xPZ57oPAHqzaxKBE8ne44C6yLPWtPV3A3cgm pJmXaTV/EFaTZ0Hh7GCSOPJSRpw6sjQcjaHTVT1gzGSY2kHilXJA74HIxcrmpoBcFG6I zn5nPjaTzMdWh1enFb+vVhWEjiEvq2cXQBUb9ux3eR0FFu+RvPYh7nnOBanYBt7DoOE4 ee1GVpXSlWVskQRlIOpR9ftYXjuy73SdAzkwON8cVV5kXJYPMiu/OFZtL1vKVGIHbEVJ oS9w== 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 :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=j/l7eugevNuE+5HkuD8qrPrloFjduVCf6WX0iKCi5gg=; b=QizoVJU4vVhNrbfZA13CpRuwAkY/v4Ym3gSJPfnQMxj51Zqb1/2OQ05BovSzY/TZn1 ZBfPzIFFcL9fmUv9QrjH+l8ZedmRpH6xSUVz3y8mXi46+eFO83MV4b6A4t47hOv3mHbG K/JF7CCMR0QTWYqCN1Qq07+ogDbu7703UBwAHvcsFTsGC1s4wXfZNiWSPF6tNrdSLU4k DrTEVNJanr+SK/YdBZYS0CVqru0n6l8QsffDfCYz1cdw0/6FMS0bpM69guaodtR7FotE 9rwwJSCjiSeqd2IiMcjq3bFsobW/UIbswG6p+BvFbO9ZhIp4oFhQm+v1hz4yyVagHs0j /0UQ== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id w196si407000iow.24.2017.06.13.09.15.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jun 2017 09:15:09 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoRx-0008Ig-LQ; Tue, 13 Jun 2017 16:13:49 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoRw-0008Fq-N8 for xen-devel@lists.xen.org; Tue, 13 Jun 2017 16:13:48 +0000 Received: from [85.158.139.211] by server-7.bemta-5.messagelabs.com id 6D/3D-02181-C3F00495; Tue, 13 Jun 2017 16:13:48 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKLMWRWlGSWpSXmKPExsVysyfVTdeE3yH SoOe/tcWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmnHy1wu2gmUGFcfuzmJuYDyj0sXIySEksJlR YvmM3C5GLiD7NKPEqT+rmEASbAKaEnc+fwKzRQSkJa59vswIYjMLREg0LdgLFOfgEBbwkPjx0 QkkzCKgKnFn005WEJtXwFJi14SJbCC2hIC8xK62i2BxTgEriUvPmxgh9lpKNO9ezzSBkXsBI8 MqRo3i1KKy1CJdQ0O9pKLM9IyS3MTMHF1DA1O93NTi4sT01JzEpGK95PzcTYxA7zIAwQ7Gle3 OhxglOZiURHm3XLGJFOJLyk+pzEgszogvKs1JLT7EKMPBoSTBu5DPIVJIsCg1PbUiLTMHGGYw aQkOHiUR3vssQGne4oLE3OLMdIjUKUZFKXHeCSB9AiCJjNI8uDZYaF9ilJUS5mUEOkSIpyC1K DezBFX+FaM4B6OSMG8LD9AUnsy8Erjpr4AWMwEtvg5yM29xSSJCSqqBsVH3fganV/3K/JVbmr 5vZnY5YKLz7sT/XdP4J4vE6efxGs6u9d3wd9/e2qxExdhJC14dVrmX9fPqzdpa11NP7a5wzSx JkRK00zujcUAksczpnG1XULzAPe3pv+1jkhuV/0n7PChuLHecYPd35+mkxNydjHLHWw/HZMzq 0JVN+RHb3F6k552lxFKckWioxVxUnAgAAuFPB2gCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-14.tower-206.messagelabs.com!1497370420!64400387!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 56889 invoked from network); 13 Jun 2017 16:13:40 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-14.tower-206.messagelabs.com with SMTP; 13 Jun 2017 16:13:40 -0000 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 09DC31596; Tue, 13 Jun 2017 09:13:40 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 450213F557; Tue, 13 Jun 2017 09:13:39 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 13 Jun 2017 17:13:07 +0100 Message-Id: <20170613161323.25196-9-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170613161323.25196-1-julien.grall@arm.com> References: <20170613161323.25196-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org, punit.agrawal@arm.com Subject: [Xen-devel] [PATCH 08/24] xen/arm: mm: Use typesafe MFN in mfn_to_xen_entry X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/mm.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index d164ed2eda..08116679ec 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -259,7 +259,7 @@ void dump_hyp_walk(vaddr_t addr) * We put the same permissions at every level, because they're ignored * by the walker in non-leaf entries. */ -static inline lpae_t mfn_to_xen_entry(unsigned long mfn, unsigned attr) +static inline lpae_t mfn_to_xen_entry(mfn_t mfn, unsigned attr) { lpae_t e = (lpae_t) { .pt = { @@ -315,9 +315,9 @@ static inline lpae_t mfn_to_xen_entry(unsigned long mfn, unsigned attr) break; } - ASSERT(!(pfn_to_paddr(mfn) & ~PADDR_MASK)); + ASSERT(!(pfn_to_paddr(mfn_x(mfn)) & ~PADDR_MASK)); - e.pt.base = mfn; + e.pt.base = mfn_x(mfn); return e; } @@ -325,7 +325,7 @@ static inline lpae_t mfn_to_xen_entry(unsigned long mfn, unsigned attr) /* Map a 4k page in a fixmap entry */ void set_fixmap(unsigned map, unsigned long mfn, unsigned attributes) { - lpae_t pte = mfn_to_xen_entry(mfn, attributes); + lpae_t pte = mfn_to_xen_entry(_mfn(mfn), attributes); pte.pt.table = 1; /* 4k mappings always have this bit set */ pte.pt.xn = 1; write_pte(xen_fixmap + third_table_offset(FIXMAP_ADDR(map)), pte); @@ -363,7 +363,7 @@ static void __init create_mappings(lpae_t *second, count = nr_mfns / LPAE_ENTRIES; p = second + second_linear_offset(virt_offset); - pte = mfn_to_xen_entry(base_mfn, WRITEALLOC); + pte = mfn_to_xen_entry(_mfn(base_mfn), WRITEALLOC); if ( granularity == 16 * LPAE_ENTRIES ) pte.pt.contig = 1; /* These maps are in 16-entry contiguous chunks. */ for ( i = 0; i < count; i++ ) @@ -416,7 +416,7 @@ void *map_domain_page(mfn_t mfn) else if ( map[slot].pt.avail == 0 ) { /* Commandeer this 2MB slot */ - pte = mfn_to_xen_entry(slot_mfn, WRITEALLOC); + pte = mfn_to_xen_entry(_mfn(slot_mfn), WRITEALLOC); pte.pt.avail = 1; write_pte(map + slot, pte); break; @@ -537,7 +537,7 @@ static inline lpae_t pte_of_xenaddr(vaddr_t va) { paddr_t ma = va + phys_offset; unsigned long mfn = ma >> PAGE_SHIFT; - return mfn_to_xen_entry(mfn, WRITEALLOC); + return mfn_to_xen_entry(_mfn(mfn), WRITEALLOC); } /* Map the FDT in the early boot page table */ @@ -646,7 +646,7 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr) /* Initialise xen second level entries ... */ /* ... Xen's text etc */ - pte = mfn_to_xen_entry(xen_paddr>>PAGE_SHIFT, WRITEALLOC); + pte = mfn_to_xen_entry(_mfn(xen_paddr>>PAGE_SHIFT), WRITEALLOC); pte.pt.xn = 0;/* Contains our text mapping! */ xen_second[second_table_offset(XEN_VIRT_START)] = pte; @@ -663,7 +663,7 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr) /* ... Boot Misc area for xen relocation */ dest_va = BOOT_RELOC_VIRT_START; - pte = mfn_to_xen_entry(xen_paddr >> PAGE_SHIFT, WRITEALLOC); + pte = mfn_to_xen_entry(_mfn(xen_paddr >> PAGE_SHIFT), WRITEALLOC); /* Map the destination in xen_second. */ xen_second[second_table_offset(dest_va)] = pte; /* Map the destination in boot_second. */ @@ -694,7 +694,7 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr) unsigned long va = XEN_VIRT_START + (i << PAGE_SHIFT); if ( !is_kernel(va) ) break; - pte = mfn_to_xen_entry(mfn, WRITEALLOC); + pte = mfn_to_xen_entry(_mfn(mfn), WRITEALLOC); pte.pt.table = 1; /* 4k mappings always have this bit set */ if ( is_kernel_text(va) || is_kernel_inittext(va) ) { @@ -764,7 +764,8 @@ int init_secondary_pagetables(int cpu) * domheap mapping pages. */ for ( i = 0; i < DOMHEAP_SECOND_PAGES; i++ ) { - pte = mfn_to_xen_entry(virt_to_mfn(domheap+i*LPAE_ENTRIES), WRITEALLOC); + pte = mfn_to_xen_entry(_mfn(virt_to_mfn(domheap+i*LPAE_ENTRIES)), + WRITEALLOC); pte.pt.table = 1; write_pte(&first[first_table_offset(DOMHEAP_VIRT_START+i*FIRST_SIZE)], pte); } @@ -862,13 +863,13 @@ void __init setup_xenheap_mappings(unsigned long base_mfn, unsigned long first_mfn = alloc_boot_pages(1, 1); clear_page(mfn_to_virt(first_mfn)); - pte = mfn_to_xen_entry(first_mfn, WRITEALLOC); + pte = mfn_to_xen_entry(_mfn(first_mfn), WRITEALLOC); pte.pt.table = 1; write_pte(p, pte); first = mfn_to_virt(first_mfn); } - pte = mfn_to_xen_entry(mfn, WRITEALLOC); + pte = mfn_to_xen_entry(_mfn(mfn), WRITEALLOC); /* TODO: Set pte.pt.contig when appropriate. */ write_pte(&first[first_table_offset(vaddr)], pte); @@ -907,7 +908,7 @@ void __init setup_frametable_mappings(paddr_t ps, paddr_t pe) for ( i = 0; i < nr_second; i++ ) { clear_page(mfn_to_virt(second_base + i)); - pte = mfn_to_xen_entry(second_base + i, WRITEALLOC); + pte = mfn_to_xen_entry(_mfn(second_base + i), WRITEALLOC); pte.pt.table = 1; write_pte(&xen_first[first_table_offset(FRAMETABLE_VIRT_START)+i], pte); } @@ -960,7 +961,7 @@ static int create_xen_table(lpae_t *entry) if ( p == NULL ) return -ENOMEM; clear_page(p); - pte = mfn_to_xen_entry(virt_to_mfn(p), WRITEALLOC); + pte = mfn_to_xen_entry(_mfn(virt_to_mfn(p)), WRITEALLOC); pte.pt.table = 1; write_pte(entry, pte); return 0; @@ -1011,7 +1012,7 @@ static int create_xen_entries(enum xenmap_operation op, } if ( op == RESERVE ) break; - pte = mfn_to_xen_entry(mfn, ai); + pte = mfn_to_xen_entry(_mfn(mfn), ai); pte.pt.table = 1; write_pte(&third[third_table_offset(addr)], pte); break; From patchwork Tue Jun 13 16:13:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105402 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp486541qgd; Tue, 13 Jun 2017 09:15:38 -0700 (PDT) X-Received: by 10.157.36.47 with SMTP id p44mr580484ota.14.1497370538015; Tue, 13 Jun 2017 09:15:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497370538; cv=none; d=google.com; s=arc-20160816; b=NLO0afA63V2iJ43VFKgwD+Q/P8sCwxc6GKBvrfpTlucRlejvoSmWN1JRef3My20eQW fYjtUyMcD0+TMwVWcn9SscZ3HCjkZLRZKZgPg3HNmC2TnzBPQvNHkXrgFY/Y/CoobOmT QNdJ2DVmIKVmvrpvMxvbDaZUwRWFlZS/cf+FOw7v8DWrnTqHzNop0+qCn3oqe1xltnLj +if5/csvS4BIzdKEMf9JzUX+w6mvEY5TA5FWormN2A2LSuirxuYWnOsYb2omUCcc+JD9 4kfNqncyClm8VoNabFje4XAoOXEysMzxvY0tEvWHzKTOe7uSYCafEjx1AXXkLE7us5pr pYIg== 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 :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=Wujn8+7BIeElHopSLLNAtS5vXXJ3tlmjK0smXR7xufw=; b=WNXKymzNYiFTkcTbKVCpihhcSLdeDxAJW7G3xjJlzYYgimgaT7ZAamtVkvukjgdzJ3 Wtyc1SJzjGVheiZTMqvOc8r5+axjFSEdqO3EgfegRsP2Pb6aeFGyaJ50J8eMuinMbqKo LwgmvnTJTedbnFJZGQpJNSs61IjYOXV/de95HxBomxUW7P4KPhHuTNJd5L8zChORqjNJ xJ21J3jZGGblKnE7sUQnfZeYiDdDa+5slqPdRM5QiwUwY4gvsnEOyC0gcHIatS+ywQDS Rx4YJsHPORr0dldLQkvrbq+uFMnYrsjQNqXHX7vssx+1XSW+hnPx3+uJoMEytSiLC8tE y+8Q== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id k17si356266otk.169.2017.06.13.09.15.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jun 2017 09:15:38 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoRv-0008DL-Co; Tue, 13 Jun 2017 16:13:47 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoRt-00089r-7I for xen-devel@lists.xen.org; Tue, 13 Jun 2017 16:13:45 +0000 Received: from [85.158.143.35] by server-7.bemta-6.messagelabs.com id 13/09-03620-83F00495; Tue, 13 Jun 2017 16:13:44 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGLMWRWlGSWpSXmKPExsVysyfVTdeU3yH SYN0VHYslHxezODB6HN39mymAMYo1My8pvyKBNWP6iYssBdP4K64emcTSwDiRt4uRi0NIYDOj xM4F31ggnNOMEg+2TGXtYuTkYBPQlLjz+RMTiC0iIC1x7fNlRhCbWSBComnBXrC4sECqxOu1N 9hAbBYBVYmTj06ygNi8AlYSXR2PwOISAvISu9ougs3kBIpfet4ENkdIwFKiefd6pgmM3AsYGV YxqhenFpWlFula6iUVZaZnlOQmZuboGhqY6eWmFhcnpqfmJCYV6yXn525iBPqXAQh2MN7dFHC IUZKDSUmUd8sVm0ghvqT8lMqMxOKM+KLSnNTiQ4wyHBxKErz2fA6RQoJFqempFWmZOcBAg0lL cPAoifDeZwFK8xYXJOYWZ6ZDpE4xKkqJ804A6RMASWSU5sG1wYL7EqOslDAvI9AhQjwFqUW5m SWo8q8YxTkYlYR5l4BM4cnMK4Gb/gpoMRPQ4usgN/MWlyQipKQaGOUznX0vvfY/pnro4p4tST 8nTNObFdjbwPvtyPzKTZJCJnYZ+YF1y0XK1esW/N6ytTFp6XtBhdjQqS8zf7Gu8F3nxbYt5V7 KeWfnO8Xi32/MmubudPz+9den/3WbzI7zNTTcYJt3KyUuccGzXT5PRT6XBibZTV0VvGHOkim7 +Rj+HFJ7kPRQvVOJpTgj0VCLuag4EQChBWP3aQIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-7.tower-21.messagelabs.com!1497370421!73736992!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 57890 invoked from network); 13 Jun 2017 16:13:41 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-7.tower-21.messagelabs.com with SMTP; 13 Jun 2017 16:13:41 -0000 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 0AF6715A2; Tue, 13 Jun 2017 09:13:41 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 46FFC3F557; Tue, 13 Jun 2017 09:13:40 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 13 Jun 2017 17:13:08 +0100 Message-Id: <20170613161323.25196-10-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170613161323.25196-1-julien.grall@arm.com> References: <20170613161323.25196-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org, punit.agrawal@arm.com Subject: [Xen-devel] [PATCH 09/24] xen/arm: Define mfn_to_page/page_to_mfn in term of __mfn_to_page/__page_to_mfn X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" This is matching the x86 side where the __* version is used if you need to override the helpers in source files. At the same time, move the non-underscore version at the end of the defintion and add a comment to explain them. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/include/asm-arm/mm.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h index f6915ad882..cc3220a6b7 100644 --- a/xen/include/asm-arm/mm.h +++ b/xen/include/asm-arm/mm.h @@ -203,10 +203,8 @@ static inline void __iomem *ioremap_wc(paddr_t start, size_t len) }) /* Convert between machine frame numbers and page-info structures. */ -#define mfn_to_page(mfn) (frame_table + (pfn_to_pdx(mfn) - frametable_base_pdx)) -#define page_to_mfn(pg) pdx_to_pfn((unsigned long)((pg) - frame_table) + frametable_base_pdx) -#define __page_to_mfn(pg) page_to_mfn(pg) -#define __mfn_to_page(mfn) mfn_to_page(mfn) +#define __mfn_to_page(mfn) (frame_table + (pfn_to_pdx(mfn) - frametable_base_pdx)) +#define __page_to_mfn(pg) pdx_to_pfn((unsigned long)((pg) - frame_table) + frametable_base_pdx) /* Convert between machine addresses and page-info structures. */ #define maddr_to_page(ma) __mfn_to_page((ma) >> PAGE_SHIFT) @@ -264,6 +262,13 @@ static inline int gvirt_to_maddr(vaddr_t va, paddr_t *pa, unsigned int flags) #define virt_to_mfn(va) (virt_to_maddr(va) >> PAGE_SHIFT) #define mfn_to_virt(mfn) (maddr_to_virt((paddr_t)(mfn) << PAGE_SHIFT)) +/* + * We define non-underscored wrappers for above conversion functions. + * These are overriden in various source files while underscored version + * remain intact. + */ +#define mfn_to_page(mfn) __mfn_to_page(mfn) +#define page_to_mfn(pg) __page_to_mfn(pg) /* Convert between Xen-heap virtual addresses and page-info structures. */ static inline struct page_info *virt_to_page(const void *v) From patchwork Tue Jun 13 16:13:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105397 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp486470qgd; Tue, 13 Jun 2017 09:15:31 -0700 (PDT) X-Received: by 10.202.8.11 with SMTP id 11mr560265oii.41.1497370531564; Tue, 13 Jun 2017 09:15:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497370531; cv=none; d=google.com; s=arc-20160816; b=YNq3AuCuLdYZnWaDPghHGR+AbAp0/n6wEwtx2OyFZjJ0XvWHECf7PKpMyxKwgNYluc 2ZZBrAi1roWCWwq0Yntg1zFHZbgJ4Dy1TBwg8Imbh2WGT5j1R4lJ1v4+nvxwILphuaG0 ju9xtqAEtjU89dnLAlLuWVnSxlA31lK+kUmbSf+LTbJE35qnA7oAAnrtHAjYyPzd1wWs AYS7rfax7iuO8C+hajpt0R5an/oSmSt0ma2FVMHwGCnXCQKV0sq/anZPqqmVfYv37zkk PZdaV4+bdJICVOv4GLvxCyAy0iaTsV9yjTEXDxCnWAwuJsQbuJmGPF/wUzC5pvWv61Hs F8Vw== 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 :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=tsqLXDozsx2Q7jEfd5xj7rIbe6oyj6EfTX9ibesD9wE=; b=vIOjotbXHEjQbgGIyuj5vvXeCHwGM7nUfCFnSf/fCKdBOuIZlbygZ1vN57eBa0XxL/ rKZ6GRIHWzkVJo5B0OFiRLinyfaoSpQn4N8axt5t9hCngEEXGRaIE8ujanfhPi6Uhd07 6LjPaNBwMt7AuHkTPzaYpffwS/p9rXRm0mvD4MyCejvUKNIEdudwTA99MjgDImFD1Vvr tMzImqd7HvEmsMqbfNb09vCjAyWcVbZd6jH6cQHf5foZl2FxnxWsVXOVmzeWM3W0Pe11 HTcL7tl0xcdS0audxRCNsNertWTT09P1Z83xhTh5hZNJN4NqqSHmrfrojzyFEKPGPgw6 2LLg== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id c8si332383otd.236.2017.06.13.09.15.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jun 2017 09:15:31 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoRt-0008AV-3t; Tue, 13 Jun 2017 16:13:45 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoRr-00088e-Pg for xen-devel@lists.xen.org; Tue, 13 Jun 2017 16:13:43 +0000 Received: from [85.158.143.35] by server-10.bemta-6.messagelabs.com id 92/34-03613-73F00495; Tue, 13 Jun 2017 16:13:43 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrELMWRWlGSWpSXmKPExsVysyfVTdeM3yH S4MBqHYslHxezODB6HN39mymAMYo1My8pvyKBNeP0lvfsBc/YKt7P+MHSwNjP2sXIySEksJlR on1nRBcjF5B9mlHiZdNpZpAEm4CmxJ3Pn5hAbBEBaYlrny8zgtjMAhESTQv2gsWFBdIktt2+B xZnEVCV+PtkGRuIzStgJbF90k6wORIC8hK72i6CLeMEil963sQIsdhSonn3eqYJjNwLGBlWMW oUpxaVpRbpGhvrJRVlpmeU5CZm5ugaGpjp5aYWFyemp+YkJhXrJefnbmIE+pcBCHYw7lwfeIh RkoNJSZR3yxWbSCG+pPyUyozE4oz4otKc1OJDjDIcHEoSvPZ8DpFCgkWp6akVaZk5wECDSUtw 8CiJ8N5nAUrzFhck5hZnpkOkTjHqcjR92PKFSYglLz8vVUqc9w8vUJEASFFGaR7cCFjQX2KUl RLmZQQ6SoinILUoN7MEVf4VozgHo5IwbwsP0BSezLwSuE2vgI5gAjriOsj9vMUliQgpqQbGOd Lb6u/cd5hhwZG3b1b80o09zr4965ROLhE+W3UmZCIrt1vz6uVt6/u+L7glm3Z4z6u7as9Lamw EPddblNV8dnber3L0zLLmWZPbX/DUeEQU9loIfube1nRU67DJxIQjPoJlkQz5PyrWcSw47mSk 498/O5vBY/I1TleJzatS6/ecnMp8x61AiaU4I9FQi7moOBEA5M/KlnUCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-4.tower-21.messagelabs.com!1497370422!67510926!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 48273 invoked from network); 13 Jun 2017 16:13:42 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-4.tower-21.messagelabs.com with SMTP; 13 Jun 2017 16:13:42 -0000 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 0C2091596; Tue, 13 Jun 2017 09:13:42 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 483423F557; Tue, 13 Jun 2017 09:13:41 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 13 Jun 2017 17:13:09 +0100 Message-Id: <20170613161323.25196-11-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170613161323.25196-1-julien.grall@arm.com> References: <20170613161323.25196-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org, punit.agrawal@arm.com Subject: [Xen-devel] [PATCH 10/24] xen/arm: domain_build: Replace paddr_to_pfn(virt_to_maddr(.)) by virt_to_mfn(.) X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" paddr_to_pfn(virt_to_maddr(.)) and virt_to_mfn(.) are equivalent. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/domain_build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 3abacc0d80..a04c8862db 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1903,7 +1903,7 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo) rc = map_regions_p2mt(d, _gfn(paddr_to_pfn(d->arch.efi_acpi_gpa)), PFN_UP(d->arch.efi_acpi_len), - _mfn(paddr_to_pfn(virt_to_maddr(d->arch.efi_acpi_table))), + _mfn(virt_to_mfn(d->arch.efi_acpi_table)), p2m_mmio_direct_c); if ( rc != 0 ) { From patchwork Tue Jun 13 16:13:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105403 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp486544qgd; Tue, 13 Jun 2017 09:15:38 -0700 (PDT) X-Received: by 10.107.162.145 with SMTP id l139mr758390ioe.211.1497370538269; Tue, 13 Jun 2017 09:15:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497370538; cv=none; d=google.com; s=arc-20160816; b=c1EAcYp8djppulOvNWuFQGr7kh2T4jXw0Bk6cvAzgi+G/Aq68g6u4mOSjJbYW4DDIH CsoAngWLj7/aLnBzzEQoL9r4lwNmCWdY5ldOn+jlNZC0WMJWpEU3GX+z1tu5KpfxWqea cx+PFclosQZTRn4H1CZGCqGFVOpbYqrTPGOq2jDvXPfIbZ3n9Tl0ptnXvd8j1yCPYLsV hYRFdseZhu92CGBW7vyAgvxXvhlImuzx1VgQf6eJP9ijPGp29GQAMv3nu0BwvpVxVEu5 sF4ukrReGdMtOEcUsoPOxQA8WY+68oVoqe/L5dgfuDIq+1M7ew2Kqnz0vqb8PGiUx7dC vIYg== 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 :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=BZjnb/xWTIwhNEdthVSOhUZdK2rQru4T5pbGi7isLn0=; b=QVKrwAIve9Y2CSxef1i4tvX+Jzr4ffHZyPmhgsief686CCkj4tY3f3vw80FD/q7w4k wSgp7BN9RkcEoUnoAizUcWW5coo2Tbazhr2AyDd8cY/R7Uuc3vSGWBK5KwWjrPogn1hT 1kbzdRvcwkKE/6uBbhqdTXrlqCwAWPdpHyTLWdfeTPxeCgLU/LKCuYDIpwid57id+ZfN 1rT3pAz1ZTrxfNGUNuJLUXO2Po72w/pRn4hhVJRpRXsGniWPbMrMLzkqtTy3LrSIv9XF em37tuWNy9z5CEC7o0iLUIuJT8pBDQqDfwONoL5PU1gmkd6S67Uzg5R9Ae7krDJSwnoV aOMg== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id i8si418762iob.66.2017.06.13.09.15.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jun 2017 09:15:38 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoRv-0008Dr-Kt; Tue, 13 Jun 2017 16:13:47 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoRt-0008BQ-S6 for xen-devel@lists.xen.org; Tue, 13 Jun 2017 16:13:45 +0000 Received: from [85.158.139.211] by server-13.bemta-5.messagelabs.com id 7B/E4-01709-93F00495; Tue, 13 Jun 2017 16:13:45 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrILMWRWlGSWpSXmKPExsVysyfVTdec3yH SYOo/A4slHxezODB6HN39mymAMYo1My8pvyKBNeP6x6usBTtYK+7Mes3ewHiEpYuRi0NIYDOj RPOLzWxdjJxAzmlGiVnLTEBsNgFNiTufPzGB2CIC0hLXPl9mBLGZBSIkmhbsBYpzcAgLBEk8e xcKEmYRUJU4//AyWDmvgJXEpIVnWUFsCQF5iV1tF8FsTqD4pedNjBCrLCWad69nmsDIvYCRYR WjRnFqUVlqka6RqV5SUWZ6RkluYmaOrqGBqV5uanFxYnpqTmJSsV5yfu4mRqB36xkYGHcw7mr 3O8QoycGkJMq75YpNpBBfUn5KZUZicUZ8UWlOavEhRhkODiUJXns+h0ghwaLU9NSKtMwcYJjB pCU4eJREeO+zAKV5iwsSc4sz0yFSpxh1OZo+bPnCJMSSl5+XKiXO+4cXqEgApCijNA9uBCzkL zHKSgnzMjIwMAjxFKQW5WaWoMq/YhTnYFQS5m3hAZrCk5lXArfpFdARTEBHXAe5n7e4JBEhJd XAqK/kFF8mlCjnurPIgk9phd3Fg98Z1bQjIgQYDwSYdItdvdMQ1NGwx1vjztn/N+cy5N4v/Jq W+fD++YzbyhvX1S309VqgLBuwtdDp/uGVerM803RECj9dWjmxcVk+Wzyr+CZxDbWDBw82Ghzp cG/83bGGawHb6pysFTbGCjWlvB8fCHLcMFVUYinOSDTUYi4qTgQAjKH56XQCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-15.tower-206.messagelabs.com!1497370423!89208179!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 25766 invoked from network); 13 Jun 2017 16:13:43 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-15.tower-206.messagelabs.com with SMTP; 13 Jun 2017 16:13:43 -0000 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 0C1AF15A2; Tue, 13 Jun 2017 09:13:43 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 486B33F557; Tue, 13 Jun 2017 09:13:42 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 13 Jun 2017 17:13:10 +0100 Message-Id: <20170613161323.25196-12-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170613161323.25196-1-julien.grall@arm.com> References: <20170613161323.25196-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org, punit.agrawal@arm.com Subject: [Xen-devel] [PATCH 11/24] xen/arm: mm: Replace __va(pfn_to_paddr(...)) by mfn_to_virt X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" __va(pfn_to_paddr(...)) and mfn_to_virt are equivalent. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/mm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 08116679ec..f5df669d92 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -999,7 +999,7 @@ static int create_xen_entries(enum xenmap_operation op, BUG_ON(!xen_second[second_linear_offset(addr)].pt.valid); - third = __va(pfn_to_paddr(xen_second[second_linear_offset(addr)].pt.base)); + third = mfn_to_virt(xen_second[second_linear_offset(addr)].pt.base); switch ( op ) { case INSERT: From patchwork Tue Jun 13 16:13:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105399 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp486508qgd; Tue, 13 Jun 2017 09:15:34 -0700 (PDT) X-Received: by 10.36.1.205 with SMTP id 196mr824352itk.33.1497370534664; Tue, 13 Jun 2017 09:15:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497370534; cv=none; d=google.com; s=arc-20160816; b=ODlzvbnBmqmuX3cSZhzJz35Ip9gsZ7zWzxcQiBSUYe2ub/x9ijO2jSrocbNH/MM6V2 LYVy80V4LPlWdhcxgU9MN0O63RRj2psoSLe6H3nbweqnM/tMt5oOTBj7TIYr2zXWSDN/ 89+Egl5Xwi6CO255hwlEgnRiRPJGxmxgbnyuQ2w9uc6d03QjwQEQQzMnu5nxzlLPNQqI gmixwe/ef4rIGGJjdzvXglmB0rDbx03P9YzqiZ+jMiLFM5N7W7yQorw/1Zf6MonaDXjf nERYgeAcyNQdj6a3ENailgyWkHPWAoZO/vLKvhYUOItzm1jyW64vQjkuTDkgDcPwxwq/ Ex4Q== 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 :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=DjS+P8BqKsh4QrIjG/Zi1vk5WYUq/21cDI0xoSw0j/A=; b=wL1X/rD3Pdsi7bIcXltFBo9xq2TO7dFhQghZlS2f/BdLJ9CPWQHBXAFOf89qFQJhfB dQ/U0rrKQhk1lNxyX3dhF4nPumrnbEweqyScgca6wPllWItdZjy2toh3f/SdEaZRm2yj 6tJHkSCI06enC7kSnAFjn032cyrbT/Zop/yng8CcmDLoQ8XbESWLkVa0r9kNq9x9972s he/EHvcJFbpb7RZFktgIc/gJcm4Wd9F6sPrX7T1gvIONMt9B8V58r9GoSiJ8q/vIBfCv GdZb3/EvCqLih3WR8Jx/7J4VzlIO6De4yLwPc0jAnDd5S6T9yl9thfYIa+u4P8q/gPWV OY4g== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id n76si372960itg.101.2017.06.13.09.15.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jun 2017 09:15:34 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoRv-0008Ea-S4; Tue, 13 Jun 2017 16:13:47 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoRu-0008Bp-8r for xen-devel@lists.xen.org; Tue, 13 Jun 2017 16:13:46 +0000 Received: from [85.158.139.211] by server-17.bemta-5.messagelabs.com id D8/2B-19466-93F00495; Tue, 13 Jun 2017 16:13:45 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrOLMWRWlGSWpSXmKPExsVysyfVTdeS3yH SYOUrRoslHxezODB6HN39mymAMYo1My8pvyKBNePj7W7Ggu9yFZuePmJtYPwt2sXIxSEksJlR 4vKeD+wQzmlGifYjT4EcTg42AU2JO58/MYHYIgLSEtc+X2YEsZkFIiSaFuwFiwsLBEvs2/WVD cRmEVCV2LZtOiuIzStgJfH/+3+wuISAvMSutotgcU6g+KXnTWBzhAQsJZp3r2eawMi9gJFhFa NGcWpRWWqRrpGxXlJRZnpGSW5iZo6uoYGpXm5qcXFiempOYlKxXnJ+7iZGoIfrGRgYdzDuaPc 7xCjJwaQkyrvlik2kEF9SfkplRmJxRnxRaU5q8SFGGQ4OJQleez6HSCHBotT01Iq0zBxgqMGk JTh4lER477MApXmLCxJzizPTIVKnGBWlxHn/8AIlBEASGaV5cG2w8L7EKCslzMvIwMAgxFOQW pSbWYIq/4pRnINRSZi3hQdoCk9mXgnc9FdAi5mAFl8HuZm3uCQRISXVwFh295P1Op68vDet2e oPdN7c1oqZmvRKuK1DZuJeza2B0UGGmRenhUxiOD/3x/5Qe/sjs8qt6nNvmkysniHXuMGqTmb 69n5W2+xlDq9l7+YmvPi5LoRB4gEbA1dld/mZN083/w3hfnIiVzU2xm236Kpd26uZihIZfr+5 wvOeo2FPwQ7hq9KdzEosxRmJhlrMRcWJACJragtqAgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-2.tower-206.messagelabs.com!1497370424!82613440!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 51348 invoked from network); 13 Jun 2017 16:13:44 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-2.tower-206.messagelabs.com with SMTP; 13 Jun 2017 16:13:44 -0000 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 0E0871596; Tue, 13 Jun 2017 09:13:44 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4868B3F557; Tue, 13 Jun 2017 09:13:43 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 13 Jun 2017 17:13:11 +0100 Message-Id: <20170613161323.25196-13-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170613161323.25196-1-julien.grall@arm.com> References: <20170613161323.25196-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org, punit.agrawal@arm.com Subject: [Xen-devel] [PATCH 12/24] xen/arm: Replace DIV_ROUND_UP(..., PAGE_SIZE) by PFN_UP(...) X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" DIV_ROUND_UP(..., PAGE_SIZE) and PFN_UP(...) are equivalent. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/domain_build.c | 4 ++-- xen/arch/arm/gic-v2.c | 2 +- xen/arch/arm/gic-v3.c | 8 ++++---- xen/arch/arm/kernel.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index a04c8862db..a3243bdb5d 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1008,7 +1008,7 @@ static int map_range_to_domain(const struct dt_device_node *dev, { res = map_regions_p2mt(d, _gfn(paddr_to_pfn(addr)), - DIV_ROUND_UP(len, PAGE_SIZE), + PFN_UP(len), _mfn(paddr_to_pfn(addr)), mr_data->p2mt); @@ -1545,7 +1545,7 @@ static void acpi_map_other_tables(struct domain *d) size = acpi_gbl_root_table_list.tables[i].length; res = map_regions_p2mt(d, _gfn(paddr_to_pfn(addr)), - DIV_ROUND_UP(size, PAGE_SIZE), + PFN_UP(size), _mfn(paddr_to_pfn(addr)), p2m_mmio_direct_c); if ( res ) diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c index f8124e5e54..0482b1fe32 100644 --- a/xen/arch/arm/gic-v2.c +++ b/xen/arch/arm/gic-v2.c @@ -598,7 +598,7 @@ static int gicv2_map_hwdown_extra_mappings(struct domain *d) v2m_data->spi_start, v2m_data->nr_spis); ret = map_mmio_regions(d, _gfn(paddr_to_pfn(v2m_data->addr)), - DIV_ROUND_UP(v2m_data->size, PAGE_SIZE), + PFN_UP(v2m_data->size), _mfn(paddr_to_pfn(v2m_data->addr))); if ( ret ) { diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c index a559e5e260..bb845e955d 100644 --- a/xen/arch/arm/gic-v3.c +++ b/xen/arch/arm/gic-v3.c @@ -1283,7 +1283,7 @@ static int gicv3_iomem_deny_access(const struct domain *d) unsigned long mfn, nr; mfn = dbase >> PAGE_SHIFT; - nr = DIV_ROUND_UP(SZ_64K, PAGE_SIZE); + nr = PFN_UP(SZ_64K); rc = iomem_deny_access(d, mfn, mfn + nr); if ( rc ) return rc; @@ -1291,7 +1291,7 @@ static int gicv3_iomem_deny_access(const struct domain *d) for ( i = 0; i < gicv3.rdist_count; i++ ) { mfn = gicv3.rdist_regions[i].base >> PAGE_SHIFT; - nr = DIV_ROUND_UP(gicv3.rdist_regions[i].size, PAGE_SIZE); + nr = PFN_UP(gicv3.rdist_regions[i].size); rc = iomem_deny_access(d, mfn, mfn + nr); if ( rc ) return rc; @@ -1300,7 +1300,7 @@ static int gicv3_iomem_deny_access(const struct domain *d) if ( cbase != INVALID_PADDR ) { mfn = cbase >> PAGE_SHIFT; - nr = DIV_ROUND_UP(csize, PAGE_SIZE); + nr = PFN_UP(csize); rc = iomem_deny_access(d, mfn, mfn + nr); if ( rc ) return rc; @@ -1309,7 +1309,7 @@ static int gicv3_iomem_deny_access(const struct domain *d) if ( vbase != INVALID_PADDR ) { mfn = vbase >> PAGE_SHIFT; - nr = DIV_ROUND_UP(csize, PAGE_SIZE); + nr = PFN_UP(csize); return iomem_deny_access(d, mfn, mfn + nr); } diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c index e2512c4612..0ed8b6005c 100644 --- a/xen/arch/arm/kernel.c +++ b/xen/arch/arm/kernel.c @@ -312,7 +312,7 @@ static __init int kernel_decompress(struct bootmodule *mod) * Need to free pages after output_size here because they won't be * freed by discard_initial_modules */ - i = DIV_ROUND_UP(output_size, PAGE_SIZE); + i = PFN_UP(output_size); for ( ; i < (1 << kernel_order_out); i++ ) free_domheap_page(pages + i); From patchwork Tue Jun 13 16:13:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105398 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp486484qgd; Tue, 13 Jun 2017 09:15:33 -0700 (PDT) X-Received: by 10.107.59.213 with SMTP id i204mr825148ioa.94.1497370532966; Tue, 13 Jun 2017 09:15:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497370532; cv=none; d=google.com; s=arc-20160816; b=McqGQdIiU40XGprMzHxj+QOmGLADdtre2mbeLccr0NY246OpuwSa5PSzmTQv1Ve0BL s0MvLycpy9us+n2fRiAIJbY+yJTgtYqcP8NGRqwqUTC8Ah4aHmrUfVm9JXu2MYjusPBO 9aykLFeeFoWD082SrcNzirGoRXvTBqfBar0KGGzhG90T0gL0GWKfw6mVjjgiwosPHtOt y/cTB4DJk7NHPAznupOaUBDpHbIYmUZ/ddaR5x3uxbUVBWSt+ccdldaniY+7ugS9r7JY ++jiJqZs9dj0WxnIfvPfKQkbWB5paGNX6Tjnd0lT6Voy2J4tc2v0Re4uZvmKGPQUVK88 ymEg== 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 :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=nMP5+A10j3xiv7VRTQm+YNqRdga+en7AP7/HPClL2UU=; b=LwaVfPS+3S8t7WHZw6hgmOVKsJW2V+YK6YRJ8HqvF7X/HN8S149Jwu4G0BMEkOby+a ST2eVUSMoPmOsKLMKETO2FfDIgcDS4olTDuUp4X+23CTSJqd15zk/TpbltNeENZw/3th Hh2kNs5PbCG0dFVyZs6MUV02xlGwlKvvWMnSx0rVKsgUw43mAwapP4vhMKx8EFgqF0Ci takExn/Hmp1UjIxC/sda3Hx9c/IM+eS1gXawUihLe9Gfw38kGYzSZdzZYDNp7XyqBjAe LArDDhAZlRFkc1Mw4QTtW/eSPhUqobyxTmqiPZ9JPT9bNwCxkhOBcn227szyW69mirTG WdzQ== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 10si10586992itl.34.2017.06.13.09.15.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jun 2017 09:15:32 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoRw-0008FK-2x; Tue, 13 Jun 2017 16:13:48 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoRv-0008Cd-1i for xen-devel@lists.xen.org; Tue, 13 Jun 2017 16:13:47 +0000 Received: from [85.158.139.211] by server-6.bemta-5.messagelabs.com id 33/28-02180-A3F00495; Tue, 13 Jun 2017 16:13:46 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrOLMWRWlGSWpSXmKPExsVysyfVTdeS3yH S4OMaI4slHxezODB6HN39mymAMYo1My8pvyKBNWPf2aVMBVv4K66vPMXUwNjA08XIxSEksJlR 4taUXjYI5zSjxNPGTUxdjJwcbAKaEnc+fwKzRQSkJa59vswIYjMLREg0LdgLFhcWSJTYveAUm M0ioCqx7fhVFhCbV8BKYt+5BWBxCQF5iV1tF1lBbE6g+KXnTWBzhAQsJZp3r2eawMi9gJFhFa NGcWpRWWqRrqGZXlJRZnpGSW5iZo6uoYGpXm5qcXFiempOYlKxXnJ+7iZGoIcZgGAH4/nTnoc YJTmYlER5t1yxiRTiS8pPqcxILM6ILyrNSS0+xCjDwaEkwWvP5xApJFiUmp5akZaZAww1mLQE B4+SCO99FqA0b3FBYm5xZjpE6hSjopQ47wSQPgGQREZpHlwbLLwvMcpKCfMyAh0ixFOQWpSbW YIq/4pRnINRSZh3CcgUnsy8Erjpr4AWMwEtvg5yM29xSSJCSqqBMftABr/Ht9pL9rrvDl4SnZ sTs//vLYfn9ettRbcdeS8kfOffWi0fF6mvnAcmfo8Q8fAIj8i+0WSddvHk5VXpEtw+PI4h+nX rNt6qsTPP1eVtDTxQnpV3IOSacQNT71w3p0UHZlm9/l+aHnZC9UijzfFGdUXvE00rE8U0gk6l +IfMLZpwzm27EktxRqKhFnNRcSIArVKXYmoCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-6.tower-206.messagelabs.com!1497370425!103024706!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 37545 invoked from network); 13 Jun 2017 16:13:45 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-6.tower-206.messagelabs.com with SMTP; 13 Jun 2017 16:13:45 -0000 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 0EDDA15A2; Tue, 13 Jun 2017 09:13:45 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4AA363F557; Tue, 13 Jun 2017 09:13:44 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 13 Jun 2017 17:13:12 +0100 Message-Id: <20170613161323.25196-14-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170613161323.25196-1-julien.grall@arm.com> References: <20170613161323.25196-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org, punit.agrawal@arm.com Subject: [Xen-devel] [PATCH 13/24] xen/arm: traps: Replace p2m_lookup(..., ..., NULL) by gfn_to_mfn(..., ...) X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" gfn_to_mfn is a wrapper of p2m_lookup which does not return the p2m_type. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/traps.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 6cf9ee7244..ce19021f01 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -2481,7 +2481,7 @@ void dump_guest_s1_walk(struct domain *d, vaddr_t addr) uint32_t *first = NULL, *second = NULL; mfn_t mfn; - mfn = p2m_lookup(d, _gfn(paddr_to_pfn(ttbr0)), NULL); + mfn = gfn_to_mfn(d, _gfn(paddr_to_pfn(ttbr0))); printk("dom%d VA 0x%08"PRIvaddr"\n", d->domain_id, addr); printk(" TTBCR: 0x%08"PRIregister"\n", ttbcr); @@ -2513,7 +2513,7 @@ void dump_guest_s1_walk(struct domain *d, vaddr_t addr) (first[offset] & 0x2) ) goto done; - mfn = p2m_lookup(d, _gfn(paddr_to_pfn(first[offset])), NULL); + mfn = gfn_to_mfn(d, _gfn(paddr_to_pfn(first[offset]))); if ( mfn_eq(mfn, INVALID_MFN) ) { @@ -2619,7 +2619,7 @@ static void do_trap_instr_abort_guest(struct cpu_user_regs *regs, * with the Stage-2 page table. Walk the Stage-2 PT to check * if the entry exists. If it's the case, return to the guest */ - mfn = p2m_lookup(current->domain, _gfn(paddr_to_pfn(gpa)), NULL); + mfn = gfn_to_mfn(current->domain, _gfn(paddr_to_pfn(gpa))); if ( !mfn_eq(mfn, INVALID_MFN) ) return; } @@ -2759,7 +2759,7 @@ static void do_trap_data_abort_guest(struct cpu_user_regs *regs, * with the Stage-2 page table. Walk the Stage-2 PT to check * if the entry exists. If it's the case, return to the guest */ - mfn = p2m_lookup(current->domain, _gfn(paddr_to_pfn(info.gpa)), NULL); + mfn = gfn_to_mfn(current->domain, _gfn(paddr_to_pfn(info.gpa))); if ( !mfn_eq(mfn, INVALID_MFN) ) return; From patchwork Tue Jun 13 16:13:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105404 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp486549qgd; Tue, 13 Jun 2017 09:15:38 -0700 (PDT) X-Received: by 10.107.59.211 with SMTP id i202mr800208ioa.159.1497370538825; Tue, 13 Jun 2017 09:15:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497370538; cv=none; d=google.com; s=arc-20160816; b=G9dS7c9OXVyrlpg+HtB3d+AR4eXfFDfCJlxylH1nJntN5783bS6/9ZzYUQ63mOaF9T TyzigqjP5W9j+z/cvqlJEVeNGyeSeAvP2SF1CC7aHjoEo5AJkOS5M/WmJVJ2sY5nItUn DNQGzxUMFykzQYwqepuxdwenJSYgVClS+ItzghtUD26iwlzeOBsQKncY59PJRC5gLZFi Z54YkxApfumxJqemw4qnXhRU+YjxQWlioXn3itv/8X+K7k/cP0AykaWhRKl8Q+8DSeOY i7qZgTVFzWkL6J81WP62woor4NObxkefEmjhllLHyNzJdZG9M2rN2ByoIaJmljy7dKPx yMIA== 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 :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=iHuvf0MnJmoSwgvUlWF2DbznHCIxnp+PNrgT7koYSGs=; b=YDF+rrhk357UMPnuhp6NfaUyTabl4O7Y0JtXc0vWYngRSB5xVJbgXH4xKcNrqM/D0Y JQ1IABRWpmkv7m8bCGZs9C8wgxCSC3Ebzs4UEZdsQKnOGHd6t9y+zrNf09q7HdccMvaq x4PeCVtNJai4sRfZyE4JwUI8Mia01YI14gyzhOftOZtjDL/iXqtvOjm9sqVPhgn/S+// /X0PYOWlmuQyb5rsd1WodGynStd8Awr877pqEvjMtKCYjk11UmADe25g0Z3Cg+oZPm6s 2t64duk11IOOpgB3VW4dcvONP9O7Jh15RHWgbDqPR81Khm5io35GQiyabTc0le3Mpo+n B/Zw== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id l72si431444iod.97.2017.06.13.09.15.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jun 2017 09:15:38 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoRx-0008Hb-AE; Tue, 13 Jun 2017 16:13:49 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoRv-0008DI-QC for xen-devel@lists.xen.org; Tue, 13 Jun 2017 16:13:47 +0000 Received: from [85.158.143.35] by server-6.bemta-6.messagelabs.com id 84/DB-03920-B3F00495; Tue, 13 Jun 2017 16:13:47 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGLMWRWlGSWpSXmKPExsVysyfVTdeK3yH S4FSHrsWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmnF+yTmmgk0cFfMmnWBsYFzD3sXIxSEksJlR Yt/n/UxdjJxAzmlGia4bGSA2m4CmxJ3Pn8DiIgLSEtc+X2YEsZkFIiSaFuwFiwsLhEk8fAIRZ xFQlTg/6yxYnFfASmL+9C0sILaEgLzErraLrCA2J1D80vMmRohdlhLNu9czTWDkXsDIsIpRoz i1qCy1SNfYQC+pKDM9oyQ3MTNH19DATC83tbg4MT01JzGpWC85P3cTI9C/DECwg/Hv2sBDjJI cTEqivJ4CdpFCfEn5KZUZicUZ8UWlOanFhxhlODiUJHjt+RwihQSLUtNTK9Iyc4CBBpOW4OBR EuG9zwKU5i0uSMwtzkyHSJ1iVJQS5/3DC5QQAElklObBtcGC+xKjrJQwLyPQIUI8BalFuZklq PKvGMU5GJWEeVt4gKbwZOaVwE1/BbSYCWjx9Ss2IItLEhFSUg2M4ouuul7xspEIWSKg9W2pzQ 7nL7ymeWV/A/b03bQylglaN9N6j2/19IitT02Ln+wRXONX1vL/d1at5jHWn/yTep0rLzY0TbO ICpqdHH3fa+4GNp060VlaF7yDVmw9/mBVeOK/yj/MpUGne6csO/n2Y9bkrs1BebY/BSS0y6b/ /HhxmnqMlvMGJZbijERDLeai4kQAoUABPWkCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-6.tower-21.messagelabs.com!1497370426!50655265!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 38361 invoked from network); 13 Jun 2017 16:13:46 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-6.tower-21.messagelabs.com with SMTP; 13 Jun 2017 16:13:46 -0000 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 0F4EF1596; Tue, 13 Jun 2017 09:13:46 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4BA0A3F557; Tue, 13 Jun 2017 09:13:45 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 13 Jun 2017 17:13:13 +0100 Message-Id: <20170613161323.25196-15-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170613161323.25196-1-julien.grall@arm.com> References: <20170613161323.25196-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org, punit.agrawal@arm.com Subject: [Xen-devel] [PATCH 14/24] xen/arm: Introduce wrappers for MFN <-> MADDR and GFN <-> GADDR X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" The new wrappers will add more safety when converting an address to a frame number (either machine or guest). A follow-up patch will use them to simplify the code. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/include/asm-arm/mm.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h index cc3220a6b7..a42da20f0a 100644 --- a/xen/include/asm-arm/mm.h +++ b/xen/include/asm-arm/mm.h @@ -214,6 +214,10 @@ static inline void __iomem *ioremap_wc(paddr_t start, size_t len) #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 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)) +#define maddr_to_mfn(ma) _mfn(paddr_to_pfn(ma)) #define vmap_to_mfn(va) paddr_to_pfn(virt_to_maddr((vaddr_t)va)) #define vmap_to_page(va) mfn_to_page(vmap_to_mfn(va)) From patchwork Tue Jun 13 16:13:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105396 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp486455qgd; Tue, 13 Jun 2017 09:15:30 -0700 (PDT) X-Received: by 10.157.61.180 with SMTP id l49mr521486otc.55.1497370530610; Tue, 13 Jun 2017 09:15:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497370530; cv=none; d=google.com; s=arc-20160816; b=r0LKo8J9p7RFTzgrCEXCldyVe4HpJ/s3glLvHLKd8ysaQRSCwLoUVkwtxpmsPwlEEb d3HbmUhgCY0YVkaZoURNR5vpI4tG2NvqW6OhXAYyRuEYAu3USAWYSlDDRh8GylbOuORA ZWEKrd7ULZsXoU9/ofqqI5VyHTKK06VBUmc2s1sVOquR7UHplrMLCtDLJVNTXDDE6UK3 U+Pv2jzoq8BbfUOivtmCqzobSj0xMDqSQmTnb/ekVC35Az7UkNy9nhVimHGAIIVtQ+97 60ajjpjt88dQVxkrYDXF5dvDb/GtfVk3jNllqMybVf8aVatSeMJ2h6K9mAnzdNKgWym0 5EGg== 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 :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=NkkGJvftDd5lhiytVPw9+P0FVLGfwtMox52AKwihVG4=; b=V1qSFURv6Iheu/jRujLV/uC4jNxfDkk5XOayMMZIDSRvQATOuVxoW7ttE/zSqZoSQE 0DOSou+8x2HHSExqiB1fXLxHyEAyIxcyI0WRtM9esNhxcr3zeke4vNAfaYk4tRDAt1Hu VyO0HA4hr0PyBLT6bINgoa494wmBDCDoedc8lNWr7QEWaFufCYd8D6nU78ZN9M/2QTZK 4Y0nj+kXVLOGGlExRRL+tuSD3RYxJfuXaCKbwlij4Oyxn88ZuUNQeK+IGZzO3MDGACKf Fl1V0P5KBxVwgUIt91i+3ygo9cBMra+aN/ZDBR2LohNsum0i/ryJBREgGrdbmt6M6qge TJow== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id t11si339932oig.142.2017.06.13.09.15.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jun 2017 09:15:30 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoRy-0008Ky-TR; Tue, 13 Jun 2017 16:13:50 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoRx-0008HU-Ld for xen-devel@lists.xen.org; Tue, 13 Jun 2017 16:13:49 +0000 Received: from [193.109.254.147] by server-10.bemta-6.messagelabs.com id D2/74-03613-D3F00495; Tue, 13 Jun 2017 16:13:49 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrELMWRWlGSWpSXmKPExsVysyfVTdeG3yH SYO5pYYslHxezODB6HN39mymAMYo1My8pvyKBNWNd1zK2gqtlFdv3HGZrYOyN6GLk4hAS2Mwo 8eLAfcYuRk4g5zSjxN9ecRCbTUBT4s7nT0wgtoiAtMS1z5cZQRqYBdYxSmx+spmti5GDQ1ggQ aLrWDpIDYuAqsTPBT2sIDavgJXEzpWzwXolBOQldrVdBItzAsUvPW+C2mUp0bx7PdMERu4FjA yrGDWKU4vKUot0jQz0kooy0zNKchMzc3QNDcz0clOLixPTU3MSk4r1kvNzNzEC/csABDsYfy0 LOMQoycGkJMq75YpNpBBfUn5KZUZicUZ8UWlOavEhRhkODiUJ3h28DpFCgkWp6akVaZk5wECD SUtw8CiJ8N5nAUrzFhck5hZnpkOkTjHqclzq2/CFSYglLz8vVUqc9w/IDAGQoozSPLgRsKC/x CgrJczLCHSUEE9BalFuZgmq/CtGcQ5GJWHeFh6gKTyZeSVwm14BHcEEdMR1kPt5i0sSEVJSDY xqsfza/RtVpng+XbWB29om5NiqoyXt06c/3ib8YK1005lXEbxHk9tK51tWO9yq9TkxI7HsXUV XQeFXo9tzmtv3PTopdGsym4d+8QURtd/K67eY2p/Y03LgUp3NwsBYi3W55bIMbIo/DHo/c+ZJ 3u52tz/adD/+mPWjxSmbphpucljnuy9sp64SS3FGoqEWc1FxIgDOqtnvdQIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-2.tower-27.messagelabs.com!1497370427!47935449!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 40060 invoked from network); 13 Jun 2017 16:13:47 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-2.tower-27.messagelabs.com with SMTP; 13 Jun 2017 16:13:47 -0000 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 588491596; Tue, 13 Jun 2017 09:13:47 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4C34C3F557; Tue, 13 Jun 2017 09:13:46 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 13 Jun 2017 17:13:14 +0100 Message-Id: <20170613161323.25196-16-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170613161323.25196-1-julien.grall@arm.com> References: <20170613161323.25196-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org, Tamas K Lengyel , Razvan Cojocaru , punit.agrawal@arm.com Subject: [Xen-devel] [PATCH 15/24] xen/arm: Use the newly introduced MFN <-> MADDR and GFN <-> MADDR helpers X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Replace the following constructions: - _gfn(paddr_to_pfn(...)) => gaddr_to_gfn(...) - _mfn(paddr_to_pfn(...)) => maddr_to_mfn(...) - pfn_to_paddr(mfn_x(...)) => mfn_to_maddr(...) - pfn_to_paddr(gfn_x(...)) => gfn_to_gaddr(...) - _mfn(... >> PAGE_SHIFT) => maddr_to_mfn(...) Signed-off-by: Julien Grall Cc: Razvan Cojocaru Cc: Tamas K Lengyel Acked-by: Tamas K Lengyel Reviewed-by: Stefano Stabellini --- xen/arch/arm/domain_build.c | 12 ++++++------ xen/arch/arm/gic-v2.c | 4 ++-- xen/arch/arm/kernel.c | 2 +- xen/arch/arm/mem_access.c | 10 +++++----- xen/arch/arm/mm.c | 14 +++++++------- xen/arch/arm/p2m.c | 10 +++++----- xen/arch/arm/platforms/exynos5.c | 8 ++++---- xen/arch/arm/platforms/omap5.c | 16 ++++++++-------- xen/arch/arm/traps.c | 14 +++++++------- xen/arch/arm/vgic-v2.c | 4 ++-- 10 files changed, 47 insertions(+), 47 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index a3243bdb5d..c6776d76fc 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1007,9 +1007,9 @@ static int map_range_to_domain(const struct dt_device_node *dev, if ( need_mapping ) { res = map_regions_p2mt(d, - _gfn(paddr_to_pfn(addr)), + gaddr_to_gfn(addr), PFN_UP(len), - _mfn(paddr_to_pfn(addr)), + maddr_to_mfn(addr), mr_data->p2mt); if ( res < 0 ) @@ -1544,9 +1544,9 @@ static void acpi_map_other_tables(struct domain *d) addr = acpi_gbl_root_table_list.tables[i].address; size = acpi_gbl_root_table_list.tables[i].length; res = map_regions_p2mt(d, - _gfn(paddr_to_pfn(addr)), + gaddr_to_gfn(addr), PFN_UP(size), - _mfn(paddr_to_pfn(addr)), + maddr_to_mfn(addr), p2m_mmio_direct_c); if ( res ) { @@ -1901,7 +1901,7 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo) /* Map the EFI and ACPI tables to Dom0 */ rc = map_regions_p2mt(d, - _gfn(paddr_to_pfn(d->arch.efi_acpi_gpa)), + gaddr_to_gfn(d->arch.efi_acpi_gpa), PFN_UP(d->arch.efi_acpi_len), _mfn(virt_to_mfn(d->arch.efi_acpi_table)), p2m_mmio_direct_c); @@ -2014,7 +2014,7 @@ static void initrd_load(struct kernel_info *kinfo) return; } - dst = map_domain_page(_mfn(paddr_to_pfn(ma))); + dst = map_domain_page(maddr_to_mfn(ma)); copy_from_paddr(dst + s, paddr + offs, l); diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c index 0482b1fe32..5bf7d35a7e 100644 --- a/xen/arch/arm/gic-v2.c +++ b/xen/arch/arm/gic-v2.c @@ -597,9 +597,9 @@ static int gicv2_map_hwdown_extra_mappings(struct domain *d) d->domain_id, v2m_data->addr, v2m_data->size, v2m_data->spi_start, v2m_data->nr_spis); - ret = map_mmio_regions(d, _gfn(paddr_to_pfn(v2m_data->addr)), + ret = map_mmio_regions(d, gaddr_to_gfn(v2m_data->addr), PFN_UP(v2m_data->size), - _mfn(paddr_to_pfn(v2m_data->addr))); + maddr_to_mfn(v2m_data->addr)); if ( ret ) { printk(XENLOG_ERR "GICv2: Map v2m frame to d%d failed.\n", diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c index 0ed8b6005c..1b32d55284 100644 --- a/xen/arch/arm/kernel.c +++ b/xen/arch/arm/kernel.c @@ -183,7 +183,7 @@ static void kernel_zimage_load(struct kernel_info *info) return; } - dst = map_domain_page(_mfn(paddr_to_pfn(ma))); + dst = map_domain_page(maddr_to_mfn(ma)); copy_from_paddr(dst + s, paddr + offs, l); diff --git a/xen/arch/arm/mem_access.c b/xen/arch/arm/mem_access.c index 04b1506b00..bcf49f5c15 100644 --- a/xen/arch/arm/mem_access.c +++ b/xen/arch/arm/mem_access.c @@ -113,7 +113,7 @@ p2m_mem_access_check_and_get_page(vaddr_t gva, unsigned long flag, if ( rc < 0 ) goto err; - gfn = _gfn(paddr_to_pfn(ipa)); + gfn = gaddr_to_gfn(ipa); /* * We do this first as this is faster in the default case when no @@ -203,7 +203,7 @@ bool_t p2m_mem_access_check(paddr_t gpa, vaddr_t gla, const struct npfec npfec) if ( !p2m->mem_access_enabled ) return true; - rc = p2m_get_mem_access(v->domain, _gfn(paddr_to_pfn(gpa)), &xma); + rc = p2m_get_mem_access(v->domain, gaddr_to_gfn(gpa), &xma); if ( rc ) return true; @@ -245,13 +245,13 @@ bool_t p2m_mem_access_check(paddr_t gpa, vaddr_t gla, const struct npfec npfec) /* First, handle rx2rw and n2rwx conversion automatically. */ if ( npfec.write_access && xma == XENMEM_access_rx2rw ) { - rc = p2m_set_mem_access(v->domain, _gfn(paddr_to_pfn(gpa)), 1, + rc = p2m_set_mem_access(v->domain, gaddr_to_gfn(gpa), 1, 0, ~0, XENMEM_access_rw, 0); return false; } else if ( xma == XENMEM_access_n2rwx ) { - rc = p2m_set_mem_access(v->domain, _gfn(paddr_to_pfn(gpa)), 1, + rc = p2m_set_mem_access(v->domain, gaddr_to_gfn(gpa), 1, 0, ~0, XENMEM_access_rwx, 0); } @@ -273,7 +273,7 @@ bool_t p2m_mem_access_check(paddr_t gpa, vaddr_t gla, const struct npfec npfec) { /* A listener is not required, so clear the access * restrictions. */ - rc = p2m_set_mem_access(v->domain, _gfn(paddr_to_pfn(gpa)), 1, + rc = p2m_set_mem_access(v->domain, gaddr_to_gfn(gpa), 1, 0, ~0, XENMEM_access_rwx, 0); } } diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index f5df669d92..0014c24ecc 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -315,7 +315,7 @@ static inline lpae_t mfn_to_xen_entry(mfn_t mfn, unsigned attr) break; } - ASSERT(!(pfn_to_paddr(mfn_x(mfn)) & ~PADDR_MASK)); + ASSERT(!(mfn_to_maddr(mfn) & ~PADDR_MASK)); e.pt.base = mfn_x(mfn); @@ -536,8 +536,8 @@ void __init arch_init_memory(void) static inline lpae_t pte_of_xenaddr(vaddr_t va) { paddr_t ma = va + phys_offset; - unsigned long mfn = ma >> PAGE_SHIFT; - return mfn_to_xen_entry(_mfn(mfn), WRITEALLOC); + + return mfn_to_xen_entry(maddr_to_mfn(ma), WRITEALLOC); } /* Map the FDT in the early boot page table */ @@ -646,7 +646,7 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr) /* Initialise xen second level entries ... */ /* ... Xen's text etc */ - pte = mfn_to_xen_entry(_mfn(xen_paddr>>PAGE_SHIFT), WRITEALLOC); + pte = mfn_to_xen_entry(maddr_to_mfn(xen_paddr), WRITEALLOC); pte.pt.xn = 0;/* Contains our text mapping! */ xen_second[second_table_offset(XEN_VIRT_START)] = pte; @@ -663,7 +663,7 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr) /* ... Boot Misc area for xen relocation */ dest_va = BOOT_RELOC_VIRT_START; - pte = mfn_to_xen_entry(_mfn(xen_paddr >> PAGE_SHIFT), WRITEALLOC); + pte = mfn_to_xen_entry(maddr_to_mfn(xen_paddr), WRITEALLOC); /* Map the destination in xen_second. */ xen_second[second_table_offset(dest_va)] = pte; /* Map the destination in boot_second. */ @@ -690,11 +690,11 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr) /* Break up the Xen mapping into 4k pages and protect them separately. */ for ( i = 0; i < LPAE_ENTRIES; i++ ) { - unsigned long mfn = paddr_to_pfn(xen_paddr) + i; + mfn_t mfn = mfn_add(maddr_to_mfn(xen_paddr), i); unsigned long va = XEN_VIRT_START + (i << PAGE_SHIFT); if ( !is_kernel(va) ) break; - pte = mfn_to_xen_entry(_mfn(mfn), WRITEALLOC); + pte = mfn_to_xen_entry(mfn, WRITEALLOC); pte.pt.table = 1; /* 4k mappings always have this bit set */ if ( is_kernel_text(va) || is_kernel_inittext(va) ) { diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index b7bbea1d81..266d1c3bd6 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -311,7 +311,7 @@ mfn_t p2m_get_entry(struct p2m_domain *p2m, gfn_t gfn, p2m_type_t *t, p2m_access_t *a, unsigned int *page_order) { - paddr_t addr = pfn_to_paddr(gfn_x(gfn)); + paddr_t addr = gfn_to_gaddr(gfn); unsigned int level = 0; lpae_t entry, *table; int rc; @@ -542,7 +542,7 @@ static lpae_t mfn_to_p2m_entry(mfn_t mfn, p2m_type_t t, p2m_access_t a) p2m_set_permission(&e, t, a); - ASSERT(!(pfn_to_paddr(mfn_x(mfn)) & ~PADDR_MASK)); + ASSERT(!(mfn_to_maddr(mfn) & ~PADDR_MASK)); e.p2m.base = mfn_x(mfn); @@ -803,7 +803,7 @@ static int __p2m_set_entry(struct p2m_domain *p2m, p2m_type_t t, p2m_access_t a) { - paddr_t addr = pfn_to_paddr(gfn_x(sgfn)); + paddr_t addr = gfn_to_gaddr(sgfn); unsigned int level = 0; unsigned int target = 3 - (page_order / LPAE_SHIFT); lpae_t *entry, *table, orig_pte; @@ -1440,10 +1440,10 @@ struct page_info *get_page_from_gva(struct vcpu *v, vaddr_t va, if ( rc ) goto err; - if ( !mfn_valid(_mfn(maddr >> PAGE_SHIFT)) ) + if ( !mfn_valid(maddr_to_mfn(maddr)) ) goto err; - page = mfn_to_page(maddr >> PAGE_SHIFT); + page = mfn_to_page(mfn_x(maddr_to_mfn(maddr))); ASSERT(page); if ( unlikely(!get_page(page, d)) ) diff --git a/xen/arch/arm/platforms/exynos5.c b/xen/arch/arm/platforms/exynos5.c index 492cd3e11f..2ae5fa66e0 100644 --- a/xen/arch/arm/platforms/exynos5.c +++ b/xen/arch/arm/platforms/exynos5.c @@ -82,12 +82,12 @@ static int exynos5_init_time(void) static int exynos5250_specific_mapping(struct domain *d) { /* Map the chip ID */ - map_mmio_regions(d, _gfn(paddr_to_pfn(EXYNOS5_PA_CHIPID)), 1, - _mfn(paddr_to_pfn(EXYNOS5_PA_CHIPID))); + map_mmio_regions(d, gaddr_to_gfn(EXYNOS5_PA_CHIPID), 1, + maddr_to_mfn(EXYNOS5_PA_CHIPID)); /* Map the PWM region */ - map_mmio_regions(d, _gfn(paddr_to_pfn(EXYNOS5_PA_TIMER)), 2, - _mfn(paddr_to_pfn(EXYNOS5_PA_TIMER))); + map_mmio_regions(d, gaddr_to_gfn(EXYNOS5_PA_TIMER), 2, + maddr_to_mfn(EXYNOS5_PA_TIMER)); return 0; } diff --git a/xen/arch/arm/platforms/omap5.c b/xen/arch/arm/platforms/omap5.c index eadc4f8382..1e1f9fa970 100644 --- a/xen/arch/arm/platforms/omap5.c +++ b/xen/arch/arm/platforms/omap5.c @@ -101,20 +101,20 @@ static int omap5_init_time(void) static int omap5_specific_mapping(struct domain *d) { /* Map the PRM module */ - map_mmio_regions(d, _gfn(paddr_to_pfn(OMAP5_PRM_BASE)), 2, - _mfn(paddr_to_pfn(OMAP5_PRM_BASE))); + map_mmio_regions(d, gaddr_to_gfn(OMAP5_PRM_BASE), 2, + maddr_to_mfn(OMAP5_PRM_BASE)); /* Map the PRM_MPU */ - map_mmio_regions(d, _gfn(paddr_to_pfn(OMAP5_PRCM_MPU_BASE)), 1, - _mfn(paddr_to_pfn(OMAP5_PRCM_MPU_BASE))); + map_mmio_regions(d, gaddr_to_gfn(OMAP5_PRCM_MPU_BASE), 1, + maddr_to_mfn(OMAP5_PRCM_MPU_BASE)); /* Map the Wakeup Gen */ - map_mmio_regions(d, _gfn(paddr_to_pfn(OMAP5_WKUPGEN_BASE)), 1, - _mfn(paddr_to_pfn(OMAP5_WKUPGEN_BASE))); + map_mmio_regions(d, gaddr_to_gfn(OMAP5_WKUPGEN_BASE), 1, + maddr_to_mfn(OMAP5_WKUPGEN_BASE)); /* Map the on-chip SRAM */ - map_mmio_regions(d, _gfn(paddr_to_pfn(OMAP5_SRAM_PA)), 32, - _mfn(paddr_to_pfn(OMAP5_SRAM_PA))); + map_mmio_regions(d, gaddr_to_gfn(OMAP5_SRAM_PA), 32, + maddr_to_mfn(OMAP5_SRAM_PA)); return 0; } diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index ce19021f01..c07999b518 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -2481,12 +2481,12 @@ void dump_guest_s1_walk(struct domain *d, vaddr_t addr) uint32_t *first = NULL, *second = NULL; mfn_t mfn; - mfn = gfn_to_mfn(d, _gfn(paddr_to_pfn(ttbr0))); + mfn = gfn_to_mfn(d, gaddr_to_gfn(ttbr0)); printk("dom%d VA 0x%08"PRIvaddr"\n", d->domain_id, addr); printk(" TTBCR: 0x%08"PRIregister"\n", ttbcr); printk(" TTBR0: 0x%016"PRIx64" = 0x%"PRIpaddr"\n", - ttbr0, pfn_to_paddr(mfn_x(mfn))); + ttbr0, mfn_to_maddr(mfn)); if ( ttbcr & TTBCR_EAE ) { @@ -2508,12 +2508,12 @@ void dump_guest_s1_walk(struct domain *d, vaddr_t addr) offset = addr >> (12+8); printk("1ST[0x%"PRIx32"] (0x%"PRIpaddr") = 0x%08"PRIx32"\n", - offset, pfn_to_paddr(mfn_x(mfn)), first[offset]); + offset, mfn_to_maddr(mfn), first[offset]); if ( !(first[offset] & 0x1) || (first[offset] & 0x2) ) goto done; - mfn = gfn_to_mfn(d, _gfn(paddr_to_pfn(first[offset]))); + mfn = gfn_to_mfn(d, gaddr_to_gfn(first[offset])); if ( mfn_eq(mfn, INVALID_MFN) ) { @@ -2523,7 +2523,7 @@ void dump_guest_s1_walk(struct domain *d, vaddr_t addr) second = map_domain_page(mfn); offset = (addr >> 12) & 0x3FF; printk("2ND[0x%"PRIx32"] (0x%"PRIpaddr") = 0x%08"PRIx32"\n", - offset, pfn_to_paddr(mfn_x(mfn)), second[offset]); + offset, mfn_to_maddr(mfn), second[offset]); done: if (second) unmap_domain_page(second); @@ -2759,11 +2759,11 @@ static void do_trap_data_abort_guest(struct cpu_user_regs *regs, * with the Stage-2 page table. Walk the Stage-2 PT to check * if the entry exists. If it's the case, return to the guest */ - mfn = gfn_to_mfn(current->domain, _gfn(paddr_to_pfn(info.gpa))); + mfn = gfn_to_mfn(current->domain, gaddr_to_gfn(info.gpa)); if ( !mfn_eq(mfn, INVALID_MFN) ) return; - if ( try_map_mmio(_gfn(paddr_to_pfn(info.gpa))) ) + if ( try_map_mmio(gaddr_to_gfn(info.gpa)) ) return; break; diff --git a/xen/arch/arm/vgic-v2.c b/xen/arch/arm/vgic-v2.c index dc9f95b948..e5cfa33d8a 100644 --- a/xen/arch/arm/vgic-v2.c +++ b/xen/arch/arm/vgic-v2.c @@ -686,8 +686,8 @@ static int vgic_v2_domain_init(struct domain *d) * Map the gic virtual cpu interface in the gic cpu interface * region of the guest. */ - ret = map_mmio_regions(d, _gfn(paddr_to_pfn(cbase)), csize / PAGE_SIZE, - _mfn(paddr_to_pfn(vbase))); + ret = map_mmio_regions(d, gaddr_to_gfn(cbase), csize / PAGE_SIZE, + maddr_to_mfn(vbase)); if ( ret ) return ret; From patchwork Tue Jun 13 16:13:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105387 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp486348qgd; Tue, 13 Jun 2017 09:15:16 -0700 (PDT) X-Received: by 10.107.39.1 with SMTP id n1mr838984ion.8.1497370516250; Tue, 13 Jun 2017 09:15:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497370516; cv=none; d=google.com; s=arc-20160816; b=Ouw8SREn9h2U/crziOC2UYQS6hwZKq0WgayamYTZ8jXbtQgoJdEtjC4B/ZxpUeyQp4 Klc0XPosLJ+k3DgK9NUfb6BWDeYy7z0lB5vMK3Jdn+51xsvFbxfi7G5CX3Y2ZUxDhDts QSA3jUKm5DVc5Kpd6BJoexvb5cQ834vOTcoieKPv7XKIOtSeA/PgHMUDthM4QCn+3kAA D1G9MkvY5AIOwpqqw/V5yJt6vu9UHm+gM8q5Orh+/zY1/5W3Nsr0LmPRr0ekmoWLtn79 6Pn2GdaMdu94MGmRJYQuTQQyqF+BRw5fakC7YuMv4OHgWSEjmzGyLkifyadIyhI5XDXB CzVw== 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 :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=kRmqPLkv+R3xeONHf8j8Q2SunSsAl/Yd5pGatikTVYA=; b=FRcNYkgY5bovqvalaI9RCyAPRGdEoYBd/UAJNrd68CmCtG1jV1XSmieDcVvaLM2EGa iKXI7Kt5OeAQqe9BbetgW/kzoqskUmQM94nAZ6DFka8mxOkiqOTWxcC+ysOqN34dzwKS hsTLQOa628JtC0VUsQ0kTcs/cWw1+1ZQO6ebyUHBN4cWS0qDBw5qgSBCVYpuMpTX61p+ Fe//Qa11lqb8q5jlwXyMxlxoVqlSC1e/GKKnVFWNj8nxY2pktqqR2g5KrLsCoBMswhS6 V35hZpm5EPDT0xBB3bxX2hTBNMeTGSZbrAYW/IiUPSjkEyL1uZj8KlTFHp1mT5G+Eygl Da+A== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id f86si417420ioj.92.2017.06.13.09.15.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jun 2017 09:15:15 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoS0-0008NE-4z; Tue, 13 Jun 2017 16:13:52 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoRy-0008Jx-G0 for xen-devel@lists.xen.org; Tue, 13 Jun 2017 16:13:50 +0000 Received: from [193.109.254.147] by server-9.bemta-6.messagelabs.com id 34/81-03557-D3F00495; Tue, 13 Jun 2017 16:13:49 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrELMWRWlGSWpSXmKPExsVysyfVTdeW3yH S4MIZboslHxezODB6HN39mymAMYo1My8pvyKBNePj/J9MBauMKhadnMfawDhPvYuRi0NIYDOj xN2Ze5khnNOMEhdeT2PqYuTkYBPQlLjz+ROYLSIgLXHt82VGEJtZIEKiacFesLiwgJvEm+vv2 EBsFgFVib1X+oBsDg5eASuJy1tiQcISAvISu9ousoLYnEDhS8+bwMYICVhKNO9ezzSBkXsBI8 MqRo3i1KKy1CJdQwu9pKLM9IyS3MTMHF1DAzO93NTi4sT01JzEpGK95PzcTYxA/zIAwQ7Gmxs DDjFKcjApifJuuWITKcSXlJ9SmZFYnBFfVJqTWnyIUYaDQ0mC157PIVJIsCg1PbUiLTMHGGgw aQkOHiUR3vssQGne4oLE3OLMdIjUKUZdjg2r139hEmLJy89LlRLnnQAyQwCkKKM0D24ELOgvM cpKCfMyAh0lxFOQWpSbWYIq/4pRnINRSZi3hQdoCk9mXgncpldARzABHXEd5H7e4pJEhJRUA2 OOWeYl32mLWL+3hke3lh+ZPPnJf59PM2tYLn62l7JUzcsTTuLOkuOJK/y8pOi2j0zt3qNl3jH Gj/YyvFXj+/vY48TZN1XHjjFsD798trXtznYxXW/5E00HxM8uXHN5thHb3Xe+34M7b8zLW7Fz i91lhz2hLmnT13wSu2fgtTJbNlSw6qPJkqdKLMUZiYZazEXFiQA37zNNdQIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-14.tower-27.messagelabs.com!1497370428!95059963!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 34558 invoked from network); 13 Jun 2017 16:13:48 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-14.tower-27.messagelabs.com with SMTP; 13 Jun 2017 16:13:48 -0000 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 5B59C15A2; Tue, 13 Jun 2017 09:13:48 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 94F4F3F557; Tue, 13 Jun 2017 09:13:47 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 13 Jun 2017 17:13:15 +0100 Message-Id: <20170613161323.25196-17-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170613161323.25196-1-julien.grall@arm.com> References: <20170613161323.25196-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org, punit.agrawal@arm.com Subject: [Xen-devel] [PATCH 16/24] xen/arm: mm: Use typesafe mfn for xenheap_mfn_* X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Add more safety when using xenheap_mfn_*. Signed-off-by: Julien Grall --- xen/arch/arm/mm.c | 16 ++++++++-------- xen/arch/arm/setup.c | 18 +++++++++--------- xen/include/asm-arm/mm.h | 11 ++++++----- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 0014c24ecc..fb01f01879 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -138,8 +138,8 @@ uint64_t init_ttbr; static paddr_t phys_offset; /* Limits of the Xen heap */ -unsigned long xenheap_mfn_start __read_mostly = ~0UL; -unsigned long xenheap_mfn_end __read_mostly; +mfn_t xenheap_mfn_start __read_mostly = INVALID_MFN; +mfn_t xenheap_mfn_end __read_mostly; vaddr_t xenheap_virt_end __read_mostly; #ifdef CONFIG_ARM_64 vaddr_t xenheap_virt_start __read_mostly; @@ -801,8 +801,8 @@ void __init setup_xenheap_mappings(unsigned long base_mfn, /* Record where the xenheap is, for translation routines. */ xenheap_virt_end = XENHEAP_VIRT_START + nr_mfns * PAGE_SIZE; - xenheap_mfn_start = base_mfn; - xenheap_mfn_end = base_mfn + nr_mfns; + xenheap_mfn_start = _mfn(base_mfn); + xenheap_mfn_end = _mfn(base_mfn + nr_mfns); } #else /* CONFIG_ARM_64 */ void __init setup_xenheap_mappings(unsigned long base_mfn, @@ -816,16 +816,16 @@ void __init setup_xenheap_mappings(unsigned long base_mfn, mfn = base_mfn & ~((FIRST_SIZE>>PAGE_SHIFT)-1); /* First call sets the xenheap physical and virtual offset. */ - if ( xenheap_mfn_start == ~0UL ) + if ( mfn_eq(xenheap_mfn_start, INVALID_MFN) ) { - xenheap_mfn_start = base_mfn; + xenheap_mfn_start = _mfn(base_mfn); xenheap_virt_start = DIRECTMAP_VIRT_START + (base_mfn - mfn) * PAGE_SIZE; } - if ( base_mfn < xenheap_mfn_start ) + if ( base_mfn < mfn_x(xenheap_mfn_start) ) panic("cannot add xenheap mapping at %lx below heap start %lx", - base_mfn, xenheap_mfn_start); + base_mfn, mfn_x(xenheap_mfn_start)); end_mfn = base_mfn + nr_mfns; diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index ab4d8e4218..3b34855668 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -555,8 +555,8 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size) * and enough mapped pages for copying the DTB. */ dtb_pages = (dtb_size + PAGE_SIZE-1) >> PAGE_SHIFT; - boot_mfn_start = xenheap_mfn_end - dtb_pages - 1; - boot_mfn_end = xenheap_mfn_end; + boot_mfn_start = mfn_x(xenheap_mfn_end) - dtb_pages - 1; + boot_mfn_end = mfn_x(xenheap_mfn_end); init_boot_pages(pfn_to_paddr(boot_mfn_start), pfn_to_paddr(boot_mfn_end)); @@ -591,11 +591,11 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size) e = bank_end; /* Avoid the xenheap */ - if ( s < pfn_to_paddr(xenheap_mfn_start+xenheap_pages) - && pfn_to_paddr(xenheap_mfn_start) < e ) + if ( s < mfn_to_maddr(mfn_add(xenheap_mfn_start, xenheap_pages)) + && mfn_to_maddr(xenheap_mfn_start) < e ) { - e = pfn_to_paddr(xenheap_mfn_start); - n = pfn_to_paddr(xenheap_mfn_start+xenheap_pages); + e = mfn_to_maddr(xenheap_mfn_start); + n = mfn_to_maddr(mfn_add(xenheap_mfn_start, xenheap_pages)); } dt_unreserved_regions(s, e, init_boot_pages, 0); @@ -610,7 +610,7 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size) /* Add xenheap memory that was not already added to the boot allocator. */ - init_xenheap_pages(pfn_to_paddr(xenheap_mfn_start), + init_xenheap_pages(mfn_to_maddr(xenheap_mfn_start), pfn_to_paddr(boot_mfn_start)); } #else /* CONFIG_ARM_64 */ @@ -662,8 +662,8 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size) total_pages += ram_size >> PAGE_SHIFT; xenheap_virt_end = XENHEAP_VIRT_START + ram_end - ram_start; - xenheap_mfn_start = ram_start >> PAGE_SHIFT; - xenheap_mfn_end = ram_end >> PAGE_SHIFT; + xenheap_mfn_start = maddr_to_mfn(ram_start); + xenheap_mfn_end = maddr_to_mfn(ram_end); /* * Need enough mapped pages for copying the DTB. diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h index a42da20f0a..3dab6dc9a1 100644 --- a/xen/include/asm-arm/mm.h +++ b/xen/include/asm-arm/mm.h @@ -115,7 +115,7 @@ struct page_info #define PGC_count_width PG_shift(9) #define PGC_count_mask ((1UL<= xenheap_mfn_start && _mfn < xenheap_mfn_end); \ + (_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) @@ -235,7 +236,7 @@ static inline paddr_t __virt_to_maddr(vaddr_t va) static inline void *maddr_to_virt(paddr_t ma) { ASSERT(is_xen_heap_mfn(ma >> PAGE_SHIFT)); - ma -= pfn_to_paddr(xenheap_mfn_start); + ma -= mfn_to_maddr(xenheap_mfn_start); return (void *)(unsigned long) ma + XENHEAP_VIRT_START; } #else @@ -243,7 +244,7 @@ static inline void *maddr_to_virt(paddr_t ma) { ASSERT(pfn_to_pdx(ma >> PAGE_SHIFT) < (DIRECTMAP_SIZE >> PAGE_SHIFT)); return (void *)(XENHEAP_VIRT_START - - pfn_to_paddr(xenheap_mfn_start) + + mfn_to_maddr(xenheap_mfn_start) + ((ma & ma_va_bottom_mask) | ((ma & ma_top_mask) >> pfn_pdx_hole_shift))); } @@ -284,7 +285,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(xenheap_mfn_start); + pdx += pfn_to_pdx(mfn_x(xenheap_mfn_start)); return frame_table + pdx - frametable_base_pdx; } From patchwork Tue Jun 13 16:13:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105395 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp486448qgd; Tue, 13 Jun 2017 09:15:30 -0700 (PDT) X-Received: by 10.202.65.194 with SMTP id o185mr512383oia.10.1497370530160; Tue, 13 Jun 2017 09:15:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497370530; cv=none; d=google.com; s=arc-20160816; b=GM73n+EaMNT4xBH+KteiDgUaHecuTN/MMGG0RtK2LkDLrd8ehAmdItKcEV9Utt1vh4 GX9oVCDlD7H85n3TvhaI+vdb0sHA9Pb2bCzLyF8JpH6KFPEyD830lnA4k3EpBaOfSS67 gGf5/HPxmEoXux1dvayv/MPfs//UEGavhNZg7ONE5ycwxb47ztmrpTDlbRf1BZLxqFgG BNfq5jROOWMB4ssPISdU34CGiGXG0faHB3K+MDw4eSB/LD+UMjC8BZbLRxqGaPwj6Rf1 fRUIwVMiLRs1VBX2fTAis6lJl9/2Mk/dMCmjxDosKusr2WmjUR24bL9BIcgz46wosl5m NFBg== 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 :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=DUiy0QdAtuUVwSMHIZfFbTvu6xzn25wyPUdeGERGZ6E=; b=dUt28gy9DA72ANb4N/3oQ9ABElTWA8Xuv8KZNbXa3w3pSZVR4AqrSPzO0F2womLCYK F9UvXQBGYzWN8kpz/zU39pGIzvf1Z9C8TnClTAnwxTN7MM5WvnLoWJ+YoOH2rRrzqgzJ qR8cox1iTn0s1H9DH4q+MID1Q+M3yPJ22MPO+joz2oVt2Gt2IFkNSOSG8nE0sp7FgUIw +BpVfWWMzNYzHyPYDNKKi1FnBrY4zhB3PUDeC9iqjR7vHdE8kFN84guFELC6+5cUF3Xp ZHaeD+IIkVIS0yFBjL8am7H9CUZjYvZ4ZmMMQC/R/UksP+4/s8jokC5Xuv8CrK/ZaPGl IREw== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id o30si338251oto.180.2017.06.13.09.15.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jun 2017 09:15:30 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoS4-0008Vd-94; Tue, 13 Jun 2017 16:13:56 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoS2-0008RM-Oz for xen-devel@lists.xen.org; Tue, 13 Jun 2017 16:13:54 +0000 Received: from [85.158.143.35] by server-11.bemta-6.messagelabs.com id 1D/33-03587-24F00495; Tue, 13 Jun 2017 16:13:54 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGLMWRWlGSWpSXmKPExsVysyfVTdeR3yH S4Nx2foslHxezODB6HN39mymAMYo1My8pvyKBNePpsmVMBZ3KFbf6JzI2MN6X6WLk4hAS2Mwo 0XS/jRXCOc0osXvSRfYuRk4ONgFNiTufPzGB2CIC0hLXPl9mBLGZBSIkmhbsBYpzcAgLOEnsX i0JEmYRUJV4fXoqK4jNK2AlcXldO1irhIC8xK62i2BxTqD4pedNYGOEBCwlmnevZ5rAyL2AkW EVo0ZxalFZapGukaVeUlFmekZJbmJmjq6hgZlebmpxcWJ6ak5iUrFecn7uJkagfxmAYAfjgUW BhxglOZiURHm3XLGJFOJLyk+pzEgszogvKs1JLT7EKMPBoSTBu4PXIVJIsCg1PbUiLTMHGGgw aQkOHiUR3vssQGne4oLE3OLMdIjUKUZFKXHeCXxACQGQREZpHlwbLLgvMcpKCfMyAh0ixFOQW pSbWYIq/4pRnINRSZi3hQdoCk9mXgnc9FdAi5mAFl8HuZm3uCQRISXVwHg8Z/Z37xrps4LnXq W4vjyiusHJv/F2Vu+r76LsLpPLv51fxnFMrOVh+LyDq+/tnhjw85hkSr+ZZMSsJ5t6LhR/MVx vyL62zCvJdon/nnmXBCwenbVdrFkUKX9N6MlFhrZn2T+VY79tXmVcnHR4kZnMupdbHfR38YZo leSFrLXYp+jou/ntvBlKLMUZiYZazEXFiQATYV4EaQIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-5.tower-21.messagelabs.com!1497370432!65704477!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 55284 invoked from network); 13 Jun 2017 16:13:52 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-5.tower-21.messagelabs.com with SMTP; 13 Jun 2017 16:13:52 -0000 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 5F2B715B2; Tue, 13 Jun 2017 09:13:49 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 97F563F557; Tue, 13 Jun 2017 09:13:48 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 13 Jun 2017 17:13:16 +0100 Message-Id: <20170613161323.25196-18-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170613161323.25196-1-julien.grall@arm.com> References: <20170613161323.25196-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org, punit.agrawal@arm.com Subject: [Xen-devel] [PATCH 17/24] xen/arm: mm: Use typesafe MFN in set_fixmap X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/acpi/lib.c | 4 ++-- xen/arch/arm/kernel.c | 4 +--- xen/arch/arm/mm.c | 4 ++-- xen/arch/arm/platforms/vexpress.c | 2 +- xen/drivers/video/arm_hdlcd.c | 2 +- xen/include/asm-arm/mm.h | 2 +- 6 files changed, 8 insertions(+), 10 deletions(-) diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c index 9bd769cff6..70131b0736 100644 --- a/xen/arch/arm/acpi/lib.c +++ b/xen/arch/arm/acpi/lib.c @@ -31,7 +31,7 @@ char *__acpi_map_table(paddr_t phys, unsigned long size) offset = phys & (PAGE_SIZE - 1); mapped_size = PAGE_SIZE - offset; - set_fixmap(FIXMAP_ACPI_BEGIN, phys >> PAGE_SHIFT, PAGE_HYPERVISOR); + set_fixmap(FIXMAP_ACPI_BEGIN, maddr_to_mfn(phys), PAGE_HYPERVISOR); base = FIXMAP_ADDR(FIXMAP_ACPI_BEGIN); /* Most cases can be covered by the below. */ @@ -41,7 +41,7 @@ char *__acpi_map_table(paddr_t phys, unsigned long size) if ( ++idx > FIXMAP_ACPI_END ) return NULL; /* cannot handle this */ phys += PAGE_SIZE; - set_fixmap(idx, phys >> PAGE_SHIFT, PAGE_HYPERVISOR); + set_fixmap(idx, maddr_to_mfn(phys), PAGE_HYPERVISOR); mapped_size += PAGE_SIZE; } diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c index 1b32d55284..7403ec0c0e 100644 --- a/xen/arch/arm/kernel.c +++ b/xen/arch/arm/kernel.c @@ -49,14 +49,12 @@ void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len) void *src = (void *)FIXMAP_ADDR(FIXMAP_MISC); while (len) { - paddr_t p; unsigned long l, s; - p = paddr >> PAGE_SHIFT; s = paddr & (PAGE_SIZE-1); l = min(PAGE_SIZE - s, len); - set_fixmap(FIXMAP_MISC, p, BUFFERABLE); + set_fixmap(FIXMAP_MISC, maddr_to_mfn(paddr), BUFFERABLE); memcpy(dst, src + s, l); clean_dcache_va_range(dst, l); diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index fb01f01879..8573192e3a 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -323,9 +323,9 @@ static inline lpae_t mfn_to_xen_entry(mfn_t mfn, unsigned attr) } /* Map a 4k page in a fixmap entry */ -void set_fixmap(unsigned map, unsigned long mfn, unsigned attributes) +void set_fixmap(unsigned map, mfn_t mfn, unsigned attributes) { - lpae_t pte = mfn_to_xen_entry(_mfn(mfn), attributes); + lpae_t pte = mfn_to_xen_entry(mfn, attributes); pte.pt.table = 1; /* 4k mappings always have this bit set */ pte.pt.xn = 1; write_pte(xen_fixmap + third_table_offset(FIXMAP_ADDR(map)), pte); diff --git a/xen/arch/arm/platforms/vexpress.c b/xen/arch/arm/platforms/vexpress.c index 8e6a4eaa32..a26ac324ba 100644 --- a/xen/arch/arm/platforms/vexpress.c +++ b/xen/arch/arm/platforms/vexpress.c @@ -65,7 +65,7 @@ int vexpress_syscfg(int write, int function, int device, uint32_t *data) uint32_t *syscfg = (uint32_t *) FIXMAP_ADDR(FIXMAP_MISC); int ret = -1; - set_fixmap(FIXMAP_MISC, V2M_SYS_MMIO_BASE >> PAGE_SHIFT, DEV_SHARED); + set_fixmap(FIXMAP_MISC, maddr_to_mfn(V2M_SYS_MMIO_BASE), DEV_SHARED); if ( syscfg[V2M_SYS_CFGCTRL/4] & V2M_SYS_CFG_START ) goto out; diff --git a/xen/drivers/video/arm_hdlcd.c b/xen/drivers/video/arm_hdlcd.c index 8241cae117..3915f731f5 100644 --- a/xen/drivers/video/arm_hdlcd.c +++ b/xen/drivers/video/arm_hdlcd.c @@ -227,7 +227,7 @@ void __init video_init(void) /* uses FIXMAP_MISC */ set_pixclock(videomode->pixclock); - set_fixmap(FIXMAP_MISC, hdlcd_start >> PAGE_SHIFT, DEV_SHARED); + set_fixmap(FIXMAP_MISC, maddr_to_mfn(hdlcd_start), DEV_SHARED); HDLCD[HDLCD_COMMAND] = 0; HDLCD[HDLCD_LINELENGTH] = videomode->xres * bytes_per_pixel; diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h index 3dab6dc9a1..b2e7ea7761 100644 --- a/xen/include/asm-arm/mm.h +++ b/xen/include/asm-arm/mm.h @@ -176,7 +176,7 @@ extern void setup_xenheap_mappings(unsigned long base_mfn, unsigned long nr_mfns /* Map a frame table to cover physical addresses ps through pe */ extern void setup_frametable_mappings(paddr_t ps, paddr_t pe); /* Map a 4k page in a fixmap entry */ -extern void set_fixmap(unsigned map, unsigned long mfn, unsigned attributes); +extern void set_fixmap(unsigned map, mfn_t mfn, unsigned attributes); /* Remove a mapping from a fixmap entry */ extern void clear_fixmap(unsigned map); /* map a physical range in virtual memory */ From patchwork Tue Jun 13 16:13:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105385 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp486321qgd; Tue, 13 Jun 2017 09:15:12 -0700 (PDT) X-Received: by 10.36.58.145 with SMTP id m139mr17566604itm.34.1497370512504; Tue, 13 Jun 2017 09:15:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497370512; cv=none; d=google.com; s=arc-20160816; b=npeR7BQ1Az5py2NUi6KVjMwY5+xO/rG6SSWELzmfUpWJMLGBZJ5sXHg69CaQULwh0c Jkj3McKlKQDVC1ujdQYPjq5sv2htPzddEWbfkcX1fFUEgVi5O4m5n8uf1SwnlGfpQgmm XedofTw8YIT++6psPzy5wNOe9kpSCErh3JxRzcsggBrm8pycTnh+hS5QvVok/IN0p1aG nCYRh56UKine+pqLUMQZV7mlVuJfVGqIQHmreGgUH2L8YVbaruNS2bHipWbr139tIals 8kOvnU+o1MpktIIe6Ktr091WuPcOr7I+vrOYGhQO6dYDMO+NaEzxY3lQkO+jcwNu0Tvt qCdQ== 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 :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=hyDL7b8/Xxat6k83fH79bH1NujDa4z7GlsMsUfv2gfM=; b=PADbbrvdBlm7ovMJ+NDL/yFww6V1ATkC2ogUc/ipu/Y9Hq1qSoDPlN2zEWGHaTx8rY CaaGqd5pke02qcsuVnxpYuJoioUAg6fppvRG2hDN1K6GzfoOssrGw/MVdYvvvDZkJJNL R0Njze4XtjNvfQd4ktpQ4Vq8QIEUzyCheQSuFWUmLSEjtwtTBpgzTDlYH2uQAAQZ0Wa0 gQwhZgA7NTpB6RDCiRO29qwlpIFSTFIngtiwccO9+VmDKs7mIAVwJP8lSMPQE28X2Pp7 bKSH4DaqLkTM2MtPJ8n5RiwcQfPHy2CdoNPH7za9yhIKbUz6i2LO8ghDpd5lozvn6w3U j/oQ== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id o24si421051ioi.146.2017.06.13.09.15.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jun 2017 09:15:12 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoS2-0008Ra-Gs; Tue, 13 Jun 2017 16:13:54 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoS0-0008Nw-T2 for xen-devel@lists.xen.org; Tue, 13 Jun 2017 16:13:53 +0000 Received: from [85.158.137.68] by server-9.bemta-3.messagelabs.com id 70/2B-26749-04F00495; Tue, 13 Jun 2017 16:13:52 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrPLMWRWlGSWpSXmKPExsVysyfVTdee3yH SoPuBiMWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmnFwWXnBYfaK671n2RsYf7N2MXJyCAlsZpRo nVnQxcgFZJ9mlDhw+hA7SIJNQFPizudPTCC2iIC0xLXPlxlBbGaBCImmBXvB4sICLhJHJq0Gq ufgYBFQleg/aAsS5hWwkrh+4z9YiYSAvMSutotguziB4peeNzFC7LWUaN69nmkCI/cCRoZVjO rFqUVlqUW6FnpJRZnpGSW5iZk5uoYGxnq5qcXFiempOYlJxXrJ+bmbGIGeZQCCHYwX2p0PMUp yMCmJ8m65YhMpxJeUn1KZkVicEV9UmpNafIhRhoNDSYLXns8hUkiwKDU9tSItMwcYYjBpCQ4e JRHe+yxAad7igsTc4sx0iNQpRl2Opg9bvjAJseTl56VKifP+4QUqEgApyijNgxsBC/dLjLJSw ryMQEcJ8RSkFuVmlqDKv2IU52BUEuZt4QGawpOZVwK36RXQEUxAR1wHuZ+3uCQRISXVwFjeuj CiLFhpg3B44IS6r/r7H5ncNtWri9/3/EXOeWexE6E7Yi4cyy6TL9StVd7euGpuSFdi6qdlDgq xE5tmFBmrsdtwmmQlRv7zK3w8kXN6RFld8svmh89X/G1X/br8la+4n5rAul+t0V/OCE7p/GKy MPff24vH/x5Lv+bF4tk7VcZV4LXcbyWW4oxEQy3mouJEADVhco5yAgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-16.tower-31.messagelabs.com!1497370430!97858229!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 11115 invoked from network); 13 Jun 2017 16:13:51 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-16.tower-31.messagelabs.com with SMTP; 13 Jun 2017 16:13:51 -0000 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 5FCEB1596; Tue, 13 Jun 2017 09:13:50 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9BD2D3F557; Tue, 13 Jun 2017 09:13:49 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 13 Jun 2017 17:13:17 +0100 Message-Id: <20170613161323.25196-19-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170613161323.25196-1-julien.grall@arm.com> References: <20170613161323.25196-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org, punit.agrawal@arm.com Subject: [Xen-devel] [PATCH 18/24] xen/arm: mm: Use typesafe MFN in dump_pt_walk X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/mm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 8573192e3a..452c1e26c3 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -181,7 +181,7 @@ void dump_pt_walk(paddr_t ttbr, paddr_t addr, unsigned int nr_root_tables) { static const char *level_strs[4] = { "0TH", "1ST", "2ND", "3RD" }; - const unsigned long root_pfn = paddr_to_pfn(ttbr); + const mfn_t root_mfn = maddr_to_mfn(ttbr); const unsigned int offsets[4] = { zeroeth_table_offset(addr), first_table_offset(addr), @@ -215,7 +215,7 @@ void dump_pt_walk(paddr_t ttbr, paddr_t addr, else root_table = 0; - mapping = map_domain_page(_mfn(root_pfn + root_table)); + mapping = map_domain_page(mfn_add(root_mfn, root_table)); for ( level = root_level; ; level++ ) { From patchwork Tue Jun 13 16:13:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105382 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp486300qgd; Tue, 13 Jun 2017 09:15:10 -0700 (PDT) X-Received: by 10.107.164.219 with SMTP id d88mr827109ioj.157.1497370509947; Tue, 13 Jun 2017 09:15:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497370509; cv=none; d=google.com; s=arc-20160816; b=f1BRoAbob7dlZIRIXT1EgI4vh6tpodZDir190804ME/sQ39jr2z88kmsiNEHtrUwDZ meBjhDpmG00bdcf4o7yGSemNAiVKrb1WAqYhW+q0kAnWgm65wd+5uu3mr6tJD9VbONHx 6vzZgD6jGZMWUXDoFapJA2gBhxs0LI96ldiFN/RWoeQoSsqCJG00176FQcZu9v2bFX4l ETW4udSCr5eZ0067fiGLeZc7uCpmwm5JwisqcUDepwB1PcubEnIDGcVNWicfLFJvv8sh H/MZT9ADHWJuwFs92qEABHnxSAr/gO/y04qpr7UO5Fyr9o5p2huv3uSCBAInNfR9EATN jnfQ== 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 :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=ENAXNsPqBtFRLBZNrj+WWgFgWOj8D/GyqG9avc3j7EQ=; b=CzEqkswB6yjvBWgUobLy5bS339XRUdmnnmfkvJ6w4cuor7o8L+WFRywoYvQ4jPGxKm lGclXMcv0z7BjAUbo5kZqz61KtM958WcTLB+T7G5sFyvZSsNHeiPgcFqUL9bZcPmSh4O xcEngHuO6j3TsfgK+crVAgW9lkU8kUSa1p+noMV6mMzkBJAbqbRAx+EMWSqLPWmSchwF sMm4rHWlASayNS6bUDNunJwKuXuZQ+ARcyuCqoTgRjF1o5udnZs57uvKpqmE7kWrDhCB v9qbXnQrUtHpv/u+Io7wOHS/ZfuDKXM/7O4xC2v4h3Zh/HjXuF/N3yCKVJtkpFYm/RrZ I8uw== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id e70si405186ioj.189.2017.06.13.09.15.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jun 2017 09:15:09 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoS2-0008SF-O6; Tue, 13 Jun 2017 16:13:54 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoS1-0008Os-64 for xen-devel@lists.xen.org; Tue, 13 Jun 2017 16:13:53 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id 3E/53-03696-04F00495; Tue, 13 Jun 2017 16:13:52 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrCLMWRWlGSWpSXmKPExsVysyfVTdeB3yH SYPsrVoslHxezODB6HN39mymAMYo1My8pvyKBNWPK16msBQ/EK3btNmhg/CPUxcjFISSwmVHi +Is2xi5GTiDnNKNE15JSEJtNQFPizudPTCC2iIC0xLXPl8FqmAUiJJoW7AWKc3AIC0RKbF9cD hJmEVCV2PPhETOIzStgJbH2zA02EFtCQF5iV9tFVhCbEyh+6XkT1CpLiebd65kmMHIvYGRYxa hRnFpUllqka2yol1SUmZ5RkpuYmaNraGCml5taXJyYnpqTmFSsl5yfu4kR6FsGINjB2LQo8BC jJAeTkijvlis2kUJ8SfkplRmJxRnxRaU5qcWHGGU4OJQkeHfwOkQKCRalpqdWpGXmAIMMJi3B waMkwnufBSjNW1yQmFucmQ6ROsWoKCXO+wekTwAkkVGaB9cGC+xLjLJSwryMQIcI8RSkFuVml qDKv2IU52BUEuZt4QGawpOZVwI3/RXQYiagxddBbuYtLklESEk1MGaFXnm497qjVtXGr5vmMg ZbzKn89stqx68lvbG3c3fote5lmCrzNlF9LufBW8G23+aVJV421hJLl1u12qbS4AbnZMP76zd JvE7osusWtlXcecVw19YfWQcsLXR6lnmIxEyuijsyqftokrv8v2xf6+KSx4avS17bS017e3S1 hEWsh+eSjQ8DpZVYijMSDbWYi4oTAXcAt2FnAgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-15.tower-27.messagelabs.com!1497370431!54632337!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 33967 invoked from network); 13 Jun 2017 16:13:51 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-15.tower-27.messagelabs.com with SMTP; 13 Jun 2017 16:13:51 -0000 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 636FC15A2; Tue, 13 Jun 2017 09:13:51 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9C95B3F557; Tue, 13 Jun 2017 09:13:50 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 13 Jun 2017 17:13:18 +0100 Message-Id: <20170613161323.25196-20-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170613161323.25196-1-julien.grall@arm.com> References: <20170613161323.25196-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org, punit.agrawal@arm.com Subject: [Xen-devel] [PATCH 19/24] xen/arm: p2m: Redefine mfn_to_page and page_to_mfn to use typesafe X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" The file xen/arch/arm/p2m.c is using typesafe MFN in most of the place. This requires caller to mfn_to_page and page_to_mfn to use _mfn/mfn_x. To avoid extra _mfn/mfn_x, re-define mfn_to_page and page_to_mfn within xen/arch/arm/p2m.c to handle typesafe MFN. Signed-off-by: Julien Grall --- xen/arch/arm/p2m.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 266d1c3bd6..6c1ac70044 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -38,6 +38,12 @@ static unsigned int __read_mostly max_vmid = MAX_VMID_8_BIT; #define P2M_ROOT_PAGES (1<domain_id, addr); printk("P2M @ %p mfn:0x%lx\n", - p2m->root, page_to_mfn(p2m->root)); + p2m->root, mfn_x(page_to_mfn(p2m->root))); dump_pt_walk(page_to_maddr(p2m->root), addr, P2M_ROOT_LEVEL, P2M_ROOT_PAGES); @@ -591,7 +597,7 @@ static int p2m_create_table(struct p2m_domain *p2m, lpae_t *entry) * The access value does not matter because the hardware will ignore * the permission fields for table entry. */ - pte = mfn_to_p2m_entry(_mfn(page_to_mfn(page)), p2m_invalid, + pte = mfn_to_p2m_entry(page_to_mfn(page), p2m_invalid, p2m->default_access); p2m_write_pte(entry, pte, p2m->clean_pte); @@ -650,9 +656,9 @@ static void p2m_put_l3_page(const lpae_t pte) */ if ( p2m_is_foreign(pte.p2m.type) ) { - unsigned long mfn = pte.p2m.base; + mfn_t mfn = _mfn(pte.p2m.base); - ASSERT(mfn_valid(_mfn(mfn))); + ASSERT(mfn_valid(mfn)); put_page(mfn_to_page(mfn)); } } @@ -702,7 +708,7 @@ static void p2m_free_entry(struct p2m_domain *p2m, mfn = _mfn(entry.p2m.base); ASSERT(mfn_valid(mfn)); - pg = mfn_to_page(mfn_x(mfn)); + pg = mfn_to_page(mfn); page_list_del(pg, &p2m->pages); free_domheap_page(pg); @@ -780,7 +786,7 @@ static bool p2m_split_superpage(struct p2m_domain *p2m, lpae_t *entry, unmap_domain_page(table); - pte = mfn_to_p2m_entry(_mfn(page_to_mfn(page)), p2m_invalid, + pte = mfn_to_p2m_entry(page_to_mfn(page), p2m_invalid, p2m->default_access); /* @@ -1443,7 +1449,7 @@ struct page_info *get_page_from_gva(struct vcpu *v, vaddr_t va, if ( !mfn_valid(maddr_to_mfn(maddr)) ) goto err; - page = mfn_to_page(mfn_x(maddr_to_mfn(maddr))); + page = mfn_to_page(maddr_to_mfn(maddr)); ASSERT(page); if ( unlikely(!get_page(page, d)) ) From patchwork Tue Jun 13 16:13:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105386 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp486344qgd; Tue, 13 Jun 2017 09:15:16 -0700 (PDT) X-Received: by 10.157.83.29 with SMTP id g29mr640709oth.20.1497370515979; Tue, 13 Jun 2017 09:15:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497370515; cv=none; d=google.com; s=arc-20160816; b=E+3yVdn0d4aj05h8U1R/JttbdM8GMAU1cEWIfKISwjSCwP4YXTmRB46VhEu9ucAEqB Q5rxfvdEe3GVmMq5CGSZ1BJ0fNJ5ptP8LavqLu5GoqvwTQcLbcFKhKTMA1dHyXuX0lWn D5wc43ZTNCg9COL3//EiQf4cwyzOU3QOEX8hN9Ftwly1EPGI3fMdnEBuxXMaFanCY9eb eitKkef/2EPAmhCAlZ0wrYxwbvKDAQ/e2FjR19IVVDYfjnSsPY31PbbDhPINFcV74Lz0 Wwe/7iRBFzMbHql11qcTcoO8lJp5/IAda3P5OsW5GdKeoR+2hjCR5MVLlfCjQbGRbcy0 OidQ== 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 :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=a21w7YFp8hSHK3q1Mk9Tmitx71HChTZB5AejyAvJAVM=; b=NZJPlN3RNg0H2tWfdx82CH+badXe+qnaH4K329/wJ/Zgci9IEikcnoaSozde8Nx2ry +zLcGPPnevfCVkhsPFlECWey/DR5h3gkEMkgbquy2MxFCogiONg0PopmmzcsUy+BQ4FL djOQBhpc+A3s0OGAV5nF/TYZ+8szjNRsUN3PCGLFkTctFaghLTBD7l6wzZhvsuGgDEPH yZuZc7ATLH19jDqcskERab+ReXXo9z6pfYoQ0SZdrLx2D8nHE/mYbaWPswYFpakyXWbu ZqoIzfN9+zLD1rSbu3ttuma3/Nisjz9xCW5wEaAXAPZrq7hWGmuseaPYGbnnm/aX5cB5 yf7w== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id x16si329205otd.133.2017.06.13.09.15.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jun 2017 09:15:15 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoS4-0008Uq-11; Tue, 13 Jun 2017 16:13:56 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoS2-0008R8-KO for xen-devel@lists.xen.org; Tue, 13 Jun 2017 16:13:54 +0000 Received: from [193.109.254.147] by server-3.bemta-6.messagelabs.com id 32/F9-03058-14F00495; Tue, 13 Jun 2017 16:13:53 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrOLMWRWlGSWpSXmKPExsVysyfVTdeR3yH SYOIWQYslHxezODB6HN39mymAMYo1My8pvyKBNePF2S8sBefkKvb+amNtYNwo0cXIxSEksJlR Yu7SGYwQzmlGiV9Xuli7GDk52AQ0Je58/sQEYosISEtc+3yZEcRmFoiQaFqwFywuLOAj0fz5M JjNIqAqsWHrcrAaXgEriWf/v7KB2BIC8hK72i6CzeQEil963gRWIyRgKdG8ez3TBEbuBYwMqx g1ilOLylKLdI1M9ZKKMtMzSnITM3N0DQ3M9HJTi4sT01NzEpOK9ZLzczcxAj3MAAQ7GFctCDz EKMnBpCTKu+WKTaQQX1J+SmVGYnFGfFFpTmrxIUYZDg4lCV57PodIIcGi1PTUirTMHGCowaQl OHiURHjvswCleYsLEnOLM9MhUqcYFaXEef/wAiUEQBIZpXlwbbDwvsQoKyXMywh0iBBPQWpRb mYJqvwrRnEORiVh3hYeoCk8mXklcNNfAS1mAlp8HeRm3uKSRISUVANjut9FLaWXUT4POSXyqz hedPItiPkhqpaVLjDBIdbnuWn88wvdQZsvNVx3cNh0ieu+7bTH6xZt8t93sL3i7I69QVsyitv mHe1fW8nS3d6/WdzO/eZeAau5ziH6Ca+0p3477r/bmLm5N7xFYVoj902vSKuidv6MugCRyZw7 DNZtC2jybi5Lu6XEUpyRaKjFXFScCACkqWbsagIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-7.tower-27.messagelabs.com!1497370432!102885192!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 55612 invoked from network); 13 Jun 2017 16:13:53 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-7.tower-27.messagelabs.com with SMTP; 13 Jun 2017 16:13:53 -0000 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 65ADB1596; Tue, 13 Jun 2017 09:13:52 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A07783F557; Tue, 13 Jun 2017 09:13:51 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 13 Jun 2017 17:13:19 +0100 Message-Id: <20170613161323.25196-21-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170613161323.25196-1-julien.grall@arm.com> References: <20170613161323.25196-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org, punit.agrawal@arm.com Subject: [Xen-devel] [PATCH 20/24] xen/arm: mm: Redefine virt_to_mfn to support typesafe X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" The file xen/arch/arm/mm.c is using the typesafe MFN in most of the place. This requires all caller of virt_to_mfn to prefixed by _mfn(...). To avoid the extra _mfn(...), re-defined virt_to_mfn within arch/arm/mm.c to handle typesafe MFN. This patch also introduce __virt_to_mfn, so virt_to_mfn can be re-defined easily. Signed-off-by: Julien Grall --- xen/arch/arm/mm.c | 16 ++++++++++------ xen/include/asm-arm/mm.h | 3 ++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 452c1e26c3..2ff1688f3f 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -44,6 +44,10 @@ struct domain *dom_xen, *dom_io, *dom_cow; +/* Override macros from asm/page.h to make them work with mfn_t */ +#undef virt_to_mfn +#define virt_to_mfn(va) _mfn(__virt_to_mfn(va)) + /* Static start-of-day pagetables that we use before the allocators * are up. These are used by all CPUs during bringup before switching * to the CPUs own pagetables. @@ -479,7 +483,7 @@ unsigned long domain_page_map_to_mfn(const void *ptr) unsigned long offset = (va>>THIRD_SHIFT) & LPAE_ENTRY_MASK; if ( va >= VMAP_VIRT_START && va < VMAP_VIRT_END ) - return virt_to_mfn(va); + return mfn_x(virt_to_mfn(va)); ASSERT(slot >= 0 && slot < DOMHEAP_ENTRIES); ASSERT(map[slot].pt.avail != 0); @@ -764,7 +768,7 @@ int init_secondary_pagetables(int cpu) * domheap mapping pages. */ for ( i = 0; i < DOMHEAP_SECOND_PAGES; i++ ) { - pte = mfn_to_xen_entry(_mfn(virt_to_mfn(domheap+i*LPAE_ENTRIES)), + pte = mfn_to_xen_entry(virt_to_mfn(domheap+i*LPAE_ENTRIES), WRITEALLOC); pte.pt.table = 1; write_pte(&first[first_table_offset(DOMHEAP_VIRT_START+i*FIRST_SIZE)], pte); @@ -961,7 +965,7 @@ static int create_xen_table(lpae_t *entry) if ( p == NULL ) return -ENOMEM; clear_page(p); - pte = mfn_to_xen_entry(_mfn(virt_to_mfn(p)), WRITEALLOC); + pte = mfn_to_xen_entry(virt_to_mfn(p), WRITEALLOC); pte.pt.table = 1; write_pte(entry, pte); return 0; @@ -1216,7 +1220,7 @@ int xenmem_add_to_physmap_one( unsigned long idx, gfn_t gfn) { - unsigned long mfn = 0; + mfn_t mfn = INVALID_MFN; int rc; p2m_type_t t; struct page_info *page = NULL; @@ -1302,7 +1306,7 @@ int xenmem_add_to_physmap_one( return -EINVAL; } - mfn = page_to_mfn(page); + mfn = _mfn(page_to_mfn(page)); t = p2m_map_foreign; rcu_unlock_domain(od); @@ -1321,7 +1325,7 @@ int xenmem_add_to_physmap_one( } /* Map at new location. */ - rc = guest_physmap_add_entry(d, gfn, _mfn(mfn), 0, t); + rc = guest_physmap_add_entry(d, gfn, mfn, 0, t); /* If we fail to add the mapping, we need to drop the reference we * took earlier on foreign pages */ diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h index b2e7ea7761..6e2b3c7f2b 100644 --- a/xen/include/asm-arm/mm.h +++ b/xen/include/asm-arm/mm.h @@ -264,7 +264,7 @@ static inline int gvirt_to_maddr(vaddr_t va, paddr_t *pa, unsigned int flags) #define __va(x) (maddr_to_virt(x)) /* Convert between Xen-heap virtual addresses and machine frame numbers. */ -#define virt_to_mfn(va) (virt_to_maddr(va) >> PAGE_SHIFT) +#define __virt_to_mfn(va) (virt_to_maddr(va) >> PAGE_SHIFT) #define mfn_to_virt(mfn) (maddr_to_virt((paddr_t)(mfn) << PAGE_SHIFT)) /* @@ -274,6 +274,7 @@ static inline int gvirt_to_maddr(vaddr_t va, paddr_t *pa, unsigned int flags) */ #define mfn_to_page(mfn) __mfn_to_page(mfn) #define page_to_mfn(pg) __page_to_mfn(pg) +#define virt_to_mfn(va) __virt_to_mfn(va) /* Convert between Xen-heap virtual addresses and page-info structures. */ static inline struct page_info *virt_to_page(const void *v) From patchwork Tue Jun 13 16:13:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105383 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp486309qgd; Tue, 13 Jun 2017 09:15:11 -0700 (PDT) X-Received: by 10.36.185.13 with SMTP id w13mr826645ite.95.1497370511303; Tue, 13 Jun 2017 09:15:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497370511; cv=none; d=google.com; s=arc-20160816; b=yUpnbYA4ckA2inUOr1GJMnBR4dhDfXATDvDjwqFMwkgUxYUR9zaZK7yQ0/sLre9T9Y WTH00DNn+76Z4GrxakKQrki7PP2SK2eVIVddeLfoBEEeBBkAPhXI3w5AnkZIXoa3SQa0 gPFzb+f8+thks1CIW+ailDGG5zpm7gbf1lM/YGBpkXo/ewEdwEfjPGFsCUAscltUwgDa zBwIriKxB+/LLT3FzyfOGnuEWRxr8TXOUQqVdnV3eCOIASnawYoGt7YG2gcOv9vh60e9 dWLKTW33Is+jLgvFoDBNliOTJAI9du+eQZy5tMfRhnVyxf6a6+W1ny9HduJ1f5uXtUyn A8cA== 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 :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=N678OtxVSegXytiBKnuBCO7VtJ/MgJX6YDUmAKbWdFY=; b=oQnqJncI63qrhGydsyP8On8/74rSz2Nc7nX3JYrrXt+wBdkLJz20Sy/RtBi5eISGK0 5wni5Mkuxkm9kKmtYh7tSVBlc17ly6gpY1zFDkKgn3SuHFFeydfgH9eMmY79zfIyHeMF 8YEqqyRMBeCAA1pg/VVGZuBCQYP5aD8C+fOnOkQRMfrPnRNDU8pJ+lRGx9WP/O++Rir6 t1ViLMap5Y3FcSv4RTgjNRfsEdCL6fSjCi+RBAicVPu1dGL5k4SsZIpgz+JxmDppn6bF EXm4iEre7J0M40VKPO5UuC8vBg9E+Iq7Nypl92gtVh8+I9Sla8Jm8rQzrvg+tFY6ZBll KgWg== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id m66si482244ioo.162.2017.06.13.09.15.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jun 2017 09:15:11 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoS7-0000B5-P4; Tue, 13 Jun 2017 16:13:59 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoS6-00007D-CK for xen-devel@lists.xen.org; Tue, 13 Jun 2017 16:13:58 +0000 Received: from [85.158.139.211] by server-7.bemta-5.messagelabs.com id 8A/8D-02181-54F00495; Tue, 13 Jun 2017 16:13:57 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrCLMWRWlGSWpSXmKPExsVysyfVTdeJ3yH S4OY8boslHxezODB6HN39mymAMYo1My8pvyKBNWPDq0/MBVe4KpZtrGhgXMfRxcjFISSwmVFi w9W3rF2MnEDOaUaJN5cSQGw2AU2JO58/MYHYIgLSEtc+X2YEsZkFIiSaFuwFiwsLhEkcnT2bB cRmEVCVeHN0NlsXIwcHr4CVxNajmiBhCQF5iV1tF8HGcwKFLz1vYoRYZSnRvHs90wRG7gWMDK sYNYpTi8pSi3SNzPSSijLTM0pyEzNzdA0NTPVyU4uLE9NTcxKTivWS83M3MQJ9W8/AwLiD8fZ kv0OMkhxMSqK8W67YRArxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4N3B6xApJFiUmp5akZaZAwwy mLQEB4+SCO99FqA0b3FBYm5xZjpE6hSjopQ4bzNInwBIIqM0D64NFtiXGGWlhHkZGRgYhHgKU otyM0tQ5V8xinMwKgnztvAATeHJzCuBm/4KaDET0OLrIDfzFpckIqSkGhg7JurqS/i8DpBk2B J7b8OU6e9fffkjsUDgX9Tr0wZ5tWxzv0b6m0bVfJzwVKPyFoPfh/Lwsr2ex0qaDG+91vrMaKd r4bfmx4WU8Cs7QhbnxC5MiSxZqjLnGLvTlgOqnwwTrhnx+EgpBWblHwrR5Jhq+y1eqVtyjWRF 4qb19bu/tzctfTEly0uJpTgj0VCLuag4EQA+NK/aZwIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-9.tower-206.messagelabs.com!1497370433!103337134!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 64116 invoked from network); 13 Jun 2017 16:13:54 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-9.tower-206.messagelabs.com with SMTP; 13 Jun 2017 16:13:54 -0000 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 6625715A2; Tue, 13 Jun 2017 09:13:53 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A219D3F557; Tue, 13 Jun 2017 09:13:52 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 13 Jun 2017 17:13:20 +0100 Message-Id: <20170613161323.25196-22-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170613161323.25196-1-julien.grall@arm.com> References: <20170613161323.25196-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org, punit.agrawal@arm.com Subject: [Xen-devel] [PATCH 21/24] xen/arm: domain_build: Redefine virt_to_mfn to support typesafe X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" The file xen/arch/arm/domain_build.c is using typesafe MFN in most of the place. The only caller to virt_to_mfn is using prefixed with _mfn(...). To avoid extra _mfn(...), re-define virt_to_mfn within arch/arm/domain_build.c to handle typesafe MFN. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/domain_build.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index c6776d76fc..1bec4fa23d 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -45,6 +45,10 @@ struct map_range_data p2m_type_t p2mt; }; +/* Override macros from asm/page.h to make them work with mfn_t */ +#undef virt_to_mfn +#define virt_to_mfn(va) _mfn(__virt_to_mfn(va)) + //#define DEBUG_11_ALLOCATION #ifdef DEBUG_11_ALLOCATION # define D11PRINT(fmt, args...) printk(XENLOG_DEBUG fmt, ##args) @@ -1903,7 +1907,7 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo) rc = map_regions_p2mt(d, gaddr_to_gfn(d->arch.efi_acpi_gpa), PFN_UP(d->arch.efi_acpi_len), - _mfn(virt_to_mfn(d->arch.efi_acpi_table)), + virt_to_mfn(d->arch.efi_acpi_table), p2m_mmio_direct_c); if ( rc != 0 ) { From patchwork Tue Jun 13 16:13:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105390 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp486395qgd; Tue, 13 Jun 2017 09:15:22 -0700 (PDT) X-Received: by 10.202.3.135 with SMTP id 129mr545749oid.160.1497370522189; Tue, 13 Jun 2017 09:15:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497370522; cv=none; d=google.com; s=arc-20160816; b=mKNUWU8Nn9OAGiBQxoMxX4Yz5svcT6gcQnVdcjN4fAeRbOmbWAtdwtAw4jtJrF7Pc9 VMbYau1YJpFIVxLNYWn8jK9lFowZ8J6j/7NscNgUuYRuWi8XSGFKiRtlAkmCP8zGyzoR 9DG4v1dJjt7H/evYe89DhOfd5Ru+OjBv1FgNyr7nW9o8+spO324WYZi0xv0RQnIdZKtK 6UTc+IkmQICmp80n5AlWhXCugxJDOTekRME4e+ppztBApN+ff90ixYWaGmSAh19jHibQ NvL3oXoL8cXjVL3+rnBnjXWzKOteqGlfgR29niSwF5CEbpqOgPujY9o7XaqWEfK37iaW rj/w== 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 :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=T5+q49O6bVFz1NH4jcfHTaURIu3baYl9odX/pW63/3k=; b=k3+VS2QpfsggB482Vai3cpoGxqAi2tDi4SPQA1mZSQKF6eokPc4raGT3egYvJ+ty3w gJZl+0NlEk0Akp+4h0Z/3QZmcSwT0sdWVPkKLP5JlK8QKoAaMEwfV5I/H4cuxOg1JvuD x7iaEFEDHHs+6e5roieRHb8TAXSXy+IoJsxZwnDjAGzy1bNZwTkfDzLyzfMEI9UzrdJQ i4v33wnONG1C6GVnmyvQ2WwnfC4qGZD7sL48/xUPMjYmhvn4tq4XRg5Euw2HjV8C/EnB Ym4Oc8ZyKnaQk3Ll9cG2x02nw3E4rMw2ULgIYPuOvq4rR5TyT+6GKoL6ci06S5Tc2ujS Ja/w== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 102si237901otg.303.2017.06.13.09.15.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jun 2017 09:15:22 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoS5-000069-Gf; Tue, 13 Jun 2017 16:13:57 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoS4-0008UT-3d for xen-devel@lists.xen.org; Tue, 13 Jun 2017 16:13:56 +0000 Received: from [193.109.254.147] by server-6.bemta-6.messagelabs.com id A7/2C-03920-34F00495; Tue, 13 Jun 2017 16:13:55 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrILMWRWlGSWpSXmKPExsVysyfVTdeZ3yH S4MFlNoslHxezODB6HN39mymAMYo1My8pvyKBNeP8qqesBXc5K85M3MTewNjB0cXIxSEksJlR 4sjkjYxdjJxAzmlGiVN75EFsNgFNiTufPzGB2CIC0hLXPl8Gq2EWiJBoWrAXLC4sECrxYOlal i5GDg4WAVWJn63lIGFeASuJI6cawMolBOQldrVdZAWxOYHil543Qa2ylGjevZ5pAiP3AkaGVY waxalFZalFuoaWeklFmekZJbmJmTm6hgZmermpxcWJ6ak5iUnFesn5uZsYgd5lAIIdjD+WBRx ilORgUhLl3XLFJlKILyk/pTIjsTgjvqg0J7X4EKMMB4eSBO8OXodIIcGi1PTUirTMHGCYwaQl OHiURHjvswCleYsLEnOLM9MhUqcYdTk2rF7/hUmIJS8/L1VKnPcPyAwBkKKM0jy4EbCQv8QoK yXMywh0lBBPQWpRbmYJqvwrRnEORiVh3hYeoCk8mXklcJteAR3BBHTEdZD7eYtLEhFSUg2MK2 Q9XRdJ7Qy53vcxYkKz4H7R134+O6etnrLQpG/dwiNtKQWTIj2mTVbIdvj+et9X0cUTw4KZmSK rVj51cbZLfjXzRfb9mqTbK6YpLznwsbLUMJItNSVy2luTi1/n5Wj88D9WHsv32nHFzgvrmSsl Qy7+8H14N/TDTwb27XJ1S7/2/L7Ze375OiWW4oxEQy3mouJEAIF2f4x0AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-8.tower-27.messagelabs.com!1497370434!97214937!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 64004 invoked from network); 13 Jun 2017 16:13:54 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-8.tower-27.messagelabs.com with SMTP; 13 Jun 2017 16:13:54 -0000 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 671C51596; Tue, 13 Jun 2017 09:13:54 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A31EC3F557; Tue, 13 Jun 2017 09:13:53 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 13 Jun 2017 17:13:21 +0100 Message-Id: <20170613161323.25196-23-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170613161323.25196-1-julien.grall@arm.com> References: <20170613161323.25196-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org, punit.agrawal@arm.com Subject: [Xen-devel] [PATCH 22/24] xen/arm: alternative: Redefine virt_to_mfn to support typesafe X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" The file xen/arch/arm/alternative.c is using typesafe MFN in most of the place. The only caller to virt_to_mfn is using with _mfn(...). To avoid extra _mfn(...), re-define virt_to_mfn within xen/arch/arm/alternative.c to handle typesafe MFN. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/alternative.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/alternative.c b/xen/arch/arm/alternative.c index 4d7e5b6155..a3bcda3117 100644 --- a/xen/arch/arm/alternative.c +++ b/xen/arch/arm/alternative.c @@ -32,6 +32,10 @@ #include #include +/* Override macros from asm/page.h to make them work with mfn_t */ +#undef virt_to_mfn +#define virt_to_mfn(va) _mfn(__virt_to_mfn(va)) + extern const struct alt_instr __alt_instructions[], __alt_instructions_end[]; struct alt_region { @@ -154,7 +158,7 @@ static int __apply_alternatives_multi_stop(void *unused) { int ret; struct alt_region region; - mfn_t xen_mfn = _mfn(virt_to_mfn(_start)); + mfn_t xen_mfn = virt_to_mfn(_start); paddr_t xen_size = _end - _start; unsigned int xen_order = get_order_from_bytes(xen_size); void *xenmap; From patchwork Tue Jun 13 16:13:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105388 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp486365qgd; Tue, 13 Jun 2017 09:15:18 -0700 (PDT) X-Received: by 10.202.193.6 with SMTP id r6mr523391oif.129.1497370518303; Tue, 13 Jun 2017 09:15:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497370518; cv=none; d=google.com; s=arc-20160816; b=dzW13ed6TzgaIAknxmKfsLiOYvEdv0A3F4BNEcggplKyNV0nLpKHzxUl3HyAw1ssxg hEAQa04pNvfoxhZqVYvz43cU1oYA7yyTmMuraHvlOjai+pqZTnS+lxUgQwqDBwFuvbcK y78aMXtUzojwEKsy9WLmUwJk3yEalggJkUuEO8IkN4745dSxeDqqVx7JioVDpwAg9IAQ MGCMqKjjPdElbGVEQggTpaoGC3W0nzDSRNIFLzrBv0FZ4f2ws5MbGqfagElAUjW5NdZe ZSJKRHhBwvynwC+R1xIMeuMr4O9gsdF4l858BQt1gIShSq2Nllx48WbYfE2MXaoGhL5w lzMg== 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 :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=bgUg1SOM55W1nd74cQEDDa7ypV38KHHhgmu+Yiiwin8=; b=Q2tk1ZNEmPAX80PkYel8xtZtwbD0GJAz//4LgzBdvOft7ixG0+mJ0lPlsIv1Upl6eP jHupC/vrtCCxjml9WE1CYmmdn0HrntUaRWmCYZFsAzI9PDEjiQWoiObLTitpb5fSNeNB cQFKUyarhaEfVnL7Xs2CXgVogxHZyHMv08TN/R3aZwJNoZFrLhN8/9zyaatuw5nU/2G0 +rQQbXhvv5MPm16VJ4agIND2GPKnP9yOa9CnNW/D8Kb2ER2jgE2CZPMEjD1AakE7QfWB +yhJAoQ/MCjhSitzRb/63hOfJrGpANwNVJ1S4h7kyRAg83P1h8DxhTvYduCxWXIr8hJN PSsg== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id g7si332314otd.261.2017.06.13.09.15.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jun 2017 09:15:18 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoS9-0000Fi-Dd; Tue, 13 Jun 2017 16:14:01 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoS8-0000Cg-L3 for xen-devel@lists.xen.org; Tue, 13 Jun 2017 16:14:00 +0000 Received: from [85.158.139.211] by server-13.bemta-5.messagelabs.com id 40/55-01709-74F00495; Tue, 13 Jun 2017 16:13:59 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrBLMWRWlGSWpSXmKPExsVysyfVTdeF3yH SoP2IrMWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmtH4ZQ1bwQzOiodn7zE2ML5g72Lk4hAS2Mwo sfD1DjYI5zSjRMuaw0AOJwebgKbEnc+fmEBsEQFpiWufLzOCFDELbGOUuL1kFztIQlggWGL2h UeMIDaLgKrEqdfvmUFsXgEriTsX7oHVSAjIS+xqu8gKYnMCxS89bwKrFxKwlGjevZ5pAiP3Ak aGVYwaxalFZalFusYGeklFmekZJbmJmTm6hgamermpxcWJ6ak5iUnFesn5uZsYgT6uZ2Bg3ME 4YZXfIUZJDiYlUd4tV2wihfiS8lMqMxKLM+KLSnNSiw8xynBwKEnw2vM5RAoJFqWmp1akZeYA gw0mLcHBoyTCe58FKM1bXJCYW5yZDpE6xagoJc77hxcoIQCSyCjNg2uDBfglRlkpYV5GBgYGI Z6C1KLczBJU+VeM4hyMSsK8LTxAU3gy80rgpr8CWswEtPg6yM28xSWJCCmpBkazs1d2bTt7+k Foqec1rd9R63Nq0/8dZd2pKG1+tZH910SBIAW/CU3reGq7T/xedC7/wdwVdawRru4KWbUlDnN z1XfNuCH5etkWqdM5Qcd2+mwxMPm8qvL487iKkLfNJ7Ikcy/+Wqz77730pKjuLxNMax6vVZzQ +tilu6ro5TmJWS/eN6x6JtKsxFKckWioxVxUnAgAIoJZpGsCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-12.tower-206.messagelabs.com!1497370435!66951713!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 23011 invoked from network); 13 Jun 2017 16:13:56 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-12.tower-206.messagelabs.com with SMTP; 13 Jun 2017 16:13:56 -0000 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 AF47B1596; Tue, 13 Jun 2017 09:13:55 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A3FC93F557; Tue, 13 Jun 2017 09:13:54 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 13 Jun 2017 17:13:22 +0100 Message-Id: <20170613161323.25196-24-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170613161323.25196-1-julien.grall@arm.com> References: <20170613161323.25196-1-julien.grall@arm.com> Cc: Ross Lagerwall , Julien Grall , sstabellini@kernel.org, punit.agrawal@arm.com Subject: [Xen-devel] [PATCH 23/24] xen/arm: livepatch: Redefine virt_to_mfn to support typesafe X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" The file xen/arch/arm/livepatch.c is using typesafe MFN in most of the place. The only caller to virt_to_mfn is using with _mfn(...). To avoid extra _mfn(...), re-define virt_to_mfn within xen/arch/arm/livepatch.c to handle typesafe MFN. Signed-off-by: Julien Grall Cc: Ross Lagerwall Cc: Konrad Rzeszutek Wilk Reviewed-by: Stefano Stabellini --- xen/arch/arm/livepatch.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/livepatch.c b/xen/arch/arm/livepatch.c index de95e54744..3e53524365 100644 --- a/xen/arch/arm/livepatch.c +++ b/xen/arch/arm/livepatch.c @@ -12,6 +12,10 @@ #include #include +/* Override macros from asm/page.h to make them work with mfn_t */ +#undef virt_to_mfn +#define virt_to_mfn(va) _mfn(__virt_to_mfn(va)) + void *vmap_of_xen_text; int arch_livepatch_quiesce(void) @@ -22,7 +26,7 @@ int arch_livepatch_quiesce(void) if ( vmap_of_xen_text ) return -EINVAL; - text_mfn = _mfn(virt_to_mfn(_start)); + text_mfn = virt_to_mfn(_start); text_order = get_order_from_bytes(_end - _start); /* From patchwork Tue Jun 13 16:13:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105384 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp486318qgd; Tue, 13 Jun 2017 09:15:12 -0700 (PDT) X-Received: by 10.36.51.82 with SMTP id k79mr18667977itk.32.1497370512287; Tue, 13 Jun 2017 09:15:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497370512; cv=none; d=google.com; s=arc-20160816; b=CINxCJV4+bIbjIL/6ENm1uEWiKI3uxbLwvq3Z1hrS/PyJW5yLm5zhjvf0sn+xgXGKa eGy6vSw6ScGqj4MVkJC7FSzqjP6L9NvHzeXIOIY7RQMbWRRBye0uMDgKvFAjmYwAuajo 6xB1qR25QukIUZhaiJjuOwzBzN6X+Q0q2Jg1gX9YCcXWGSu4FH9wYJtCQsmVEMVlpFBM NvQ3MAgBKyO6W+9oaBC+TpdCsK1bwQEig+HbAMcD3H4iWrBOsQIHrCla7YjHS3T+m23z 6RWbPKx0is7ifEl8a4BZf6poaPT85gGuAjBSPw6KvUb/w846M1qId9C4Ult/3NnxQyOl egrQ== 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 :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=lHZ1YsqTxMjvZRyPjzx98dC/nhclGaceWiRnSwh3vck=; b=IROcH3FjWjeZcv4MiNlJvNw+VVEkJeoSnnCb25hAM8hhyWNfwHFyOMGFuHTazYqe/w zagkZ8clD4ZJpN3idC6RfL/31XO7n0DYRwp6YIxmTG9iTl9ui1gurtYnIjmVgM5Ubjrz B2eM2Z8ARL6VS65HR8CC9I0VzjAbulb/b1XoURikP9m+bAnvDmoCTcyIkVVCZE6AVgh5 PDiYDSe/r1BSuyq3qGAJoJJOo28AIBOAbJgtJaZboV4+zoHNPpRbK1IdUMZcyRV3IgzU eO3DQ+OF/AQjyCfHcRw/O3azqzaoprH2ss/304Q6LUz60tysEpGJFsV1N5LvGRs9N4cJ TNsQ== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id r126si444425itb.13.2017.06.13.09.15.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jun 2017 09:15:12 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoS8-0000C7-1M; Tue, 13 Jun 2017 16:14:00 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoS6-00007x-J2 for xen-devel@lists.xen.org; Tue, 13 Jun 2017 16:13:58 +0000 Received: from [85.158.143.35] by server-5.bemta-6.messagelabs.com id B3/C5-03371-54F00495; Tue, 13 Jun 2017 16:13:57 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrOLMWRWlGSWpSXmKPExsVysyfVTdeV3yH SoGuCpMWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmnFg3SS2grWSFTvWb2dpYLwq2MXIxSEksJlR YvmPLawQzmlGie8rjjF3MXJysAloStz5/IkJxBYRkJa49vkyI4jNLBAh0bRgL1hcWMBF4sTBP WwgNouAqsTvaYdYQWxeASuJvTOngNVICMhL7Gq7CBbnBIpfet4ENkdIwFKiefd6pgmM3AsYGV YxahSnFpWlFukaWuolFWWmZ5TkJmbm6BoamOnlphYXJ6an5iQmFesl5+duYgR6mAEIdjD+WBZ wiFGSg0lJlHfLFZtIIb6k/JTKjMTijPii0pzU4kOMMhwcShK8O3gdIoUEi1LTUyvSMnOAoQaT luDgURLhvc8ClOYtLkjMLc5Mh0idYlSUEuf9A9InAJLIKM2Da4OF9yVGWSlhXkagQ4R4ClKLc jNLUOVfMYpzMCoJ87bwAE3hycwrgZv+CmgxE9Di6yA38xaXJCKkpBoYue61qUwJXLj789n3U4 OW9848e+/31hXXl/H0HlD++mKV4T39Nza3lrMdOdHqdWzrzN7+LyfOsa+4JPXudGrMBd5ZmZa pvCwz616dubOV/96TpJ75CzetqDh2Tt2V223zXa2texNuJ1/dmMu3izEyrbmqdDXvupDus1J/ G3Z3u6U/33nnRPBdpd9KLMUZiYZazEXFiQBza9mfagIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-3.tower-21.messagelabs.com!1497370436!70195160!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 35258 invoked from network); 13 Jun 2017 16:13:57 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-3.tower-21.messagelabs.com with SMTP; 13 Jun 2017 16:13:57 -0000 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 B0DF015A2; Tue, 13 Jun 2017 09:13:56 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EC7AF3F557; Tue, 13 Jun 2017 09:13:55 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 13 Jun 2017 17:13:23 +0100 Message-Id: <20170613161323.25196-25-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170613161323.25196-1-julien.grall@arm.com> References: <20170613161323.25196-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org, punit.agrawal@arm.com Subject: [Xen-devel] [PATCH 24/24] xen/arm: create_xen_entries: Use typesafe MFN X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Add a bit more safety when using create_xen_entries. Also when destroying/modifying mapping, the MFN is currently not used. Rather than passing _mfn(0) use INVALID_MFN to stay consistent with the other usage. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/mm.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 2ff1688f3f..8cb0559972 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -980,7 +980,7 @@ enum xenmap_operation { static int create_xen_entries(enum xenmap_operation op, unsigned long virt, - unsigned long mfn, + mfn_t mfn, unsigned long nr_mfns, unsigned int ai) { @@ -989,7 +989,7 @@ static int create_xen_entries(enum xenmap_operation op, lpae_t pte; lpae_t *third = NULL; - for(; addr < addr_end; addr += PAGE_SIZE, mfn++) + for(; addr < addr_end; addr += PAGE_SIZE, mfn = mfn_add(mfn, 1)) { if ( !xen_second[second_linear_offset(addr)].pt.valid || !xen_second[second_linear_offset(addr)].pt.table ) @@ -1010,13 +1010,13 @@ static int create_xen_entries(enum xenmap_operation op, case RESERVE: if ( third[third_table_offset(addr)].pt.valid ) { - printk("create_xen_entries: trying to replace an existing mapping addr=%lx mfn=%lx\n", - addr, mfn); + printk("create_xen_entries: trying to replace an existing mapping addr=%lx mfn=%"PRI_mfn"\n", + addr, mfn_x(mfn)); return -EINVAL; } if ( op == RESERVE ) break; - pte = mfn_to_xen_entry(_mfn(mfn), ai); + pte = mfn_to_xen_entry(mfn, ai); pte.pt.table = 1; write_pte(&third[third_table_offset(addr)], pte); break; @@ -1061,24 +1061,25 @@ int map_pages_to_xen(unsigned long virt, unsigned long nr_mfns, unsigned int flags) { - return create_xen_entries(INSERT, virt, mfn, nr_mfns, flags); + return create_xen_entries(INSERT, virt, _mfn(mfn), nr_mfns, flags); } int populate_pt_range(unsigned long virt, unsigned long mfn, unsigned long nr_mfns) { - return create_xen_entries(RESERVE, virt, mfn, nr_mfns, 0); + return create_xen_entries(RESERVE, virt, _mfn(mfn), nr_mfns, 0); } int destroy_xen_mappings(unsigned long v, unsigned long e) { - return create_xen_entries(REMOVE, v, 0, (e - v) >> PAGE_SHIFT, 0); + return create_xen_entries(REMOVE, v, INVALID_MFN, (e - v) >> PAGE_SHIFT, 0); } int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int flags) { ASSERT((flags & (PTE_NX | PTE_RO)) == flags); - return create_xen_entries(MODIFY, s, 0, (e - s) >> PAGE_SHIFT, flags); + return create_xen_entries(MODIFY, s, INVALID_MFN, (e - s) >> PAGE_SHIFT, + flags); } enum mg { mg_clear, mg_ro, mg_rw, mg_rx };