From patchwork Wed Nov 1 14:03: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: 117697 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp927865qgn; Wed, 1 Nov 2017 07:05:36 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Rz5ZpDxYFOPED563YmDknYnhxtQgcVocpdLxXLwPNVfJoqLdFvErOpriYQi+kBxBy1rl+6 X-Received: by 10.107.198.74 with SMTP id w71mr7242318iof.90.1509545135951; Wed, 01 Nov 2017 07:05:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509545135; cv=none; d=google.com; s=arc-20160816; b=V7vjDkwftj36VT3QH4qH6t2lMDExv/h9k5iyA8NS3gIkcLaFOWsFiQzfPYyNSAnjZC Kce2TWiDs33xvstAMwrXTD3e+sdYl9fWUtemu5QIhIiLQhZQcaLsmyVJ6nHxL42UoQh/ 2hVw65wYyXzW/wd04jJPED3LR/+y6G9LxZKic+XTZZ/VJk3PBBEkJ7Mpkj47uBWO5WLZ 9l+vkI7t0H2BXpEbZ4S0pAKY2WsOiYuiWm5yJw9dAM59GJMDc0mI2yDWiNGIQeVG2LEU FY+ISrLT0Q64cI03SQ7LNgtfTokqn684GDv/Q9OJaK1LxqfBtBdHUtc6PurQn2QGwpFO OFQw== 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:dkim-signature:arc-authentication-results; bh=b+KzTdXS4+KOK+XRA1EL3KsA5JbSIeJB6dJKhgFuYZM=; b=toW9r0gcjYhuUw147xJHjU7DfHecMvs+yZVTAO7Z85hSt8x6mBXwG9a/Jc2SJ6omno ht6eoVHxAusT2YxMU1E4XRLkE5ZTfzzTD83t9PeORLWP7Z5lmCqNnJeYvGHGn/f8av87 MVyMQ9nKlKfRTvyq+8MZvIlWjNAecOg/YeFjnP89lP9T0PzXLOsvb7ANEvAFE92J5euf oDgC7FDmcwSmSB+zRDAI8nkZxxgS38LoWYOoFVp773F4ixqiz1wxwyCdDaDkElg7eWVD TRtdfHI+pho5J6l408A/PM30jPK/UcpW+jIu5lLIyLhFqohfpPLg4ySVkoYe76aZhCsr ohSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=SHyO6z0h; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id n31si686091ioi.71.2017.11.01.07.05.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Nov 2017 07:05: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; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=SHyO6z0h; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.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 1e9tc5-0007ss-8U; Wed, 01 Nov 2017 14:03:25 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e9tc3-0007sb-Tz for xen-devel@lists.xen.org; Wed, 01 Nov 2017 14:03:24 +0000 Received: from [85.158.139.211] by server-9.bemta-5.messagelabs.com id 2D/76-02146-B24D9F95; Wed, 01 Nov 2017 14:03:23 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrNIsWRWlGSWpSXmKPExsVyMbThkK7WlZ+ RBnv3qVgs+biYxYHR4+ju30wBjFGsmXlJ+RUJrBlnGyewFnQKV+zonsjWwDiDr4uRi0NIYAKj RM+hhywgDovAPGaJazdWMYI4EgL9rBL/5l9j6mLkBHLyJO5fbmXuYuQAstMkji3kgghXSzy/2 gAWFhJQk1jzJgpiaDeTxI85R5hA4mwCOhLrZtSClIsISEtc+3yZEcRmFoiQOP/hIBuILSzgL7 H923GwOIuAqsSZpT/YQWxeARuJBT+eskCskpfY1XaRFWQkp4CtxLIr5iBhIaCS2w0n2CcwCi5 gZFjFqFGcWlSWWqRraKqXVJSZnlGSm5iZo2toYKqXm1pcnJiempOYVKyXnJ+7iREYbAxAsIOx YbvnIUZJDiYlUd6djt8jhfiS8lMqMxKLM+KLSnNSiw8xynBwKEnwNlz+GSkkWJSanlqRlpkDD HuYtAQHj5IIrwJImre4IDG3ODMdInWK0Z7jwp1Lf5g4Duy5BSQ7bt4Fks9mvm5gFmLJy89LlR Ln9QRpEwBpyyjNgxsKi9NLjLJSwryMQGcK8RSkFuVmlqDKv2IU52BUEuY9fgloCk9mXgnc7ld AZzEBneUl8QPkrJJEhJRUA6P26g9fiwJDo+VZC67I/fbNsxWaKn21PaOU+dh/UcGD37KP/F4d cvSkvoPkzAcH1tz/65D4dNfd5c769twrJYIltIKO/b5yVeWdW0b5Qe9/t/+9X2v6oOxDTJv7H f3Jbx8cX9q0bGPHm9jbW6unHDBpV3154z3fQ6n0m0KHL4ZuWhO4alrgQZFwJZbijERDLeai4k QAUb/ffc4CAAA= X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-11.tower-206.messagelabs.com!1509545002!89866573!1 X-Originating-IP: [209.85.128.194] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 52459 invoked from network); 1 Nov 2017 14:03:22 -0000 Received: from mail-wr0-f194.google.com (HELO mail-wr0-f194.google.com) (209.85.128.194) by server-11.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 1 Nov 2017 14:03:22 -0000 Received: by mail-wr0-f194.google.com with SMTP id l1so2045471wrc.3 for ; Wed, 01 Nov 2017 07:03:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=auPzgYdYvNUtym022RmzXmFeIpSa7v4QplQOWd8aEjA=; b=SHyO6z0hwH9WD5USUMukHj/7xuFDCHgEzSpmy9PWiOU69fB0k83Uq+olDvMiwN/Kv5 JKIjutrhfBq2H6gnsIknHo6ubcgsmLb87LrSkiDa3BI9McOx8TH9a/TR8lAXtvfGiNon xYOnCfN8hxzuuwk5JvtLIgc8o/j7yPY7W6mAc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=auPzgYdYvNUtym022RmzXmFeIpSa7v4QplQOWd8aEjA=; b=Qqis2tiKjgvQurccRX8iXNIEal8876ij1qQRcKxfh2cbXVZXdJgq/pKeQ77IlbR7u3 QwCTaPCX3LGfO76p/17fSL+iIB4bM4nOEK3IBgln1YYiLwS0FD3HKcxvxLPRJanu4w7d s0v4pvESICJR/2JLDDthhQLXkjCRE08sqMV+OdJiF4qB8LOcW6W2gpYaBIV5uJ8C5k9T +VpIb8wYG2O3BbyXqxEPb5YP+Axr3XHpLfDClA9Wo5Po1K9BgOh2uT9SB+FMfTiFkkQI mopNlpVsu59ortLW9z1Vj7Kp8t51r8K7Y4NF//yWRH4/qVUG2MkAuNTWKtQbYghsbhw1 1izw== X-Gm-Message-State: AMCzsaXNV+jEksdcSgqK2nxlUR5q7br2PAdPMTQccMhsTb7P6D8N9Kbo 23kFcQJE11Ef6jRVZoQArDzgfdSjpIg= X-Received: by 10.223.139.221 with SMTP id w29mr4806729wra.243.1509545001782; Wed, 01 Nov 2017 07:03:21 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id w4sm595582wrc.17.2017.11.01.07.03.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Nov 2017 07:03:20 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 1 Nov 2017 14:03:13 +0000 Message-Id: <20171101140316.31333-2-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171101140316.31333-1-julien.grall@linaro.org> References: <20171101140316.31333-1-julien.grall@linaro.org> Cc: Julien Grall , Stefano Stabellini Subject: [Xen-devel] [PATCH v3 for-next 1/4] xen/arm: domain_build: Clean-up insert_11_bank 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" - Remove spurious () - Add missing spaces - Turn 1 << to 1UL << - Rename spfn to smfn and switch to mfn_t Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Cc: Stefano Stabellini Changes in v2: - Remove double space - s/spfn/smfn/ and switch to mfn_t --- xen/arch/arm/domain_build.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index bf29299707..5532068ab1 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -50,6 +50,8 @@ struct map_range_data /* 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)) +#undef page_to_mfn +#define page_to_mfn(pg) _mfn(__page_to_mfn(pg)) //#define DEBUG_11_ALLOCATION #ifdef DEBUG_11_ALLOCATION @@ -104,16 +106,16 @@ static bool insert_11_bank(struct domain *d, unsigned int order) { int res, i; - paddr_t spfn; + mfn_t smfn; paddr_t start, size; - spfn = page_to_mfn(pg); - start = pfn_to_paddr(spfn); - size = pfn_to_paddr((1 << order)); + smfn = page_to_mfn(pg); + start = mfn_to_maddr(smfn); + size = pfn_to_paddr(1UL << order); D11PRINT("Allocated %#"PRIpaddr"-%#"PRIpaddr" (%ldMB/%ldMB, order %d)\n", start, start + size, - 1UL << (order+PAGE_SHIFT-20), + 1UL << (order + PAGE_SHIFT - 20), /* Don't want format this as PRIpaddr (16 digit hex) */ (unsigned long)(kinfo->unassigned_mem >> 20), order); @@ -126,7 +128,7 @@ static bool insert_11_bank(struct domain *d, goto fail; } - res = guest_physmap_add_page(d, _gfn(spfn), _mfn(spfn), order); + res = guest_physmap_add_page(d, _gfn(mfn_x(smfn)), smfn, order); if ( res ) panic("Failed map pages to DOM0: %d", res); @@ -167,7 +169,8 @@ static bool insert_11_bank(struct domain *d, */ if ( start + size < bank->start && kinfo->mem.nr_banks < NR_MEM_BANKS ) { - memmove(bank + 1, bank, sizeof(*bank)*(kinfo->mem.nr_banks - i)); + memmove(bank + 1, bank, + sizeof(*bank) * (kinfo->mem.nr_banks - i)); kinfo->mem.nr_banks++; bank->start = start; bank->size = size; From patchwork Wed Nov 1 14:03: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: 117696 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp927698qgn; Wed, 1 Nov 2017 07:05:28 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Qg1Rdy5mGPr79GZyvAIab9ITi6Qkb2Yg/Uuob1+Ilu/4opjoW+din/mTG356cCi9UZS5Hs X-Received: by 10.36.249.73 with SMTP id l70mr606402ith.70.1509545128499; Wed, 01 Nov 2017 07:05:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509545128; cv=none; d=google.com; s=arc-20160816; b=bM5zt7IWwElYYBq70gP8NvWGolFLXDxBX69NrOEDnOND8j7y0mNIId6Nvk3BaaN3ff RCcsAdXR/a66NXo7EJsspxBGVybj3jBn00OgIrgNsMCKGP9H1Y+Xn+iQsEwDdan1dLwy uDVMq9Dr1BVAy2yhqpP7546GwHRZHaahpZ1tQYsDVvy2tEiHa/Fl+CgbRV35nWOwm5Dh G/touP+HgsFD/9RvKTPESChrZFG0x0RQlyGfFH0pFRViXpq4YqbOA65oYLeVwkw0YE+H 3zshuAp1kICJ3Vdf5zu/jUzOUwYT2IUJGLRT0NxRJSKY6/WAFEttWgb10SxZXTegGaay gpog== 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:dkim-signature:arc-authentication-results; bh=1qPxsPsp9gWgNIz7HOgdPrBQVxf+k15uJxe1gHdpI3E=; b=CVhDa4gkLw282FfER85qhFRIC9avIiRuySgaFeBgxRSmqyG4le/XMbdGRWdR8JND0N rakjS+IyLeL1cbQ3eb1rJwEuAJYvi1I30Vgvm+y/2g07g1CQQfskTVExxmE51IaFHh70 cLCRV8+TAiJcstwhfBXLotKzzzAjrgWX8aLnyajPlMsfWykaWEBy9pbDXcpOgIDhi0D6 zxhL85HLhep6wcBPrT2zMlMDLrVO67A1Du09f+TqgPX8ZcCD9Ab9VketX8f3JngpsftU yh16D7PnGnsCcpdZB5dYZRY2B/JVZCloKLPwssIBfe7Q08dYvwIel1u0yJxZFiRRBGmG 03gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=jLaaJoPZ; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id k29si1152638iti.29.2017.11.01.07.05.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Nov 2017 07:05: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; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=jLaaJoPZ; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.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 1e9tc6-0007t9-Fb; Wed, 01 Nov 2017 14:03:26 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e9tc5-0007sx-Rj for xen-devel@lists.xen.org; Wed, 01 Nov 2017 14:03:25 +0000 Received: from [85.158.137.68] by server-4.bemta-3.messagelabs.com id 68/C7-10698-D24D9F95; Wed, 01 Nov 2017 14:03:25 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrIIsWRWlGSWpSXmKPExsVyMbThoK7OlZ+ RBgeeCFss+biYxYHR4+ju30wBjFGsmXlJ+RUJrBlnPy9nLPjOVTH/m1QD41v2LkYuDiGBiYwS j1eeYgZxWATmMUvMafoLlpEQ6GeV2LHtGlsXIyeQkydxddc/dgg7TeLitJdMEHa1xMfm56xdj BxAo9Qk1ryJgpjazSRx6/lUZpA4m4COxLoZtSDlIgLSEtc+X2YEsZkFIiTOfzgINl5YIEpi6c VVYONZBFQlFtx+wAxi8wrYSBz9vAFqlbzErraLYKs4BWwlll0xBwkLAZXcbjjBPoFRcAEjwyp GjeLUorLUIl1Dc72kosz0jJLcxMwcXUMDY73c1OLixPTUnMSkYr3k/NxNjMBgYwCCHYwvT3se YpTkYFIS5d3p+D1SiC8pP6UyI7E4I76oNCe1+BCjDAeHkgTvkUs/I4UEi1LTUyvSMnOAYQ+Tl uDgURLhXQ2S5i0uSMwtzkyHSJ1idOW4cOfSHyaOY5suA8kDe24ByY6bd4Hks5mvG5iFWPLy81 KlxHmfgTQLgDRnlObBjYbF7CVGWSlhXkagY4V4ClKLcjNLUOVfMYpzMCoJ8x4HmcKTmVcCd8E roOOYgI7zkvgBclxJIkIKmAZmXNgc8cjo+pVH5bN0i3XiZ/w66MQr/lYkxPqVyIS5U1L+Wco/ XBFzUThRwvQFw9mMiSyL/0xeU3+uY+WGQLf4uQrT9RvLtIr43juuvntu29c3h9wFDqmuMBCpn 5Dwetah20Gq/cv5GdW+7ljvMUGkflMF99+vp07KN/038XEOv5Xwe+2D1rgCJZbijERDLeai4k QAWE4YyNQCAAA= X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-10.tower-31.messagelabs.com!1509545004!112264772!1 X-Originating-IP: [209.85.128.193] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 17065 invoked from network); 1 Nov 2017 14:03:24 -0000 Received: from mail-wr0-f193.google.com (HELO mail-wr0-f193.google.com) (209.85.128.193) by server-10.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 1 Nov 2017 14:03:24 -0000 Received: by mail-wr0-f193.google.com with SMTP id z55so2059299wrz.1 for ; Wed, 01 Nov 2017 07:03:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yZX5LdkSkSwGs8ZO9hc2BGe1K4hxikSYE3t3CEV9r+I=; b=jLaaJoPZEpUkq/2m4tG6/eu02okn1QhVrphoTlH3SyJEXPZXbaN206YHyEHAORk/Uo mcItTBswfiEiFHZTBkORTA3H+UrB0u1dl+mdJF/asNNoaXQ8xius42CDrA2IgKWcdK4+ 6G8vCveh7UorPbHS57HC0pqaRKo9uoylfaZrA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=yZX5LdkSkSwGs8ZO9hc2BGe1K4hxikSYE3t3CEV9r+I=; b=bnqOSd1p00HreHfHKY3vNRW4EYGbHqPD8qSwe27OYINd3iSpCN+TK9bHvSRBQcdWO7 4G809CmFYZnpJXhdmuv+C8xS0ta+v6tSU9mqPeXlCYdGFfswVQ2chVXufl4wemxupQcf wB2+2H4fRITScvp9zwG0IMJ1/vE8+of1Mg+KgvQX72D+PLq12X/vxYYB6cEqUk4HN4Rp zhotyhb4lIXKJQeNmlyBwRLbmYQ7wpMfXXQcNLRMfxwt2XikpiSN70G1lvT41rrZ7+1k jUQIEI48ySAdH2tXYyhClZDBUjtyGF9lh0PaUJ2a8Lurpy4rqVxlb/WF7vs/OVnnwqB6 cvVA== X-Gm-Message-State: AMCzsaWvRP9B9xHvOqIkS9TqOTi8lV7XN6JvG3pSadAdNNCzF5aPmr+E Fblx1cCuZ8uLbacs4boxDO/+7eea+no= X-Received: by 10.223.176.115 with SMTP id g48mr5501801wra.177.1509545003552; Wed, 01 Nov 2017 07:03:23 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id w4sm595582wrc.17.2017.11.01.07.03.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Nov 2017 07:03:22 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 1 Nov 2017 14:03:14 +0000 Message-Id: <20171101140316.31333-3-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171101140316.31333-1-julien.grall@linaro.org> References: <20171101140316.31333-1-julien.grall@linaro.org> Cc: Julien Grall , Stefano Stabellini Subject: [Xen-devel] [PATCH v3 for-next 2/4] xen/arm32: mm: Rework is_xen_heap_page to avoid nameclash 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 arm32 version of the function is_xen_heap_page currently define a variable _mfn. This will lead to a compiler when use typesafe MFN in a follow-up patch: called object '_mfn' is not a function or function pointer Fix it by renaming the local variable _mfn to mfn_. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Cc: Stefano Stabellini Changes in v3: - Fix typo in the commit message --- xen/include/asm-arm/mm.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h index cd6dfb54b9..737a429409 100644 --- a/xen/include/asm-arm/mm.h +++ b/xen/include/asm-arm/mm.h @@ -140,9 +140,9 @@ extern vaddr_t xenheap_virt_start; #ifdef CONFIG_ARM_32 #define is_xen_heap_page(page) is_xen_heap_mfn(page_to_mfn(page)) #define is_xen_heap_mfn(mfn) ({ \ - unsigned long _mfn = (mfn); \ - (_mfn >= mfn_x(xenheap_mfn_start) && \ - _mfn < mfn_x(xenheap_mfn_end)); \ + unsigned long mfn_ = (mfn); \ + (mfn_ >= mfn_x(xenheap_mfn_start) && \ + mfn_ < mfn_x(xenheap_mfn_end)); \ }) #else #define is_xen_heap_page(page) ((page)->count_info & PGC_xen_heap) From patchwork Wed Nov 1 14:03: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: 117698 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp928040qgn; Wed, 1 Nov 2017 07:05:42 -0700 (PDT) X-Google-Smtp-Source: ABhQp+RuWvy8Zh3xz+8fkz48UMwPo/pcHATKWN8/rv/3RPuP1lWIHebwcdR+N8Q2bq+mnbGW+lkK X-Received: by 10.36.14.207 with SMTP id 198mr650469ite.66.1509545142648; Wed, 01 Nov 2017 07:05:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509545142; cv=none; d=google.com; s=arc-20160816; b=kgWDJLuD1ox/U8gOAsPZTDEt8wRRyFdgGVhk9c5W5nuktOZ+NIIhSVlPKig8bTlryW njqtz8xnAXqx60MpLfBEX6hKq2+wRKc1shQ9nbl7Z55/vqQpFoU9JekhE5HN2+5n27Bc HJrVWvehRkDsrvzQF9dnp5O0z2p9g9ItvsbmEV+W1RNB4v4PkZfkJLDajp7zjuFiJcw2 GEPubZGRxmAzMXt6T45hiJLjerTnHtYF4UsVHslaLShWDo5hHH9RYExsfvfQ4y54uQ4X zR5pSxEff2YYcidbjW34ayI6c/mrnLykj9Fnv5ndcWWe8CURj6aGoY6+xgz8U54VFBdv KyZg== 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:dkim-signature:arc-authentication-results; bh=wGN7/Oj6mq9DHjcHIhGFfCd5EgxMXkB4mvbWTsD3RPw=; b=GWr/xvCWjPf1ajZNU3m7ZkB/6vLx2izaZnLrzxv48Y3FpIkkWXUnrAMpMMiBXbGHV0 b9glNaJE/1zoN4Y+PtixOIViLS5NG800eozFp+CEfGums4N/O5gFzEJEjYJQQTDm5Zq0 W5GZBDI5RwCshNCTklcseythvDFcMOlqPsi2nNGkd4ufMOuF95yTbe82hMyd/ju2Jnyb 3CGZB6Cdyu3q4T9QmDAe/sZsG7LA/TXwRXP6pAOY/uC/3NqLOtxepUYmTYFA7BE3e+9O iANxUKtW3x7WxUs391b+zGCpZqvjoezsA2QoDnCAwacmkIcdvJ/0LR4+fxfY4n/ycgDl EJLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=a2IQRJda; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id m133si1043260itb.99.2017.11.01.07.05.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Nov 2017 07:05:42 -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; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=a2IQRJda; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.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 1e9tc8-0007th-Q5; Wed, 01 Nov 2017 14:03:28 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e9tc7-0007sV-4j for xen-devel@lists.xen.org; Wed, 01 Nov 2017 14:03:27 +0000 Received: from [85.158.143.35] by server-4.bemta-6.messagelabs.com id 4A/38-30895-E24D9F95; Wed, 01 Nov 2017 14:03:26 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrJIsWRWlGSWpSXmKPExsVyMbThiK7elZ+ RBjPO81gs+biYxYHR4+ju30wBjFGsmXlJ+RUJrBkvmw8zFlxRq2g/vJO5gfGHbBcjF4eQwARG iaVTXzF1MXJysAjMY5Z4dEMYJCEh0M8q0b3jIitIQkIgT6Ktv5MRwk6T6GzqZYOwqyTa3x4Fi nMATVKTWPMmCmJoN5PEngu7WEHibAI6Eutm1IKUiwhIS1z7fBlsDLNAtMS134fA9goLJEqcOf WDCaScRUBV4vc/MZAwr4CNxO/eFhaITfISu9ougk3kFLCVWHbFHCQsBFRyu+EE+wRGwQWMDKs Y1YtTi8pSi3RN9JKKMtMzSnITM3N0DQ3M9HJTi4sT01NzEpOK9ZLzczcxAgONAQh2MHZf9j/E KMnBpCTKu9Pxe6QQX1J+SmVGYnFGfFFpTmrxIUYZDg4lCV6Dyz8jhQSLUtNTK9Iyc4AhD5OW4 OBREuFVAEnzFhck5hZnpkOkTjHac1y4c+kPE8eBPbeAZMfNu0Dy2czXDcxCLHn5ealS4ryeIG 0CIG0ZpXlwQ2ExeolRVkqYlxHoTCGegtSi3MwSVPlXjOIcjErCvMcvAU3hycwrgdv9CugsJqC zvCR+gJxVkoiQkmpgzNjAdz3sgsjET6sc1Zdc3ef8R7nWmG2CikGJ4LWfS3NYt5xXiIqYd35b keIN69lR9VvZeli2KbXYidnP5vEvd3k1K+Hfb0+1oGN+i31+6ZddD1tZvn3G7Vsl2ySfzn+7c H7tiv8ik2a16ESdU7DxMfG7xvJ/A9fj7013f628qe/S+/qlqvut6UosxRmJhlrMRcWJAG9L0q TMAgAA X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-2.tower-21.messagelabs.com!1509545006!66022001!1 X-Originating-IP: [209.85.128.196] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 7303 invoked from network); 1 Nov 2017 14:03:26 -0000 Received: from mail-wr0-f196.google.com (HELO mail-wr0-f196.google.com) (209.85.128.196) by server-2.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 1 Nov 2017 14:03:26 -0000 Received: by mail-wr0-f196.google.com with SMTP id 15so2037189wrb.5 for ; Wed, 01 Nov 2017 07:03:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=I36YDcdVKgwsPPKvceFw4AWZsTp6g82Fn4s6nFHEY48=; b=a2IQRJdadRsXnkNjJeLgl4keeG6+6VhzSbgYQ8i+aJaYG31V4d1bYXBsfKBrWTzlxE JB+pgidpYb+tFkUCWI3pbDAFmnU9kqhhsvSPA8cXvFcXl6nSt26FInpQrCJLdbwhQID3 I5jM9oxiw8fFf/x4Br/xmXFqosbgVvTDS8xNA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=I36YDcdVKgwsPPKvceFw4AWZsTp6g82Fn4s6nFHEY48=; b=COGug3Z5z06Wl1gbDhK1WB3XAKsV63gw6UryZDKBnJH9seWL2ogQjs8vlDlUJRRPJl +/Cx6izUk5F6S1QfVunJbw1CmkBSNVdO18U9RLlrIu6fuEFE7NJpEzETcu6Sxo/8tLgB a3vRfdV4Xpdbc7BCMBQNxhzwnzy2G4zoXdJt2Ydxgtbhhvy+Q77sJr0jEek41axtdqPh 8SOsdxTNSn66ESMX/nKFNjfRkgYhhn5weGZ+r7QMHvoBzLIizPtaiJNuRsr3QeQnX+Iz 6o39kKf7mhv83+mNMvVQIKghIE9PNeDVLaoikeaEhc5tzz7Dl8d0P8hfZzbePcHF2rrc /e+w== X-Gm-Message-State: AMCzsaVPE0sjunIwqrnnjTxCM4EGwZKgE44Vj4cPlA/JtOyZbGrhpPxG ErK/5opEh+Nxfmc1ulywovzD1gBkGMo= X-Received: by 10.223.166.146 with SMTP id t18mr5256884wrc.64.1509545005384; Wed, 01 Nov 2017 07:03:25 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id w4sm595582wrc.17.2017.11.01.07.03.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Nov 2017 07:03:24 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 1 Nov 2017 14:03:15 +0000 Message-Id: <20171101140316.31333-4-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171101140316.31333-1-julien.grall@linaro.org> References: <20171101140316.31333-1-julien.grall@linaro.org> Cc: Julien Grall , Konrad Rzeszutek Wilk Subject: [Xen-devel] [PATCH v3 for-next 3/4] xen/tmem: Convert the file common/tmem_xen.c to 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" The file common/tmem_xen.c is now converted to use typesafe. This is requiring to override the macro page_to_mfn to make it work with mfn_t. Note that all variables converted to mfn_t havem there initial value, when set, switch from 0 to INVALID_MFN. This is fine because the initial values was always overriden before used. Also add a couple of missing newlines suggested by Andrew in the code. Signed-off-by: Julien Grall Reviewed-by: Andrew Cooper Acked-by: Konrad Rzeszutek Wilk --- Cc: Konrad Rzeszutek Wilk Changes in v2: - Add missing newlines - Add Andrew's reviewed-by --- xen/common/tmem_xen.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/xen/common/tmem_xen.c b/xen/common/tmem_xen.c index 20f74b268f..bd52e44faf 100644 --- a/xen/common/tmem_xen.c +++ b/xen/common/tmem_xen.c @@ -14,6 +14,10 @@ #include #include +/* Override macros from asm/page.h to make them work with mfn_t */ +#undef page_to_mfn +#define page_to_mfn(pg) _mfn(__page_to_mfn(pg)) + bool __read_mostly opt_tmem; boolean_param("tmem", opt_tmem); @@ -31,7 +35,7 @@ static DEFINE_PER_CPU_READ_MOSTLY(unsigned char *, dstmem); static DEFINE_PER_CPU_READ_MOSTLY(void *, scratch_page); #if defined(CONFIG_ARM) -static inline void *cli_get_page(xen_pfn_t cmfn, unsigned long *pcli_mfn, +static inline void *cli_get_page(xen_pfn_t cmfn, mfn_t *pcli_mfn, struct page_info **pcli_pfp, bool cli_write) { ASSERT_UNREACHABLE(); @@ -39,14 +43,14 @@ static inline void *cli_get_page(xen_pfn_t cmfn, unsigned long *pcli_mfn, } static inline void cli_put_page(void *cli_va, struct page_info *cli_pfp, - unsigned long cli_mfn, bool mark_dirty) + mfn_t cli_mfn, bool mark_dirty) { ASSERT_UNREACHABLE(); } #else #include -static inline void *cli_get_page(xen_pfn_t cmfn, unsigned long *pcli_mfn, +static inline void *cli_get_page(xen_pfn_t cmfn, mfn_t *pcli_mfn, struct page_info **pcli_pfp, bool cli_write) { p2m_type_t t; @@ -68,16 +72,17 @@ static inline void *cli_get_page(xen_pfn_t cmfn, unsigned long *pcli_mfn, *pcli_mfn = page_to_mfn(page); *pcli_pfp = page; - return map_domain_page(_mfn(*pcli_mfn)); + + return map_domain_page(*pcli_mfn); } static inline void cli_put_page(void *cli_va, struct page_info *cli_pfp, - unsigned long cli_mfn, bool mark_dirty) + mfn_t cli_mfn, bool mark_dirty) { if ( mark_dirty ) { put_page_and_type(cli_pfp); - paging_mark_dirty(current->domain, _mfn(cli_mfn)); + paging_mark_dirty(current->domain, cli_mfn); } else put_page(cli_pfp); @@ -88,14 +93,14 @@ static inline void cli_put_page(void *cli_va, struct page_info *cli_pfp, int tmem_copy_from_client(struct page_info *pfp, xen_pfn_t cmfn, tmem_cli_va_param_t clibuf) { - unsigned long tmem_mfn, cli_mfn = 0; + mfn_t tmem_mfn, cli_mfn = INVALID_MFN; char *tmem_va, *cli_va = NULL; struct page_info *cli_pfp = NULL; int rc = 1; ASSERT(pfp != NULL); tmem_mfn = page_to_mfn(pfp); - tmem_va = map_domain_page(_mfn(tmem_mfn)); + tmem_va = map_domain_page(tmem_mfn); if ( guest_handle_is_null(clibuf) ) { cli_va = cli_get_page(cmfn, &cli_mfn, &cli_pfp, 0); @@ -125,7 +130,7 @@ int tmem_compress_from_client(xen_pfn_t cmfn, unsigned char *wmem = this_cpu(workmem); char *scratch = this_cpu(scratch_page); struct page_info *cli_pfp = NULL; - unsigned long cli_mfn = 0; + mfn_t cli_mfn = INVALID_MFN; void *cli_va = NULL; if ( dmem == NULL || wmem == NULL ) @@ -152,7 +157,7 @@ int tmem_compress_from_client(xen_pfn_t cmfn, int tmem_copy_to_client(xen_pfn_t cmfn, struct page_info *pfp, tmem_cli_va_param_t clibuf) { - unsigned long tmem_mfn, cli_mfn = 0; + mfn_t tmem_mfn, cli_mfn = INVALID_MFN; char *tmem_va, *cli_va = NULL; struct page_info *cli_pfp = NULL; int rc = 1; @@ -165,7 +170,8 @@ int tmem_copy_to_client(xen_pfn_t cmfn, struct page_info *pfp, return -EFAULT; } tmem_mfn = page_to_mfn(pfp); - tmem_va = map_domain_page(_mfn(tmem_mfn)); + tmem_va = map_domain_page(tmem_mfn); + if ( cli_va ) { memcpy(cli_va, tmem_va, PAGE_SIZE); @@ -181,7 +187,7 @@ int tmem_copy_to_client(xen_pfn_t cmfn, struct page_info *pfp, int tmem_decompress_to_client(xen_pfn_t cmfn, void *tmem_va, size_t size, tmem_cli_va_param_t clibuf) { - unsigned long cli_mfn = 0; + mfn_t cli_mfn = INVALID_MFN; struct page_info *cli_pfp = NULL; void *cli_va = NULL; char *scratch = this_cpu(scratch_page); From patchwork Wed Nov 1 14:03: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: 117700 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp928509qgn; Wed, 1 Nov 2017 07:06:01 -0700 (PDT) X-Google-Smtp-Source: ABhQp+T02tSuV+haT4u1PZBkfpVNtfCQGkY3yFBYmHxmhwUIXSc0Y/HNJZn9FkH/gXJdhoqSX406 X-Received: by 10.107.161.144 with SMTP id k138mr6951958ioe.218.1509545160956; Wed, 01 Nov 2017 07:06:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509545160; cv=none; d=google.com; s=arc-20160816; b=vYMZHJ26YcSkUY/cdVMc/NpE+ump87J+w4a/zxmjvfL/TLaXqYAn1j6Uf+fjXAhMd8 KfTYL9/Kn3DfIycL0QTD8cUNyqe7Ql8vJpH/A6DX+McLfuhHlLAF2EEnqeK8HL+kgJW6 FPobF3HZ6aEEoThZYEGZQkzPLy7CiZ5w/Xh495LFrcc2MQjhuOC2fEf72/GWMbYHb9e0 R8J4+OYfnt1mjX2yygGWqjRTnaf1kQskHM8GZGEaVVKhk1grFSahIPn57LcrpIjhgxer UJikC3POV3cZpjTIPuQi4Swt7MIpvynmYCvPDuCKJGgVjpHQ/MT8cAiKj1DAQxg9sWZ5 jopQ== 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:dkim-signature:arc-authentication-results; bh=oRMOTTykExY9mqQ93moobpO6leA94W0qHINjkPZHERU=; b=ZCxgTzvSwqpbbfPkd6Oc+ujdwGm6mRTW6vXdXl0kUc17tOaIC5DfWbDkzlpK/L+tpU vXUR4U3T9TG+2LP6DrqMlowq51cpKYFkvueMdwvY0eI+Gw37IvsgQnRh10/bTGbOWlPu mFU8t61/hYvOKmT2LXfmmVxZ0iPYKADCamwuTROpZjis4xKOn5DC1OzABn2NMkOG560S LjthTAf8xhJlV2SZlEPnfgTXYwhnW9Kxj54BR+7aOsJlB3JUh243DSK/S8UblhR1bRa1 AHwNxE5Wu1LQnAD6+TGZy1lr7nPz2NeMLs1QO9Il0vmVyAbWXlbxIfIULCw/iH54/8Rt ZvZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Cl02LT6m; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id o186si1163744ith.138.2017.11.01.07.06.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Nov 2017 07:06:00 -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; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Cl02LT6m; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.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 1e9tcD-0007uX-2H; Wed, 01 Nov 2017 14:03:33 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e9tcB-0007uJ-4Q for xen-devel@lists.xen.org; Wed, 01 Nov 2017 14:03:31 +0000 Received: from [85.158.143.35] by server-11.bemta-6.messagelabs.com id D0/52-20813-234D9F95; Wed, 01 Nov 2017 14:03:30 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGIsWRWlGSWpSXmKPExsVyMbThkK7BlZ+ RBv3rLSyWfFzM4sDocXT3b6YAxijWzLyk/IoE1oyW30UFt98zV2y7uJutgXFZN3MXIxeHkMAE RomzjfMYQRwWgXnMEr0/WllAHAmBflaJ7s6J7F2MnEBOnsT1/ecZIew0iTvPrkLZVRKnGl6yd TFyAI1Sk1jzJgpiajeTxLv1x5lB4mwCOhLrZtSClIsISEtc+3wZbBmzwBY2iZbPl1lAEsICiR Jfpy9hBrFZBFQlfs84CRbnFbCRuPdiBhPELnmJXW0XWUFmcgrYSiy7Yg4SFgIqud1wgn0Co+A CRoZVjBrFqUVlqUW6hmZ6SUWZ6RkluYmZObqGBmZ6uanFxYnpqTmJScV6yfm5mxiBIccABDsY 728MOMQoycGkJMq70/F7pBBfUn5KZUZicUZ8UWlOavEhRhkODiUJXoPLPyOFBItS01Mr0jJzg MEPk5bg4FES4VUASfMWFyTmFmemQ6ROMYZzXLhz6Q8Tx7FNl4HkgT23gOSjG3eBZMdNELkJTG 74/gBIPpv5uoFZiCUvPy9VSpzXE2ScAMi4jNI8uGWw6L7EKCslzMsIdL4QT0FqUW5mCar8K0Z xDkYlYV4bkCk8mXklcDe9AjqXCehcL4kfIOeWJCKkpBoYN877PP1YxHHfOboTb5fMn5HSVTaP 9/yS2nnFxtvmqDTVro3I2xN1N376fz+fg1/71xiLFpxYw/R2WXzW8jA36btFKYeWzfXz8v0qu kN656XFe57pm+UJ65We7FrBE7bFP2Gz7TOzVbM/p9xewWB8pELyIytb+pG6vhd1lmyGu5/dPc opuzj2ihJLcUaioRZzUXEiAOyyvc/pAgAA X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-7.tower-21.messagelabs.com!1509545008!79984598!1 X-Originating-IP: [209.85.128.194] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 61247 invoked from network); 1 Nov 2017 14:03:28 -0000 Received: from mail-wr0-f194.google.com (HELO mail-wr0-f194.google.com) (209.85.128.194) by server-7.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 1 Nov 2017 14:03:28 -0000 Received: by mail-wr0-f194.google.com with SMTP id 15so2037320wrb.5 for ; Wed, 01 Nov 2017 07:03:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XYaRozEAh6d3VR1DLkXJlQJtbTs16BV72Rk23anoaO8=; b=Cl02LT6m07PMpHMcbzuzfyFXiCqkOOR5si9C/2fBdMRwRex0dUvwkZjwHa4fuGo3yS rs3VRFW/36/PqBNjhSofkDWPmebeL76GgUAKR/ayP6u/CmNvzmR6+I9KoJ3dURCATAXg MoLXtH/4QnzM6+LMRc0u8pPViIlL/+WcxBrc8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XYaRozEAh6d3VR1DLkXJlQJtbTs16BV72Rk23anoaO8=; b=KB78NyrG6PNfANxGmJc9Kpv04g+gsDS3jHXu2DL1fO2hf0bMDxneazLFp9RiDaLx62 RBhXR/MUMj3D/rhRROdCTkUO7rmdPfZm3ZbpuF19NK87Qu8Ty1ETLvYERZtcq+Vqx1dr leZh+mW/s384J/52QtEa7pbK/QOeBmTF/DJ8EDsodMXMAaoOQf/hr4JT/N2Vh/HFkJlj cGhpqqViAOaCzhh39ObYD8tOoRmdv4buCHvLXq2qpV3DuGN2CAR8HSlzzg7c63Rwtygd JX3dawjI7ZI1D5Q6JVoDkWuivsLi2KraPfmRf2ESI9u/C3yoaFy/879qbTNukjElGYSj nqOg== X-Gm-Message-State: AMCzsaUl8/QeRi97Q9ax97u+o9ubAxDGo5+AEWThQP3aRywLO1IYdPO1 Zw1GZJXGdKuB/MjrSupTSma/+WQQmPg= X-Received: by 10.223.152.74 with SMTP id v68mr5089898wrb.277.1509545007322; Wed, 01 Nov 2017 07:03:27 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id w4sm595582wrc.17.2017.11.01.07.03.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Nov 2017 07:03:26 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 1 Nov 2017 14:03:16 +0000 Message-Id: <20171101140316.31333-5-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171101140316.31333-1-julien.grall@linaro.org> References: <20171101140316.31333-1-julien.grall@linaro.org> Cc: Jun Nakajima , Kevin Tian , Stefano Stabellini , Wei Liu , Suravee Suthikulpanit , Razvan Cojocaru , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Julien Grall , Ian Jackson , Tim Deegan , Julien Grall , Tamas K Lengyel , Jan Beulich , Shane Wang , Boris Ostrovsky , Gang Wei , Paul Durrant Subject: [Xen-devel] [PATCH v3 for-next 4/4] xen: Convert __page_to_mfn and __mfn_to_page to 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" Most of the users of page_to_mfn and mfn_to_page are either overriding the macros to make them work with mfn_t or use mfn_x/_mfn because the rest of the function use mfn_t. So make __page_to_mfn and __mfn_to_page return mfn_t by default. Only reasonable clean-ups are done in this patch because it is already quite big. So some of the files now override page_to_mfn and mfn_to_page to avoid using mfn_t. Lastly, domain_page_to_mfn is also converted to use mfn_t given that most of the callers are now switched to _mfn(domain_page_to_mfn(...)). Signed-off-by: Julien Grall Reviewed-by: Paul Durrant Acked-by: Razvan Cojocaru Reviewed-by: Boris Ostrovsky Reviewed-by: Kevin Tian Acked-by: Tim Deegan Acked-by: Stefano Stabellini --- Andrew suggested to drop IS_VALID_PAGE in xen/tmem_xen.h. His comment was: "/sigh This is tautological. The definition of a "valid mfn" in this case is one for which we have frametable entry, and by having a struct page_info in our hands, this is by definition true (unless you have a wild pointer, at which point your bug is elsewhere). IS_VALID_PAGE() is only ever used in assertions and never usefully, so instead I would remove it entirely rather than trying to fix it up." I can remove the function in a separate patch at the begining of the series if Konrad (TMEM maintainer) is happy with that. Cc: Stefano Stabellini Cc: Julien Grall Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Jan Beulich Cc: Konrad Rzeszutek Wilk Cc: Tim Deegan Cc: Wei Liu Cc: Razvan Cojocaru Cc: Tamas K Lengyel Cc: Paul Durrant Cc: Boris Ostrovsky Cc: Suravee Suthikulpanit Cc: Jun Nakajima Cc: Kevin Tian Cc: George Dunlap Cc: Gang Wei Cc: Shane Wang Changes in v3: - Rebase on the latest staging and fix some conflicts. Tags haven't be retained. - Switch the printf format to PRI_mfn Changes in v2: - Some part have been moved in separate patch - Remove one spurious comment - Convert domain_page_to_mfn to use mfn_t --- xen/arch/arm/domain_build.c | 2 -- xen/arch/arm/kernel.c | 2 +- xen/arch/arm/mem_access.c | 2 +- xen/arch/arm/mm.c | 8 ++++---- xen/arch/arm/p2m.c | 10 ++-------- xen/arch/x86/cpu/vpmu.c | 4 ++-- xen/arch/x86/domain.c | 21 +++++++++++---------- xen/arch/x86/domain_page.c | 6 +++--- xen/arch/x86/domctl.c | 2 +- xen/arch/x86/hvm/dm.c | 2 +- xen/arch/x86/hvm/dom0_build.c | 6 +++--- xen/arch/x86/hvm/emulate.c | 6 +++--- xen/arch/x86/hvm/hvm.c | 16 ++++++++-------- xen/arch/x86/hvm/ioreq.c | 6 +++--- xen/arch/x86/hvm/stdvga.c | 2 +- xen/arch/x86/hvm/svm/svm.c | 4 ++-- xen/arch/x86/hvm/viridian.c | 6 +++--- xen/arch/x86/hvm/vmx/vmcs.c | 2 +- xen/arch/x86/hvm/vmx/vmx.c | 10 +++++----- xen/arch/x86/hvm/vmx/vvmx.c | 6 +++--- xen/arch/x86/mm.c | 6 ------ xen/arch/x86/mm/guest_walk.c | 6 +++--- xen/arch/x86/mm/hap/guest_walk.c | 2 +- xen/arch/x86/mm/hap/hap.c | 6 ------ xen/arch/x86/mm/hap/nested_ept.c | 2 +- xen/arch/x86/mm/mem_sharing.c | 5 ----- xen/arch/x86/mm/p2m-ept.c | 4 ++++ xen/arch/x86/mm/p2m-pod.c | 6 ------ xen/arch/x86/mm/p2m.c | 6 ------ xen/arch/x86/mm/paging.c | 6 ------ xen/arch/x86/mm/shadow/private.h | 16 ++-------------- xen/arch/x86/numa.c | 2 +- xen/arch/x86/physdev.c | 2 +- xen/arch/x86/pv/callback.c | 6 ------ xen/arch/x86/pv/descriptor-tables.c | 10 ---------- xen/arch/x86/pv/dom0_build.c | 6 ++++++ xen/arch/x86/pv/domain.c | 6 ------ xen/arch/x86/pv/emul-gate-op.c | 6 ------ xen/arch/x86/pv/emul-priv-op.c | 10 ---------- xen/arch/x86/pv/grant_table.c | 6 ------ xen/arch/x86/pv/ro-page-fault.c | 6 ------ xen/arch/x86/smpboot.c | 6 ------ xen/arch/x86/tboot.c | 4 ++-- xen/arch/x86/traps.c | 4 ++-- xen/arch/x86/x86_64/mm.c | 6 ++++++ xen/common/domain.c | 4 ++-- xen/common/grant_table.c | 6 ++++++ xen/common/kimage.c | 6 ------ xen/common/memory.c | 6 ++++++ xen/common/page_alloc.c | 6 ++++++ xen/common/tmem.c | 2 +- xen/common/tmem_xen.c | 4 ---- xen/common/trace.c | 6 ++++++ xen/common/vmap.c | 9 +++++---- xen/common/xenoprof.c | 2 -- xen/drivers/passthrough/amd/iommu_map.c | 6 ++++++ xen/drivers/passthrough/iommu.c | 2 +- xen/drivers/passthrough/x86/iommu.c | 2 +- xen/include/asm-arm/mm.h | 16 +++++++++------- xen/include/asm-arm/p2m.h | 4 ++-- xen/include/asm-x86/mm.h | 12 ++++++------ xen/include/asm-x86/p2m.h | 2 +- xen/include/asm-x86/page.h | 32 ++++++++++++++++---------------- xen/include/xen/domain_page.h | 8 ++++---- xen/include/xen/tmem_xen.h | 2 +- 65 files changed, 166 insertions(+), 239 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 5532068ab1..4b554b49c1 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -50,8 +50,6 @@ struct map_range_data /* 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)) -#undef page_to_mfn -#define page_to_mfn(pg) _mfn(__page_to_mfn(pg)) //#define DEBUG_11_ALLOCATION #ifdef DEBUG_11_ALLOCATION diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c index c2755a9ab9..018d1aed06 100644 --- a/xen/arch/arm/kernel.c +++ b/xen/arch/arm/kernel.c @@ -295,7 +295,7 @@ static __init int kernel_decompress(struct bootmodule *mod) iounmap(input); return -ENOMEM; } - mfn = _mfn(page_to_mfn(pages)); + mfn = page_to_mfn(pages); output = __vmap(&mfn, 1 << kernel_order_out, 1, 1, PAGE_HYPERVISOR, VMAP_DEFAULT); rc = perform_gunzip(output, input, size); diff --git a/xen/arch/arm/mem_access.c b/xen/arch/arm/mem_access.c index 0f2cbb81d3..112e291cba 100644 --- a/xen/arch/arm/mem_access.c +++ b/xen/arch/arm/mem_access.c @@ -210,7 +210,7 @@ p2m_mem_access_check_and_get_page(vaddr_t gva, unsigned long flag, if ( t != p2m_ram_rw ) goto err; - page = mfn_to_page(mfn_x(mfn)); + page = mfn_to_page(mfn); if ( unlikely(!get_page(page, v->domain)) ) page = NULL; diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 3c328e2df5..b8818e03ab 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -477,7 +477,7 @@ void unmap_domain_page(const void *va) local_irq_restore(flags); } -unsigned long domain_page_map_to_mfn(const void *ptr) +mfn_t domain_page_map_to_mfn(const void *ptr) { unsigned long va = (unsigned long)ptr; lpae_t *map = this_cpu(xen_dommap); @@ -485,12 +485,12 @@ 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 virt_to_mfn(va); ASSERT(slot >= 0 && slot < DOMHEAP_ENTRIES); ASSERT(map[slot].pt.avail != 0); - return map[slot].pt.base + offset; + return _mfn(map[slot].pt.base + offset); } #endif @@ -1288,7 +1288,7 @@ int xenmem_add_to_physmap_one( return -EINVAL; } - mfn = _mfn(page_to_mfn(page)); + mfn = page_to_mfn(page); t = p2m_map_foreign; rcu_unlock_domain(od); diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 68b488997d..d1ef535a43 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -38,12 +38,6 @@ 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)); + printk("P2M @ %p mfn:%#"PRI_mfn"\n", + p2m->root, mfn_x(page_to_mfn(p2m->root))); dump_pt_walk(page_to_maddr(p2m->root), addr, P2M_ROOT_LEVEL, P2M_ROOT_PAGES); diff --git a/xen/arch/x86/cpu/vpmu.c b/xen/arch/x86/cpu/vpmu.c index 7baf4614be..b978e05613 100644 --- a/xen/arch/x86/cpu/vpmu.c +++ b/xen/arch/x86/cpu/vpmu.c @@ -653,7 +653,7 @@ static void pvpmu_finish(struct domain *d, xen_pmu_params_t *params) { struct vcpu *v; struct vpmu_struct *vpmu; - uint64_t mfn; + mfn_t mfn; void *xenpmu_data; if ( (params->vcpu >= d->max_vcpus) || (d->vcpu[params->vcpu] == NULL) ) @@ -675,7 +675,7 @@ static void pvpmu_finish(struct domain *d, xen_pmu_params_t *params) if ( xenpmu_data ) { mfn = domain_page_map_to_mfn(xenpmu_data); - ASSERT(mfn_valid(_mfn(mfn))); + ASSERT(mfn_valid(mfn)); unmap_domain_page_global(xenpmu_data); put_page_and_type(mfn_to_page(mfn)); } diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 735f45c133..cb596c4a31 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -186,7 +186,7 @@ void dump_pageframe_info(struct domain *d) } } printk(" DomPage %p: caf=%08lx, taf=%" PRtype_info "\n", - _p(page_to_mfn(page)), + _p(mfn_x(page_to_mfn(page))), page->count_info, page->u.inuse.type_info); } spin_unlock(&d->page_alloc_lock); @@ -199,7 +199,7 @@ void dump_pageframe_info(struct domain *d) page_list_for_each ( page, &d->xenpage_list ) { printk(" XenPage %p: caf=%08lx, taf=%" PRtype_info "\n", - _p(page_to_mfn(page)), + _p(mfn_x(page_to_mfn(page))), page->count_info, page->u.inuse.type_info); } spin_unlock(&d->page_alloc_lock); @@ -621,7 +621,8 @@ int arch_domain_soft_reset(struct domain *d) struct page_info *page = virt_to_page(d->shared_info), *new_page; int ret = 0; struct domain *owner; - unsigned long mfn, gfn; + mfn_t mfn; + unsigned long gfn; p2m_type_t p2mt; unsigned int i; @@ -655,7 +656,7 @@ int arch_domain_soft_reset(struct domain *d) ASSERT( owner == d ); mfn = page_to_mfn(page); - gfn = mfn_to_gmfn(d, mfn); + gfn = mfn_to_gmfn(d, mfn_x(mfn)); /* * gfn == INVALID_GFN indicates that the shared_info page was never mapped @@ -664,7 +665,7 @@ int arch_domain_soft_reset(struct domain *d) if ( gfn == gfn_x(INVALID_GFN) ) goto exit_put_page; - if ( mfn_x(get_gfn_query(d, gfn, &p2mt)) != mfn ) + if ( !mfn_eq(get_gfn_query(d, gfn, &p2mt), mfn) ) { printk(XENLOG_G_ERR "Failed to get Dom%d's shared_info GFN (%lx)\n", d->domain_id, gfn); @@ -681,7 +682,7 @@ int arch_domain_soft_reset(struct domain *d) goto exit_put_gfn; } - ret = guest_physmap_remove_page(d, _gfn(gfn), _mfn(mfn), PAGE_ORDER_4K); + ret = guest_physmap_remove_page(d, _gfn(gfn), mfn, PAGE_ORDER_4K); if ( ret ) { printk(XENLOG_G_ERR "Failed to remove Dom%d's shared_info frame %lx\n", @@ -690,7 +691,7 @@ int arch_domain_soft_reset(struct domain *d) goto exit_put_gfn; } - ret = guest_physmap_add_page(d, _gfn(gfn), _mfn(page_to_mfn(new_page)), + ret = guest_physmap_add_page(d, _gfn(gfn), page_to_mfn(new_page), PAGE_ORDER_4K); if ( ret ) { @@ -988,7 +989,7 @@ int arch_set_info_guest( { if ( (page->u.inuse.type_info & PGT_type_mask) == PGT_l4_page_table ) - done = !fill_ro_mpt(_mfn(page_to_mfn(page))); + done = !fill_ro_mpt(page_to_mfn(page)); page_unlock(page); } @@ -1115,7 +1116,7 @@ int arch_set_info_guest( l4_pgentry_t *l4tab; l4tab = map_domain_page(pagetable_get_mfn(v->arch.guest_table)); - *l4tab = l4e_from_pfn(page_to_mfn(cr3_page), + *l4tab = l4e_from_mfn(page_to_mfn(cr3_page), _PAGE_PRESENT|_PAGE_RW|_PAGE_USER|_PAGE_ACCESSED); unmap_domain_page(l4tab); } @@ -1945,7 +1946,7 @@ int domain_relinquish_resources(struct domain *d) if ( d->arch.pirq_eoi_map != NULL ) { unmap_domain_page_global(d->arch.pirq_eoi_map); - put_page_and_type(mfn_to_page(d->arch.pirq_eoi_map_mfn)); + put_page_and_type(mfn_to_page(_mfn(d->arch.pirq_eoi_map_mfn))); d->arch.pirq_eoi_map = NULL; d->arch.auto_unmask = 0; } diff --git a/xen/arch/x86/domain_page.c b/xen/arch/x86/domain_page.c index 3432a854dd..88046b39c9 100644 --- a/xen/arch/x86/domain_page.c +++ b/xen/arch/x86/domain_page.c @@ -331,13 +331,13 @@ void unmap_domain_page_global(const void *ptr) } /* Translate a map-domain-page'd address to the underlying MFN */ -unsigned long domain_page_map_to_mfn(const void *ptr) +mfn_t domain_page_map_to_mfn(const void *ptr) { unsigned long va = (unsigned long)ptr; const l1_pgentry_t *pl1e; if ( va >= DIRECTMAP_VIRT_START ) - return virt_to_mfn(ptr); + return _mfn(virt_to_mfn(ptr)); if ( va >= VMAP_VIRT_START && va < VMAP_VIRT_END ) { @@ -350,5 +350,5 @@ unsigned long domain_page_map_to_mfn(const void *ptr) pl1e = &__linear_l1_table[l1_linear_offset(va)]; } - return l1e_get_pfn(*pl1e); + return l1e_get_mfn(*pl1e); } diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c index 80b4df9ec9..9f6c92411a 100644 --- a/xen/arch/x86/domctl.c +++ b/xen/arch/x86/domctl.c @@ -429,7 +429,7 @@ long arch_do_domctl( { if ( i >= max_pfns ) break; - mfn = page_to_mfn(page); + mfn = mfn_x(page_to_mfn(page)); if ( copy_to_guest_offset(domctl->u.getmemlist.buffer, i, &mfn, 1) ) { diff --git a/xen/arch/x86/hvm/dm.c b/xen/arch/x86/hvm/dm.c index a787f43737..4760816ee6 100644 --- a/xen/arch/x86/hvm/dm.c +++ b/xen/arch/x86/hvm/dm.c @@ -219,7 +219,7 @@ static int modified_memory(struct domain *d, page = get_page_from_gfn(d, pfn, NULL, P2M_UNSHARE); if ( page ) { - mfn_t gmfn = _mfn(page_to_mfn(page)); + mfn_t gmfn = page_to_mfn(page); paging_mark_dirty(d, gmfn); /* diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index a67071c739..b50506ec63 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -120,7 +120,7 @@ static int __init pvh_populate_memory_range(struct domain *d, continue; } - rc = guest_physmap_add_page(d, _gfn(start), _mfn(page_to_mfn(page)), + rc = guest_physmap_add_page(d, _gfn(start), page_to_mfn(page), order); if ( rc != 0 ) { @@ -270,7 +270,7 @@ static int __init pvh_setup_vmx_realmode_helpers(struct domain *d) } write_32bit_pse_identmap(ident_pt); unmap_domain_page(ident_pt); - put_page(mfn_to_page(mfn_x(mfn))); + put_page(mfn_to_page(mfn)); d->arch.hvm_domain.params[HVM_PARAM_IDENT_PT] = gaddr; if ( pvh_add_mem_range(d, gaddr, gaddr + PAGE_SIZE, E820_RESERVED) ) printk("Unable to set identity page tables as reserved in the memory map\n"); @@ -288,7 +288,7 @@ static void __init pvh_steal_low_ram(struct domain *d, unsigned long start, for ( mfn = start; mfn < start + nr_pages; mfn++ ) { - struct page_info *pg = mfn_to_page(mfn); + struct page_info *pg = mfn_to_page(_mfn(mfn)); int rc; rc = unshare_xen_page_with_guest(pg, dom_io); diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c index e924ce07c4..312aa91416 100644 --- a/xen/arch/x86/hvm/emulate.c +++ b/xen/arch/x86/hvm/emulate.c @@ -590,7 +590,7 @@ static void *hvmemul_map_linear_addr( goto unhandleable; } - *mfn++ = _mfn(page_to_mfn(page)); + *mfn++ = page_to_mfn(page); if ( p2m_is_discard_write(p2mt) ) { @@ -622,7 +622,7 @@ static void *hvmemul_map_linear_addr( out: /* Drop all held references. */ while ( mfn-- > hvmemul_ctxt->mfn ) - put_page(mfn_to_page(mfn_x(*mfn))); + put_page(mfn_to_page(*mfn)); return err; } @@ -648,7 +648,7 @@ static void hvmemul_unmap_linear_addr( { ASSERT(mfn_valid(*mfn)); paging_mark_dirty(currd, *mfn); - put_page(mfn_to_page(mfn_x(*mfn))); + put_page(mfn_to_page(*mfn)); *mfn++ = _mfn(0); /* Clean slot for map()'s error checking. */ } diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 205b4cb685..4d795ee700 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -2211,7 +2211,7 @@ int hvm_set_cr0(unsigned long value, bool_t may_defer) v->arch.guest_table = pagetable_from_page(page); HVM_DBG_LOG(DBG_LEVEL_VMMU, "Update CR3 value = %lx, mfn = %lx", - v->arch.hvm_vcpu.guest_cr[3], page_to_mfn(page)); + v->arch.hvm_vcpu.guest_cr[3], mfn_x(page_to_mfn(page))); } } else if ( !(value & X86_CR0_PG) && (old_value & X86_CR0_PG) ) @@ -2546,7 +2546,7 @@ static void *_hvm_map_guest_frame(unsigned long gfn, bool_t permanent, if ( unlikely(p2m_is_discard_write(p2mt)) ) *writable = 0; else if ( !permanent ) - paging_mark_dirty(d, _mfn(page_to_mfn(page))); + paging_mark_dirty(d, page_to_mfn(page)); } if ( !permanent ) @@ -2588,7 +2588,7 @@ void *hvm_map_guest_frame_ro(unsigned long gfn, bool_t permanent) void hvm_unmap_guest_frame(void *p, bool_t permanent) { - unsigned long mfn; + mfn_t mfn; struct page_info *page; if ( !p ) @@ -2609,7 +2609,7 @@ void hvm_unmap_guest_frame(void *p, bool_t permanent) list_for_each_entry(track, &d->arch.hvm_domain.write_map.list, list) if ( track->page == page ) { - paging_mark_dirty(d, _mfn(mfn)); + paging_mark_dirty(d, mfn); list_del(&track->list); xfree(track); break; @@ -2626,7 +2626,7 @@ void hvm_mapped_guest_frames_mark_dirty(struct domain *d) spin_lock(&d->arch.hvm_domain.write_map.lock); list_for_each_entry(track, &d->arch.hvm_domain.write_map.list, list) - paging_mark_dirty(d, _mfn(page_to_mfn(track->page))); + paging_mark_dirty(d, page_to_mfn(track->page)); spin_unlock(&d->arch.hvm_domain.write_map.lock); } @@ -3200,8 +3200,8 @@ static enum hvm_translation_result __hvm_copy( if ( xchg(&lastpage, gfn_x(gfn)) != gfn_x(gfn) ) dprintk(XENLOG_G_DEBUG, - "%pv attempted write to read-only gfn %#lx (mfn=%#lx)\n", - v, gfn_x(gfn), page_to_mfn(page)); + "%pv attempted write to read-only gfn %#lx (mfn=%#"PRI_mfn")\n", + v, gfn_x(gfn), mfn_x(page_to_mfn(page))); } else { @@ -3209,7 +3209,7 @@ static enum hvm_translation_result __hvm_copy( memcpy(p, buf, count); else memset(p, 0, count); - paging_mark_dirty(v->domain, _mfn(page_to_mfn(page))); + paging_mark_dirty(v->domain, page_to_mfn(page)); } } else diff --git a/xen/arch/x86/hvm/ioreq.c b/xen/arch/x86/hvm/ioreq.c index d5afe20cc8..0f823d201a 100644 --- a/xen/arch/x86/hvm/ioreq.c +++ b/xen/arch/x86/hvm/ioreq.c @@ -268,7 +268,7 @@ static void hvm_remove_ioreq_gfn( struct domain *d, struct hvm_ioreq_page *iorp) { if ( guest_physmap_remove_page(d, _gfn(iorp->gfn), - _mfn(page_to_mfn(iorp->page)), 0) ) + page_to_mfn(iorp->page), 0) ) domain_crash(d); clear_page(iorp->va); } @@ -281,9 +281,9 @@ static int hvm_add_ioreq_gfn( clear_page(iorp->va); rc = guest_physmap_add_page(d, _gfn(iorp->gfn), - _mfn(page_to_mfn(iorp->page)), 0); + page_to_mfn(iorp->page), 0); if ( rc == 0 ) - paging_mark_dirty(d, _mfn(page_to_mfn(iorp->page))); + paging_mark_dirty(d, page_to_mfn(iorp->page)); return rc; } diff --git a/xen/arch/x86/hvm/stdvga.c b/xen/arch/x86/hvm/stdvga.c index 088fbdf8ce..925bab2438 100644 --- a/xen/arch/x86/hvm/stdvga.c +++ b/xen/arch/x86/hvm/stdvga.c @@ -590,7 +590,7 @@ void stdvga_init(struct domain *d) if ( pg == NULL ) break; s->vram_page[i] = pg; - clear_domain_page(_mfn(page_to_mfn(pg))); + clear_domain_page(page_to_mfn(pg)); } if ( i == ARRAY_SIZE(s->vram_page) ) diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index b9cf423fd9..f50f931598 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -1521,7 +1521,7 @@ static int svm_cpu_up_prepare(unsigned int cpu) if ( !pg ) goto err; - clear_domain_page(_mfn(page_to_mfn(pg))); + clear_domain_page(page_to_mfn(pg)); *this_hsa = page_to_maddr(pg); } @@ -1531,7 +1531,7 @@ static int svm_cpu_up_prepare(unsigned int cpu) if ( !pg ) goto err; - clear_domain_page(_mfn(page_to_mfn(pg))); + clear_domain_page(page_to_mfn(pg)); *this_vmcb = page_to_maddr(pg); } diff --git a/xen/arch/x86/hvm/viridian.c b/xen/arch/x86/hvm/viridian.c index f0fa59d7d5..070551e1ab 100644 --- a/xen/arch/x86/hvm/viridian.c +++ b/xen/arch/x86/hvm/viridian.c @@ -354,7 +354,7 @@ static void enable_hypercall_page(struct domain *d) if ( page ) put_page(page); gdprintk(XENLOG_WARNING, "Bad GMFN %#"PRI_gfn" (MFN %#"PRI_mfn")\n", - gmfn, page ? page_to_mfn(page) : mfn_x(INVALID_MFN)); + gmfn, mfn_x(page ? page_to_mfn(page) : INVALID_MFN)); return; } @@ -414,7 +414,7 @@ static void initialize_vp_assist(struct vcpu *v) fail: gdprintk(XENLOG_WARNING, "Bad GMFN %#"PRI_gfn" (MFN %#"PRI_mfn")\n", gmfn, - page ? page_to_mfn(page) : mfn_x(INVALID_MFN)); + mfn_x(page ? page_to_mfn(page) : INVALID_MFN)); } static void teardown_vp_assist(struct vcpu *v) @@ -494,7 +494,7 @@ static void update_reference_tsc(struct domain *d, bool_t initialize) if ( page ) put_page(page); gdprintk(XENLOG_WARNING, "Bad GMFN %#"PRI_gfn" (MFN %#"PRI_mfn")\n", - gmfn, page ? page_to_mfn(page) : mfn_x(INVALID_MFN)); + gmfn, mfn_x(page ? page_to_mfn(page) : INVALID_MFN)); return; } diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c index b5100b5021..8eaa58e3c0 100644 --- a/xen/arch/x86/hvm/vmx/vmcs.c +++ b/xen/arch/x86/hvm/vmx/vmcs.c @@ -1437,7 +1437,7 @@ int vmx_vcpu_enable_pml(struct vcpu *v) vmx_vmcs_enter(v); - __vmwrite(PML_ADDRESS, page_to_mfn(v->arch.hvm_vmx.pml_pg) << PAGE_SHIFT); + __vmwrite(PML_ADDRESS, page_to_maddr(v->arch.hvm_vmx.pml_pg)); __vmwrite(GUEST_PML_INDEX, NR_PML_ENTRIES - 1); v->arch.hvm_vmx.secondary_exec_control |= SECONDARY_EXEC_ENABLE_PML; diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index b18cceab55..c657ba89f5 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -2978,7 +2978,7 @@ gp_fault: static int vmx_alloc_vlapic_mapping(struct domain *d) { struct page_info *pg; - unsigned long mfn; + mfn_t mfn; if ( !cpu_has_vmx_virtualize_apic_accesses ) return 0; @@ -2987,10 +2987,10 @@ static int vmx_alloc_vlapic_mapping(struct domain *d) if ( !pg ) return -ENOMEM; mfn = page_to_mfn(pg); - clear_domain_page(_mfn(mfn)); + clear_domain_page(mfn); share_xen_page_with_guest(pg, d, XENSHARE_writable); - d->arch.hvm_domain.vmx.apic_access_mfn = mfn; - set_mmio_p2m_entry(d, paddr_to_pfn(APIC_DEFAULT_PHYS_BASE), _mfn(mfn), + d->arch.hvm_domain.vmx.apic_access_mfn = mfn_x(mfn); + set_mmio_p2m_entry(d, paddr_to_pfn(APIC_DEFAULT_PHYS_BASE), mfn, PAGE_ORDER_4K, p2m_get_hostp2m(d)->default_access); return 0; @@ -3001,7 +3001,7 @@ static void vmx_free_vlapic_mapping(struct domain *d) unsigned long mfn = d->arch.hvm_domain.vmx.apic_access_mfn; if ( mfn != 0 ) - free_shared_domheap_page(mfn_to_page(mfn)); + free_shared_domheap_page(mfn_to_page(_mfn(mfn))); } static void vmx_install_vlapic_mapping(struct vcpu *v) diff --git a/xen/arch/x86/hvm/vmx/vvmx.c b/xen/arch/x86/hvm/vmx/vvmx.c index dde02c076b..4836d69c0e 100644 --- a/xen/arch/x86/hvm/vmx/vvmx.c +++ b/xen/arch/x86/hvm/vmx/vvmx.c @@ -84,7 +84,7 @@ int nvmx_vcpu_initialise(struct vcpu *v) } v->arch.hvm_vmx.vmread_bitmap = vmread_bitmap; - clear_domain_page(_mfn(page_to_mfn(vmread_bitmap))); + clear_domain_page(page_to_mfn(vmread_bitmap)); vmwrite_bitmap = alloc_domheap_page(NULL, 0); if ( !vmwrite_bitmap ) @@ -1729,7 +1729,7 @@ int nvmx_handle_vmptrld(struct cpu_user_regs *regs) nvcpu->nv_vvmcx = vvmcx; nvcpu->nv_vvmcxaddr = gpa; v->arch.hvm_vmx.vmcs_shadow_maddr = - pfn_to_paddr(domain_page_map_to_mfn(vvmcx)); + mfn_to_maddr(domain_page_map_to_mfn(vvmcx)); } else { @@ -1815,7 +1815,7 @@ int nvmx_handle_vmclear(struct cpu_user_regs *regs) { if ( writable ) clear_vvmcs_launched(&nvmx->launched_list, - domain_page_map_to_mfn(vvmcs)); + mfn_x(domain_page_map_to_mfn(vvmcs))); else rc = VMFAIL_VALID; hvm_unmap_guest_frame(vvmcs, 0); diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index a20fdcaea4..f6ca4f884b 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -128,12 +128,6 @@ #include "pv/mm.h" -/* Override macros from asm/page.h to make them work with mfn_t */ -#undef mfn_to_page -#define mfn_to_page(mfn) __mfn_to_page(mfn_x(mfn)) -#undef page_to_mfn -#define page_to_mfn(pg) _mfn(__page_to_mfn(pg)) - /* Mapping of the fixmap space needed early. */ l1_pgentry_t __section(".bss.page_aligned") __aligned(PAGE_SIZE) l1_fixmap[L1_PAGETABLE_ENTRIES]; diff --git a/xen/arch/x86/mm/guest_walk.c b/xen/arch/x86/mm/guest_walk.c index 6055fec1ad..f67aeda3d0 100644 --- a/xen/arch/x86/mm/guest_walk.c +++ b/xen/arch/x86/mm/guest_walk.c @@ -469,20 +469,20 @@ guest_walk_tables(struct vcpu *v, struct p2m_domain *p2m, if ( l3p ) { unmap_domain_page(l3p); - put_page(mfn_to_page(mfn_x(gw->l3mfn))); + put_page(mfn_to_page(gw->l3mfn)); } #endif #if GUEST_PAGING_LEVELS >= 3 if ( l2p ) { unmap_domain_page(l2p); - put_page(mfn_to_page(mfn_x(gw->l2mfn))); + put_page(mfn_to_page(gw->l2mfn)); } #endif if ( l1p ) { unmap_domain_page(l1p); - put_page(mfn_to_page(mfn_x(gw->l1mfn))); + put_page(mfn_to_page(gw->l1mfn)); } return walk_ok; diff --git a/xen/arch/x86/mm/hap/guest_walk.c b/xen/arch/x86/mm/hap/guest_walk.c index c550017ba4..cb3f9cebe7 100644 --- a/xen/arch/x86/mm/hap/guest_walk.c +++ b/xen/arch/x86/mm/hap/guest_walk.c @@ -83,7 +83,7 @@ unsigned long hap_p2m_ga_to_gfn(GUEST_PAGING_LEVELS)( *pfec &= ~PFEC_page_present; goto out_tweak_pfec; } - top_mfn = _mfn(page_to_mfn(top_page)); + top_mfn = page_to_mfn(top_page); /* Map the top-level table and call the tree-walker */ ASSERT(mfn_valid(top_mfn)); diff --git a/xen/arch/x86/mm/hap/hap.c b/xen/arch/x86/mm/hap/hap.c index 41deb90787..97f2516ecd 100644 --- a/xen/arch/x86/mm/hap/hap.c +++ b/xen/arch/x86/mm/hap/hap.c @@ -42,12 +42,6 @@ #include "private.h" -/* Override macros from asm/page.h to make them work with mfn_t */ -#undef mfn_to_page -#define mfn_to_page(_m) __mfn_to_page(mfn_x(_m)) -#undef page_to_mfn -#define page_to_mfn(_pg) _mfn(__page_to_mfn(_pg)) - /************************************************/ /* HAP VRAM TRACKING SUPPORT */ /************************************************/ diff --git a/xen/arch/x86/mm/hap/nested_ept.c b/xen/arch/x86/mm/hap/nested_ept.c index 14b1bb01e9..1738df69f6 100644 --- a/xen/arch/x86/mm/hap/nested_ept.c +++ b/xen/arch/x86/mm/hap/nested_ept.c @@ -173,7 +173,7 @@ nept_walk_tables(struct vcpu *v, unsigned long l2ga, ept_walk_t *gw) goto map_err; gw->lxe[lvl] = lxp[ept_lvl_table_offset(l2ga, lvl)]; unmap_domain_page(lxp); - put_page(mfn_to_page(mfn_x(lxmfn))); + put_page(mfn_to_page(lxmfn)); if ( nept_non_present_check(gw->lxe[lvl]) ) goto non_present; diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c index 6f4be95515..6ecf0b27d5 100644 --- a/xen/arch/x86/mm/mem_sharing.c +++ b/xen/arch/x86/mm/mem_sharing.c @@ -152,11 +152,6 @@ static inline shr_handle_t get_next_handle(void) #define mem_sharing_enabled(d) \ (is_hvm_domain(d) && (d)->arch.hvm_domain.mem_sharing_enabled) -#undef mfn_to_page -#define mfn_to_page(_m) __mfn_to_page(mfn_x(_m)) -#undef page_to_mfn -#define page_to_mfn(_pg) _mfn(__page_to_mfn(_pg)) - static atomic_t nr_saved_mfns = ATOMIC_INIT(0); static atomic_t nr_shared_mfns = ATOMIC_INIT(0); diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c index b4996ce658..8885916c0a 100644 --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -33,6 +33,10 @@ #include "mm-locks.h" +/* Override macros from asm/page.h to avoid using typesafe mfn_t. */ +#undef mfn_to_page +#define mfn_to_page(mfn) __mfn_to_page(_mfn(mfn)) + #define atomic_read_ept_entry(__pepte) \ ( (ept_entry_t) { .epte = read_atomic(&(__pepte)->epte) } ) diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c index 0a811ccf28..7a88074c31 100644 --- a/xen/arch/x86/mm/p2m-pod.c +++ b/xen/arch/x86/mm/p2m-pod.c @@ -29,12 +29,6 @@ #include "mm-locks.h" -/* Override macros from asm/page.h to make them work with mfn_t */ -#undef mfn_to_page -#define mfn_to_page(_m) __mfn_to_page(mfn_x(_m)) -#undef page_to_mfn -#define page_to_mfn(_pg) _mfn(__page_to_mfn(_pg)) - #define superpage_aligned(_x) (((_x)&(SUPERPAGE_PAGES-1))==0) /* Enforce lock ordering when grabbing the "external" page_alloc lock */ diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index c72a3cdebb..b71f51e0b2 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -47,12 +47,6 @@ bool_t __initdata opt_hap_1gb = 1, __initdata opt_hap_2mb = 1; boolean_param("hap_1gb", opt_hap_1gb); boolean_param("hap_2mb", opt_hap_2mb); -/* Override macros from asm/page.h to make them work with mfn_t */ -#undef mfn_to_page -#define mfn_to_page(_m) __mfn_to_page(mfn_x(_m)) -#undef page_to_mfn -#define page_to_mfn(_pg) _mfn(__page_to_mfn(_pg)) - DEFINE_PERCPU_RWLOCK_GLOBAL(p2m_percpu_rwlock); /* Init the datastructures for later use by the p2m code */ diff --git a/xen/arch/x86/mm/paging.c b/xen/arch/x86/mm/paging.c index 1e2c9ba4cc..cb97642cbc 100644 --- a/xen/arch/x86/mm/paging.c +++ b/xen/arch/x86/mm/paging.c @@ -47,12 +47,6 @@ /* Per-CPU variable for enforcing the lock ordering */ DEFINE_PER_CPU(int, mm_lock_level); -/* Override macros from asm/page.h to make them work with mfn_t */ -#undef mfn_to_page -#define mfn_to_page(_m) __mfn_to_page(mfn_x(_m)) -#undef page_to_mfn -#define page_to_mfn(_pg) _mfn(__page_to_mfn(_pg)) - /************************************************/ /* LOG DIRTY SUPPORT */ /************************************************/ diff --git a/xen/arch/x86/mm/shadow/private.h b/xen/arch/x86/mm/shadow/private.h index 6a03370402..b9cc680f4e 100644 --- a/xen/arch/x86/mm/shadow/private.h +++ b/xen/arch/x86/mm/shadow/private.h @@ -315,7 +315,7 @@ static inline int page_is_out_of_sync(struct page_info *p) static inline int mfn_is_out_of_sync(mfn_t gmfn) { - return page_is_out_of_sync(mfn_to_page(mfn_x(gmfn))); + return page_is_out_of_sync(mfn_to_page(gmfn)); } static inline int page_oos_may_write(struct page_info *p) @@ -326,7 +326,7 @@ static inline int page_oos_may_write(struct page_info *p) static inline int mfn_oos_may_write(mfn_t gmfn) { - return page_oos_may_write(mfn_to_page(mfn_x(gmfn))); + return page_oos_may_write(mfn_to_page(gmfn)); } #endif /* (SHADOW_OPTIMIZATIONS & SHOPT_OUT_OF_SYNC) */ @@ -465,18 +465,6 @@ void sh_reset_l3_up_pointers(struct vcpu *v); * MFN/page-info handling */ -/* Override macros from asm/page.h to make them work with mfn_t */ -#undef mfn_to_page -#define mfn_to_page(_m) __mfn_to_page(mfn_x(_m)) -#undef page_to_mfn -#define page_to_mfn(_pg) _mfn(__page_to_mfn(_pg)) - -/* Override pagetable_t <-> struct page_info conversions to work with mfn_t */ -#undef pagetable_get_page -#define pagetable_get_page(x) mfn_to_page(pagetable_get_mfn(x)) -#undef pagetable_from_page -#define pagetable_from_page(pg) pagetable_from_mfn(page_to_mfn(pg)) - #define backpointer(sp) _mfn(pdx_to_pfn((unsigned long)(sp)->v.sh.back)) static inline unsigned long __backpointer(const struct page_info *sp) { diff --git a/xen/arch/x86/numa.c b/xen/arch/x86/numa.c index 4fc967f893..a87987da6f 100644 --- a/xen/arch/x86/numa.c +++ b/xen/arch/x86/numa.c @@ -430,7 +430,7 @@ static void dump_numa(unsigned char key) spin_lock(&d->page_alloc_lock); page_list_for_each(page, &d->page_list) { - i = phys_to_nid((paddr_t)page_to_mfn(page) << PAGE_SHIFT); + i = phys_to_nid(page_to_maddr(page)); page_num_node[i]++; } spin_unlock(&d->page_alloc_lock); diff --git a/xen/arch/x86/physdev.c b/xen/arch/x86/physdev.c index a5fedca671..5422f3e372 100644 --- a/xen/arch/x86/physdev.c +++ b/xen/arch/x86/physdev.c @@ -242,7 +242,7 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) } if ( cmpxchg(&currd->arch.pirq_eoi_map_mfn, - 0, page_to_mfn(page)) != 0 ) + 0, mfn_x(page_to_mfn(page))) != 0 ) { put_page_and_type(page); ret = -EBUSY; diff --git a/xen/arch/x86/pv/callback.c b/xen/arch/x86/pv/callback.c index 97d8438600..5957cb5085 100644 --- a/xen/arch/x86/pv/callback.c +++ b/xen/arch/x86/pv/callback.c @@ -31,12 +31,6 @@ #include -/* Override macros from asm/page.h to make them work with mfn_t */ -#undef mfn_to_page -#define mfn_to_page(mfn) __mfn_to_page(mfn_x(mfn)) -#undef page_to_mfn -#define page_to_mfn(pg) _mfn(__page_to_mfn(pg)) - static int register_guest_nmi_callback(unsigned long address) { struct vcpu *curr = current; diff --git a/xen/arch/x86/pv/descriptor-tables.c b/xen/arch/x86/pv/descriptor-tables.c index 81973af124..f2b20f9910 100644 --- a/xen/arch/x86/pv/descriptor-tables.c +++ b/xen/arch/x86/pv/descriptor-tables.c @@ -25,16 +25,6 @@ #include #include -/* Override macros from asm/page.h to make them work with mfn_t */ -#undef mfn_to_page -#define mfn_to_page(mfn) __mfn_to_page(mfn_x(mfn)) -#undef page_to_mfn -#define page_to_mfn(pg) _mfn(__page_to_mfn(pg)) - -/******************* - * Descriptor Tables - */ - void pv_destroy_gdt(struct vcpu *v) { l1_pgentry_t *pl1e; diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index 44601d08d3..1ac843e603 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -20,6 +20,12 @@ #include #include +/* Override macros from asm/page.h to avoid using typesafe mfn_t. */ +#undef page_to_mfn +#define page_to_mfn(pg) mfn_x(__page_to_mfn(pg)) +#undef mfn_to_page +#define mfn_to_page(mfn) __mfn_to_page(_mfn(mfn)) + /* Allow ring-3 access in long mode as guest cannot use ring 1 ... */ #define BASE_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_USER) #define L1_PROT (BASE_PROT|_PAGE_GUEST_KERNEL) diff --git a/xen/arch/x86/pv/domain.c b/xen/arch/x86/pv/domain.c index 2234128bb3..93f8fa4323 100644 --- a/xen/arch/x86/pv/domain.c +++ b/xen/arch/x86/pv/domain.c @@ -11,12 +11,6 @@ #include -/* Override macros from asm/page.h to make them work with mfn_t */ -#undef mfn_to_page -#define mfn_to_page(mfn) __mfn_to_page(mfn_x(mfn)) -#undef page_to_mfn -#define page_to_mfn(pg) _mfn(__page_to_mfn(pg)) - static void noreturn continue_nonidle_domain(struct vcpu *v) { check_wakeup_from_wait(); diff --git a/xen/arch/x86/pv/emul-gate-op.c b/xen/arch/x86/pv/emul-gate-op.c index 0f89c91dff..5cdb54c937 100644 --- a/xen/arch/x86/pv/emul-gate-op.c +++ b/xen/arch/x86/pv/emul-gate-op.c @@ -41,12 +41,6 @@ #include "emulate.h" -/* Override macros from asm/page.h to make them work with mfn_t */ -#undef mfn_to_page -#define mfn_to_page(mfn) __mfn_to_page(mfn_x(mfn)) -#undef page_to_mfn -#define page_to_mfn(pg) _mfn(__page_to_mfn(pg)) - static int read_gate_descriptor(unsigned int gate_sel, const struct vcpu *v, unsigned int *sel, diff --git a/xen/arch/x86/pv/emul-priv-op.c b/xen/arch/x86/pv/emul-priv-op.c index 2f9264548a..6ebaf2f1e3 100644 --- a/xen/arch/x86/pv/emul-priv-op.c +++ b/xen/arch/x86/pv/emul-priv-op.c @@ -43,16 +43,6 @@ #include "emulate.h" #include "mm.h" -/* Override macros from asm/page.h to make them work with mfn_t */ -#undef mfn_to_page -#define mfn_to_page(mfn) __mfn_to_page(mfn_x(mfn)) -#undef page_to_mfn -#define page_to_mfn(pg) _mfn(__page_to_mfn(pg)) - -/*********************** - * I/O emulation support - */ - struct priv_op_ctxt { struct x86_emulate_ctxt ctxt; struct { diff --git a/xen/arch/x86/pv/grant_table.c b/xen/arch/x86/pv/grant_table.c index aaca228c6b..97323367c5 100644 --- a/xen/arch/x86/pv/grant_table.c +++ b/xen/arch/x86/pv/grant_table.c @@ -27,12 +27,6 @@ #include "mm.h" -/* Override macros from asm/page.h to make them work with mfn_t */ -#undef mfn_to_page -#define mfn_to_page(mfn) __mfn_to_page(mfn_x(mfn)) -#undef page_to_mfn -#define page_to_mfn(pg) _mfn(__page_to_mfn(pg)) - static unsigned int grant_to_pte_flags(unsigned int grant_flags, unsigned int cache_flags) { diff --git a/xen/arch/x86/pv/ro-page-fault.c b/xen/arch/x86/pv/ro-page-fault.c index 6b2976d3df..a7b7eb5113 100644 --- a/xen/arch/x86/pv/ro-page-fault.c +++ b/xen/arch/x86/pv/ro-page-fault.c @@ -33,12 +33,6 @@ #include "emulate.h" #include "mm.h" -/* Override macros from asm/page.h to make them work with mfn_t */ -#undef mfn_to_page -#define mfn_to_page(mfn) __mfn_to_page(mfn_x(mfn)) -#undef page_to_mfn -#define page_to_mfn(pg) _mfn(__page_to_mfn(pg)) - /********************* * Writable Pagetables */ diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index 1609b627ae..0791345a47 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -46,12 +46,6 @@ #include #include -/* Override macros from asm/page.h to make them work with mfn_t */ -#undef mfn_to_page -#define mfn_to_page(mfn) __mfn_to_page(mfn_x(mfn)) -#undef page_to_mfn -#define page_to_mfn(pg) _mfn(__page_to_mfn(pg)) - #define setup_trampoline() (bootsym_phys(trampoline_realmode_entry)) unsigned long __read_mostly trampoline_phys; diff --git a/xen/arch/x86/tboot.c b/xen/arch/x86/tboot.c index 59d7c477f4..e9522f06ec 100644 --- a/xen/arch/x86/tboot.c +++ b/xen/arch/x86/tboot.c @@ -184,7 +184,7 @@ static void update_pagetable_mac(vmac_ctx_t *ctx) for ( mfn = 0; mfn < max_page; mfn++ ) { - struct page_info *page = mfn_to_page(mfn); + struct page_info *page = mfn_to_page(_mfn(mfn)); if ( !mfn_valid(_mfn(mfn)) ) continue; @@ -276,7 +276,7 @@ static void tboot_gen_xenheap_integrity(const uint8_t key[TB_KEY_SIZE], vmac_set_key((uint8_t *)key, &ctx); for ( mfn = 0; mfn < max_page; mfn++ ) { - struct page_info *page = __mfn_to_page(mfn); + struct page_info *page = mfn_to_page(_mfn(mfn)); if ( !mfn_valid(_mfn(mfn)) ) continue; diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index 86506f3747..e2562eee4e 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -810,8 +810,8 @@ int wrmsr_hypervisor_regs(uint32_t idx, uint64_t val) } gdprintk(XENLOG_WARNING, - "Bad GMFN %lx (MFN %lx) to MSR %08x\n", - gmfn, page ? page_to_mfn(page) : -1UL, base); + "Bad GMFN %lx (MFN %#"PRI_mfn") to MSR %08x\n", + gmfn, mfn_x(page ? page_to_mfn(page) : INVALID_MFN), base); return 0; } diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index 34cd8457cf..ccad3d448b 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -40,6 +40,12 @@ asm(".file \"" __FILE__ "\""); #include #include +/* Override macros from asm/page.h to avoid using typesafe mfn_t. */ +#undef page_to_mfn +#define page_to_mfn(pg) mfn_x(__page_to_mfn(pg)) +#undef mfn_to_page +#define mfn_to_page(mfn) __mfn_to_page(_mfn(mfn)) + unsigned int __read_mostly m2p_compat_vstart = __HYPERVISOR_COMPAT_VIRT_START; l2_pgentry_t *compat_idle_pg_table_l2; diff --git a/xen/common/domain.c b/xen/common/domain.c index 5aebcf265f..e8302e8e1b 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -1192,7 +1192,7 @@ int map_vcpu_info(struct vcpu *v, unsigned long gfn, unsigned offset) } v->vcpu_info = new_info; - v->vcpu_info_mfn = _mfn(page_to_mfn(page)); + v->vcpu_info_mfn = page_to_mfn(page); /* Set new vcpu_info pointer /before/ setting pending flags. */ smp_wmb(); @@ -1225,7 +1225,7 @@ void unmap_vcpu_info(struct vcpu *v) vcpu_info_reset(v); /* NB: Clobbers v->vcpu_info_mfn */ - put_page_and_type(mfn_to_page(mfn_x(mfn))); + put_page_and_type(mfn_to_page(mfn)); } int default_initialise_vcpu(struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg) diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c index c5950f2b3f..73a9d0293b 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -40,6 +40,12 @@ #include #include +/* Override macros from asm/page.h to avoid using typesafe mfn_t. */ +#undef page_to_mfn +#define page_to_mfn(pg) mfn_x(__page_to_mfn(pg)) +#undef mfn_to_page +#define mfn_to_page(mfn) __mfn_to_page(_mfn(mfn)) + /* Per-domain grant information. */ struct grant_table { /* diff --git a/xen/common/kimage.c b/xen/common/kimage.c index afd8292cc1..210241dfb7 100644 --- a/xen/common/kimage.c +++ b/xen/common/kimage.c @@ -23,12 +23,6 @@ #include -/* Override macros from asm/page.h to make them work with mfn_t */ -#undef mfn_to_page -#define mfn_to_page(mfn) __mfn_to_page(mfn_x(mfn)) -#undef page_to_mfn -#define page_to_mfn(pg) _mfn(__page_to_mfn(pg)) - /* * When kexec transitions to the new kernel there is a one-to-one * mapping between physical and virtual addresses. On processors diff --git a/xen/common/memory.c b/xen/common/memory.c index ad987e0f29..e467f271c7 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -29,6 +29,12 @@ #include #include +/* Override macros from asm/page.h to avoid using typesafe mfn_t. */ +#undef page_to_mfn +#define page_to_mfn(pg) mfn_x(__page_to_mfn(pg)) +#undef mfn_to_page +#define mfn_to_page(mfn) __mfn_to_page(_mfn(mfn)) + struct memop_args { /* INPUT */ struct domain *domain; /* Domain to be affected. */ diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 5616a82263..34c2089cd2 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -150,6 +150,12 @@ #define p2m_pod_offline_or_broken_replace(pg) BUG_ON(pg != NULL) #endif +/* Override macros from asm/page.h to avoid using typesafe mfn_t. */ +#undef page_to_mfn +#define page_to_mfn(pg) mfn_x(__page_to_mfn(pg)) +#undef mfn_to_page +#define mfn_to_page(mfn) __mfn_to_page(_mfn(mfn)) + /* * Comma-separated list of hexadecimal page numbers containing bad bytes. * e.g. 'badpage=0x3f45,0x8a321'. diff --git a/xen/common/tmem.c b/xen/common/tmem.c index 324f42a6f9..c077f87e77 100644 --- a/xen/common/tmem.c +++ b/xen/common/tmem.c @@ -243,7 +243,7 @@ static void tmem_persistent_pool_page_put(void *page_va) struct page_info *pi; ASSERT(IS_PAGE_ALIGNED(page_va)); - pi = mfn_to_page(virt_to_mfn(page_va)); + pi = mfn_to_page(_mfn(virt_to_mfn(page_va))); ASSERT(IS_VALID_PAGE(pi)); __tmem_free_page_thispool(pi); } diff --git a/xen/common/tmem_xen.c b/xen/common/tmem_xen.c index bd52e44faf..bf7b14f79a 100644 --- a/xen/common/tmem_xen.c +++ b/xen/common/tmem_xen.c @@ -14,10 +14,6 @@ #include #include -/* Override macros from asm/page.h to make them work with mfn_t */ -#undef page_to_mfn -#define page_to_mfn(pg) _mfn(__page_to_mfn(pg)) - bool __read_mostly opt_tmem; boolean_param("tmem", opt_tmem); diff --git a/xen/common/trace.c b/xen/common/trace.c index 2e18702317..cf8f8b0997 100644 --- a/xen/common/trace.c +++ b/xen/common/trace.c @@ -42,6 +42,12 @@ CHECK_t_buf; #define compat_t_rec t_rec #endif +/* Override macros from asm/page.h to avoid using typesafe mfn_t. */ +#undef page_to_mfn +#define page_to_mfn(pg) mfn_x(__page_to_mfn(pg)) +#undef mfn_to_page +#define mfn_to_page(mfn) __mfn_to_page(_mfn(mfn)) + /* opt_tbuf_size: trace buffer size (in pages) for each cpu */ static unsigned int opt_tbuf_size; static unsigned int opt_tevt_mask; diff --git a/xen/common/vmap.c b/xen/common/vmap.c index 0b23f8fb97..10f32b29e0 100644 --- a/xen/common/vmap.c +++ b/xen/common/vmap.c @@ -36,7 +36,7 @@ void __init vm_init_type(enum vmap_region type, void *start, void *end) { struct page_info *pg = alloc_domheap_page(NULL, 0); - map_pages_to_xen(va, page_to_mfn(pg), 1, PAGE_HYPERVISOR); + map_pages_to_xen(va, mfn_x(page_to_mfn(pg)), 1, PAGE_HYPERVISOR); clear_page((void *)va); } bitmap_fill(vm_bitmap(type), vm_low[type]); @@ -107,7 +107,8 @@ static void *vm_alloc(unsigned int nr, unsigned int align, { unsigned long va = (unsigned long)vm_bitmap(t) + vm_top[t] / 8; - if ( !map_pages_to_xen(va, page_to_mfn(pg), 1, PAGE_HYPERVISOR) ) + if ( !map_pages_to_xen(va, mfn_x(page_to_mfn(pg)), + 1, PAGE_HYPERVISOR) ) { clear_page((void *)va); vm_top[t] += PAGE_SIZE * 8; @@ -258,7 +259,7 @@ static void *vmalloc_type(size_t size, enum vmap_region type) pg = alloc_domheap_page(NULL, 0); if ( pg == NULL ) goto error; - mfn[i] = _mfn(page_to_mfn(pg)); + mfn[i] = page_to_mfn(pg); } va = __vmap(mfn, 1, pages, 1, PAGE_HYPERVISOR, type); @@ -270,7 +271,7 @@ static void *vmalloc_type(size_t size, enum vmap_region type) error: while ( i-- ) - free_domheap_page(mfn_to_page(mfn_x(mfn[i]))); + free_domheap_page(mfn_to_page(mfn[i])); xfree(mfn); return NULL; } diff --git a/xen/common/xenoprof.c b/xen/common/xenoprof.c index 5acdde5691..fecdfb3697 100644 --- a/xen/common/xenoprof.c +++ b/xen/common/xenoprof.c @@ -22,8 +22,6 @@ /* 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)) -#undef mfn_to_page -#define mfn_to_page(mfn) __mfn_to_page(mfn_x(mfn)) /* Limit amount of pages used for shared buffer (per domain) */ #define MAX_OPROF_SHARED_PAGES 32 diff --git a/xen/drivers/passthrough/amd/iommu_map.c b/xen/drivers/passthrough/amd/iommu_map.c index fd2327d3e5..bd62c2ce90 100644 --- a/xen/drivers/passthrough/amd/iommu_map.c +++ b/xen/drivers/passthrough/amd/iommu_map.c @@ -25,6 +25,12 @@ #include "../ats.h" #include +/* Override macros from asm/page.h to avoid using typesafe mfn_t. */ +#undef page_to_mfn +#define page_to_mfn(pg) mfn_x(__page_to_mfn(pg)) +#undef mfn_to_page +#define mfn_to_page(mfn) __mfn_to_page(_mfn(mfn)) + /* Given pfn and page table level, return pde index */ static unsigned int pfn_to_pde_idx(unsigned long pfn, unsigned int level) { diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c index 1aecf7cf34..2c44fabf99 100644 --- a/xen/drivers/passthrough/iommu.c +++ b/xen/drivers/passthrough/iommu.c @@ -184,7 +184,7 @@ void __hwdom_init iommu_hwdom_init(struct domain *d) page_list_for_each ( page, &d->page_list ) { - unsigned long mfn = page_to_mfn(page); + unsigned long mfn = mfn_x(page_to_mfn(page)); unsigned long gfn = mfn_to_gmfn(d, mfn); unsigned int mapping = IOMMUF_readable; int ret; diff --git a/xen/drivers/passthrough/x86/iommu.c b/xen/drivers/passthrough/x86/iommu.c index 0253823173..68182afd91 100644 --- a/xen/drivers/passthrough/x86/iommu.c +++ b/xen/drivers/passthrough/x86/iommu.c @@ -58,7 +58,7 @@ int arch_iommu_populate_page_table(struct domain *d) if ( is_hvm_domain(d) || (page->u.inuse.type_info & PGT_type_mask) == PGT_writable_page ) { - unsigned long mfn = page_to_mfn(page); + unsigned long mfn = mfn_x(page_to_mfn(page)); unsigned long gfn = mfn_to_gmfn(d, mfn); if ( gfn != gfn_x(INVALID_GFN) ) diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h index 737a429409..3eb4b68761 100644 --- a/xen/include/asm-arm/mm.h +++ b/xen/include/asm-arm/mm.h @@ -138,7 +138,7 @@ extern vaddr_t xenheap_virt_start; #endif #ifdef CONFIG_ARM_32 -#define is_xen_heap_page(page) is_xen_heap_mfn(page_to_mfn(page)) +#define is_xen_heap_page(page) is_xen_heap_mfn(mfn_x(__page_to_mfn(page))) #define is_xen_heap_mfn(mfn) ({ \ unsigned long mfn_ = (mfn); \ (mfn_ >= mfn_x(xenheap_mfn_start) && \ @@ -220,12 +220,14 @@ 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 __mfn_to_page(mfn) \ + (frame_table + (pfn_to_pdx(mfn_x(mfn)) - frametable_base_pdx)) +#define __page_to_mfn(pg) \ + _mfn(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) -#define page_to_maddr(pg) ((paddr_t)__page_to_mfn(pg) << PAGE_SHIFT) +#define maddr_to_page(ma) __mfn_to_page(maddr_to_mfn(ma)) +#define page_to_maddr(pg) (mfn_to_maddr(__page_to_mfn(pg))) /* Convert between frame number and address formats. */ #define pfn_to_paddr(pfn) ((paddr_t)(pfn) << PAGE_SHIFT) @@ -235,7 +237,7 @@ static inline void __iomem *ioremap_wc(paddr_t start, size_t len) #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_mfn(va) maddr_to_mfn(virt_to_maddr((vaddr_t)va)) #define vmap_to_page(va) mfn_to_page(vmap_to_mfn(va)) /* Page-align address and convert to frame number format */ @@ -309,7 +311,7 @@ static inline struct page_info *virt_to_page(const void *v) static inline void *page_to_virt(const struct page_info *pg) { - return mfn_to_virt(page_to_mfn(pg)); + return mfn_to_virt(mfn_x(__page_to_mfn(pg))); } struct page_info *get_page_from_gva(struct vcpu *v, vaddr_t va, diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h index faadcfe8fe..87c9994974 100644 --- a/xen/include/asm-arm/p2m.h +++ b/xen/include/asm-arm/p2m.h @@ -276,7 +276,7 @@ static inline struct page_info *get_page_from_gfn( { struct page_info *page; p2m_type_t p2mt; - unsigned long mfn = mfn_x(p2m_lookup(d, _gfn(gfn), &p2mt)); + mfn_t mfn = p2m_lookup(d, _gfn(gfn), &p2mt); if (t) *t = p2mt; @@ -284,7 +284,7 @@ static inline struct page_info *get_page_from_gfn( if ( !p2m_is_any_ram(p2mt) ) return NULL; - if ( !mfn_valid(_mfn(mfn)) ) + if ( !mfn_valid(mfn) ) return NULL; page = mfn_to_page(mfn); diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h index 83626085e0..c8dd273517 100644 --- a/xen/include/asm-x86/mm.h +++ b/xen/include/asm-x86/mm.h @@ -270,7 +270,7 @@ struct page_info #define is_xen_heap_page(page) ((page)->count_info & PGC_xen_heap) #define is_xen_heap_mfn(mfn) \ - (__mfn_valid(mfn) && is_xen_heap_page(__mfn_to_page(mfn))) + (__mfn_valid(mfn) && is_xen_heap_page(__mfn_to_page(_mfn(mfn)))) #define is_xen_fixed_mfn(mfn) \ ((((mfn) << PAGE_SHIFT) >= __pa(&_stext)) && \ (((mfn) << PAGE_SHIFT) <= __pa(&__2M_rwdata_end))) @@ -383,7 +383,7 @@ void put_page_from_l1e(l1_pgentry_t l1e, struct domain *l1e_owner); static inline bool get_page_from_mfn(mfn_t mfn, struct domain *d) { - struct page_info *page = __mfn_to_page(mfn_x(mfn)); + struct page_info *page = __mfn_to_page(mfn); if ( unlikely(!mfn_valid(mfn)) || unlikely(!get_page(page, d)) ) { @@ -477,10 +477,10 @@ extern paddr_t mem_hotplug; #define SHARED_M2P(_e) ((_e) == SHARED_M2P_ENTRY) #define compat_machine_to_phys_mapping ((unsigned int *)RDWR_COMPAT_MPT_VIRT_START) -#define _set_gpfn_from_mfn(mfn, pfn) ({ \ - struct domain *d = page_get_owner(__mfn_to_page(mfn)); \ - unsigned long entry = (d && (d == dom_cow)) ? \ - SHARED_M2P_ENTRY : (pfn); \ +#define _set_gpfn_from_mfn(mfn, pfn) ({ \ + struct domain *d = page_get_owner(__mfn_to_page(_mfn(mfn))); \ + unsigned long entry = (d && (d == dom_cow)) ? \ + SHARED_M2P_ENTRY : (pfn); \ ((void)((mfn) >= (RDWR_COMPAT_MPT_VIRT_END - RDWR_COMPAT_MPT_VIRT_START) / 4 || \ (compat_machine_to_phys_mapping[(mfn)] = (unsigned int)(entry))), \ machine_to_phys_mapping[(mfn)] = (entry)); \ diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h index 17b1d0c8d3..a2a216061f 100644 --- a/xen/include/asm-x86/p2m.h +++ b/xen/include/asm-x86/p2m.h @@ -487,7 +487,7 @@ static inline struct page_info *get_page_from_gfn( /* Non-translated guests see 1-1 RAM / MMIO mappings everywhere */ if ( t ) *t = likely(d != dom_io) ? p2m_ram_rw : p2m_mmio_direct; - page = __mfn_to_page(gfn); + page = __mfn_to_page(_mfn(gfn)); return mfn_valid(_mfn(gfn)) && get_page(page, d) ? page : NULL; } diff --git a/xen/include/asm-x86/page.h b/xen/include/asm-x86/page.h index 45ca742678..8737ef16ff 100644 --- a/xen/include/asm-x86/page.h +++ b/xen/include/asm-x86/page.h @@ -88,10 +88,10 @@ ((paddr_t)(((x).l4 & (PADDR_MASK&PAGE_MASK)))) /* Get pointer to info structure of page mapped by pte (struct page_info *). */ -#define l1e_get_page(x) (__mfn_to_page(l1e_get_pfn(x))) -#define l2e_get_page(x) (__mfn_to_page(l2e_get_pfn(x))) -#define l3e_get_page(x) (__mfn_to_page(l3e_get_pfn(x))) -#define l4e_get_page(x) (__mfn_to_page(l4e_get_pfn(x))) +#define l1e_get_page(x) (__mfn_to_page(l1e_get_mfn(x))) +#define l2e_get_page(x) (__mfn_to_page(l2e_get_mfn(x))) +#define l3e_get_page(x) (__mfn_to_page(l3e_get_mfn(x))) +#define l4e_get_page(x) (__mfn_to_page(l4e_get_mfn(x))) /* Get pte access flags (unsigned int). */ #define l1e_get_flags(x) (get_pte_flags((x).l1)) @@ -157,10 +157,10 @@ static inline l4_pgentry_t l4e_from_paddr(paddr_t pa, unsigned int flags) #define l4e_from_intpte(intpte) ((l4_pgentry_t) { (intpte_t)(intpte) }) /* Construct a pte from a page pointer and access flags. */ -#define l1e_from_page(page, flags) l1e_from_pfn(__page_to_mfn(page), (flags)) -#define l2e_from_page(page, flags) l2e_from_pfn(__page_to_mfn(page), (flags)) -#define l3e_from_page(page, flags) l3e_from_pfn(__page_to_mfn(page), (flags)) -#define l4e_from_page(page, flags) l4e_from_pfn(__page_to_mfn(page), (flags)) +#define l1e_from_page(page, flags) l1e_from_mfn(__page_to_mfn(page), (flags)) +#define l2e_from_page(page, flags) l2e_from_mfn(__page_to_mfn(page), (flags)) +#define l3e_from_page(page, flags) l3e_from_mfn(__page_to_mfn(page), (flags)) +#define l4e_from_page(page, flags) l4e_from_mfn(__page_to_mfn(page), (flags)) /* Add extra flags to an existing pte. */ #define l1e_add_flags(x, flags) ((x).l1 |= put_pte_flags(flags)) @@ -215,13 +215,13 @@ static inline l4_pgentry_t l4e_from_paddr(paddr_t pa, unsigned int flags) /* Page-table type. */ typedef struct { u64 pfn; } pagetable_t; #define pagetable_get_paddr(x) ((paddr_t)(x).pfn << PAGE_SHIFT) -#define pagetable_get_page(x) __mfn_to_page((x).pfn) +#define pagetable_get_page(x) __mfn_to_page(pagetable_get_mfn(x)) #define pagetable_get_pfn(x) ((x).pfn) #define pagetable_get_mfn(x) _mfn(((x).pfn)) #define pagetable_is_null(x) ((x).pfn == 0) #define pagetable_from_pfn(pfn) ((pagetable_t) { (pfn) }) #define pagetable_from_mfn(mfn) ((pagetable_t) { mfn_x(mfn) }) -#define pagetable_from_page(pg) pagetable_from_pfn(__page_to_mfn(pg)) +#define pagetable_from_page(pg) pagetable_from_mfn(__page_to_mfn(pg)) #define pagetable_from_paddr(p) pagetable_from_pfn((p)>>PAGE_SHIFT) #define pagetable_null() pagetable_from_pfn(0) @@ -240,12 +240,12 @@ void copy_page_sse2(void *, const void *); #define __mfn_to_virt(mfn) (maddr_to_virt((paddr_t)(mfn) << PAGE_SHIFT)) /* Convert between machine frame numbers and page-info structures. */ -#define __mfn_to_page(mfn) (frame_table + pfn_to_pdx(mfn)) -#define __page_to_mfn(pg) pdx_to_pfn((unsigned long)((pg) - frame_table)) +#define __mfn_to_page(mfn) (frame_table + pfn_to_pdx(mfn_x(mfn))) +#define __page_to_mfn(pg) _mfn(pdx_to_pfn((unsigned long)((pg) - frame_table))) /* Convert between machine addresses and page-info structures. */ -#define __maddr_to_page(ma) __mfn_to_page((ma) >> PAGE_SHIFT) -#define __page_to_maddr(pg) ((paddr_t)__page_to_mfn(pg) << PAGE_SHIFT) +#define __maddr_to_page(ma) __mfn_to_page(maddr_to_mfn(ma)) +#define __page_to_maddr(pg) (mfn_to_maddr(__page_to_mfn(pg))) /* Convert between frame number and address formats. */ #define __pfn_to_paddr(pfn) ((paddr_t)(pfn) << PAGE_SHIFT) @@ -273,8 +273,8 @@ void copy_page_sse2(void *, const void *); #define pfn_to_paddr(pfn) __pfn_to_paddr(pfn) #define paddr_to_pfn(pa) __paddr_to_pfn(pa) #define paddr_to_pdx(pa) pfn_to_pdx(paddr_to_pfn(pa)) -#define vmap_to_mfn(va) l1e_get_pfn(*virt_to_xen_l1e((unsigned long)(va))) -#define vmap_to_page(va) mfn_to_page(vmap_to_mfn(va)) +#define vmap_to_mfn(va) _mfn(l1e_get_pfn(*virt_to_xen_l1e((unsigned long)(va)))) +#define vmap_to_page(va) __mfn_to_page(vmap_to_mfn(va)) #endif /* !defined(__ASSEMBLY__) */ diff --git a/xen/include/xen/domain_page.h b/xen/include/xen/domain_page.h index 890bae5b9c..22ab65ba16 100644 --- a/xen/include/xen/domain_page.h +++ b/xen/include/xen/domain_page.h @@ -34,7 +34,7 @@ void unmap_domain_page(const void *va); /* * Given a VA from map_domain_page(), return its underlying MFN. */ -unsigned long domain_page_map_to_mfn(const void *va); +mfn_t domain_page_map_to_mfn(const void *va); /* * Similar to the above calls, except the mapping is accessible in all @@ -44,11 +44,11 @@ unsigned long domain_page_map_to_mfn(const void *va); void *map_domain_page_global(mfn_t mfn); void unmap_domain_page_global(const void *va); -#define __map_domain_page(pg) map_domain_page(_mfn(__page_to_mfn(pg))) +#define __map_domain_page(pg) map_domain_page(__page_to_mfn(pg)) static inline void *__map_domain_page_global(const struct page_info *pg) { - return map_domain_page_global(_mfn(__page_to_mfn(pg))); + return map_domain_page_global(page_to_mfn(pg)); } #else /* !CONFIG_DOMAIN_PAGE */ @@ -56,7 +56,7 @@ static inline void *__map_domain_page_global(const struct page_info *pg) #define map_domain_page(mfn) __mfn_to_virt(mfn_x(mfn)) #define __map_domain_page(pg) page_to_virt(pg) #define unmap_domain_page(va) ((void)(va)) -#define domain_page_map_to_mfn(va) virt_to_mfn((unsigned long)(va)) +#define domain_page_map_to_mfn(va) _mfn(virt_to_mfn((unsigned long)(va))) static inline void *map_domain_page_global(mfn_t mfn) { diff --git a/xen/include/xen/tmem_xen.h b/xen/include/xen/tmem_xen.h index 542c0b3f20..8516a0b131 100644 --- a/xen/include/xen/tmem_xen.h +++ b/xen/include/xen/tmem_xen.h @@ -25,7 +25,7 @@ typedef uint32_t pagesize_t; /* like size_t, must handle largest PAGE_SIZE */ #define IS_PAGE_ALIGNED(addr) IS_ALIGNED((unsigned long)(addr), PAGE_SIZE) -#define IS_VALID_PAGE(_pi) mfn_valid(_mfn(page_to_mfn(_pi))) +#define IS_VALID_PAGE(_pi) mfn_valid(page_to_mfn(_pi)) extern struct page_list_head tmem_page_list; extern spinlock_t tmem_page_list_lock;