From patchwork Thu Oct 5 17:42: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: 114956 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp848285qgn; Thu, 5 Oct 2017 10:44:42 -0700 (PDT) X-Received: by 10.36.172.74 with SMTP id m10mr33620954iti.150.1507225481943; Thu, 05 Oct 2017 10:44:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507225481; cv=none; d=google.com; s=arc-20160816; b=JqkuzXbMFjmbGFXnHN/lHefmdFnvvyaz677illxqdLtXCg060rn6wFFiZJd0y2IXB+ 9IOtO/uxcDrf3pwjdciE92MZN9B6q9+WsTcYFVCZcza832T+AW8TxUIp/JRlLvAbNkmy Wjr0oVZ89BNsL9IaWOEdziJDxIqgrE28SHdGzD05bxxS6srOV99wBFTBpNK2rm37aq4O FM+35jaQzVt+OUDS34Pbq99jkq1dY71CUuVIWp5k2B+VYi66Z7xmCFmeqi9CSbx3VH1/ UywNUvSF4Ad7CDxfwtudcrw36jaNw8C9jBsAAix1gl86Lx371CbGgdT+ZM26IsjLyRth 1GqQ== 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=jh+vouMko+x/OxmrtZMsTQ3JYxvsRqflHfua12sgefM=; b=GJO9Xq0MMx6Ne23NWWxXa7XhQhfF3NtCKiCbjnyxhXGGPlui0Y6UGSQvgyqWINvgno a6+GHkTlirCy6saMNGzYwj6uexygRHubb4y96cuQLG+hhuKipUUHHEAclpBGulbeF0Ap mrblFIWSTXBBx6e41MYFJUOqohhVKrHfsIKmkm5Pmg9lt84UflAGoaYvt6kgLs717DfJ GipHnQEsUGwpI70GCXssNDlGDQzNsp0kCn8tysNYK2BqWzJQSQziPjl966XkVCYCRI4f FxWR67dVT0KVwXeBv8hvRBiYaJXw6QS/H1MsKAsiZtj41xmS8w2+Z1GCk2+/e6IzvVTs Zl9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=IwPRQH4n; 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 62si14749207iox.281.2017.10.05.10.44.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Oct 2017 10:44: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; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=IwPRQH4n; 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 1e0AAL-0000xU-To; Thu, 05 Oct 2017 17:42:33 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e0AAK-0000xI-SI for xen-devel@lists.xen.org; Thu, 05 Oct 2017 17:42:33 +0000 Received: from [85.158.137.68] by server-14.bemta-3.messagelabs.com id DF/36-01909-80F66D95; Thu, 05 Oct 2017 17:42:32 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrGIsWRWlGSWpSXmKPExsVyMfTOVl32/Gu RBl2TlCyWfFzM4sDocXT3b6YAxijWzLyk/IoE1oxbO3pYCjqFK97ffMzWwDiDr4uRi0NIYDKj xIHJu5lAHBaBecwS57/uYARxJAT6WSUeHd7K1sXICeTkSfx5cosdwk6TuPT4PBOEXSkx7UsTa xcjB9AoNYk1b6IgpvYxSXzdeIQJJM4moCOxbkYtSLmIgLTEtc+XGUFsZoEIifMfDoKNFxZwk3 g9eyMziM0ioCox5Wg/I0grr4CNxKzLiRCb5CV2tV1kBbE5BWwl1vfcAbtGCKhk+YqzzBMYBRc wMqxi1ChOLSpLLdI1MtVLKspMzyjJTczM0TU0MNbLTS0uTkxPzUlMKtZLzs/dxAgMt3oGBsYd jK0n/A4xSnIwKYnyemVdixTiS8pPqcxILM6ILyrNSS0+xCjDwaEkwcufB5QTLEpNT61Iy8wBB j5MWoKDR0mE92kuUJq3uCAxtzgzHSJ1itGS48KdS3+YOA7suQUkO27e/cMkxJKXn5cqJc5rDD JPAKQhozQPbhwsOi8xykoJ8zIyMDAI8RSkFuVmlqDKv2IU52BUEub9A7KWJzOvBG7rK6CDmIA OmtN0BeSgkkSElFQDo1CLT5lWm9Lr6Z/u2X8uZXS5O03r2uln4f22cjx5bneMizf4Xf4x+ciL DP0FTRz7rNT0m98GKjKW3V3fbD47r1Zk6oa3fAKtcUvqnFOVD8gofnz953bD58U+J1NmaS9IP hyZcHIvx8KlDb+M22fHWjzbnXa4K1r6x5RtTzZ3+2dk3qidZhz3RImlOCPRUIu5qDgRAAOjca DJAgAA X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-8.tower-31.messagelabs.com!1507225350!118196111!1 X-Originating-IP: [209.85.220.181] 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 1251 invoked from network); 5 Oct 2017 17:42:31 -0000 Received: from mail-qk0-f181.google.com (HELO mail-qk0-f181.google.com) (209.85.220.181) by server-8.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 5 Oct 2017 17:42:31 -0000 Received: by mail-qk0-f181.google.com with SMTP id w63so15514138qkd.10 for ; Thu, 05 Oct 2017 10:42:31 -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=Tniu595kLO7uKPICEjK9faE8Zn+YBoOmSLupwI0Q000=; b=IwPRQH4nJKjandrchq6Ezla87sEyMaFZSD/WiCwTezFkKocc0E165euAkP2giwA068 O0+QYKTbtUDz+BTyYgLcESbrbPLunJ1Ly3lsfKuHSzfxwGeJ9UCjVBtiSAEl4QHj19eT 0Phl4y9sv2nFtvY77qcUyNOtG1HG/ODmwuZEo= 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=Tniu595kLO7uKPICEjK9faE8Zn+YBoOmSLupwI0Q000=; b=FmI+SXg3G64GIETWoeL9rXgMdt9ZUY5D3MmoxIDT09Y2F+KLZdHcMkGTM/QF73bw5b 4Qj+30oNZtihSLXBRPY/FRGg+1mBN6VISErDb+jRQY2z7Vk8PK07MXl1Z9MJFlUo3zvO WdftSMrQBdbG424v2u0C7Od+G83rAjeHgUQmUdeyc5BAQ/3TQ9APwti+zMH1rG+OG558 4EHtIRMF48MhtYTsuZF92GCtI89Amg4pkV89fEUdOgiMhWMOa7bG+t7/TK1htOd/kWQS icV0TMB+83YVthz0k399uJfb+OvL+BfYpEn5qJeeK5MHILksVHluYTqnonkSdG9OpssO 8oCQ== X-Gm-Message-State: AMCzsaVAOB4HAdQkWbm7YzAGhXA2ewKWtNnLMd28mHo03TfMsnLBZ9za StGRggnqAzUkuZQT0Y3Az1fMN7fOX98= X-Google-Smtp-Source: AOwi7QDKG1mF+m1PI1oMKQ4oKxmQOCIEECi4Tw6YXaCWHITZG8LS2SIHL6cpoRu1vf0rpmP0xpPY8g== X-Received: by 10.55.16.87 with SMTP id a84mr33029416qkh.170.1507225350381; Thu, 05 Oct 2017 10:42:30 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id y63sm11815084qky.75.2017.10.05.10.42.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Oct 2017 10:42:29 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 5 Oct 2017 18:42:14 +0100 Message-Id: <20171005174222.29161-2-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171005174222.29161-1-julien.grall@linaro.org> References: <20171005174222.29161-1-julien.grall@linaro.org> Cc: Julien Grall , Stefano Stabellini Subject: [Xen-devel] [PATCH v2 1/9] 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 --- 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 3723dc3f78..167711b4fa 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 Thu Oct 5 17:42: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: 114958 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp848293qgn; Thu, 5 Oct 2017 10:44:42 -0700 (PDT) X-Received: by 10.107.135.147 with SMTP id r19mr39958779ioi.26.1507225482379; Thu, 05 Oct 2017 10:44:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507225482; cv=none; d=google.com; s=arc-20160816; b=kUdQy1AYUBYypPjwY0HuKxQtOJMXmfiq0figpFkxVWobq9nmMtbPOkqrsSANBjC8Y4 7gbCW0e1QPld1f0nE+Zab7uEnuiti2PgqpZtbHqMVGiNAYVzYmZbk6LJczyCwxJNStU2 9jMl3hKoGEXwSG41izxESplh5q8qJfEw1lM1ksmKAWc4cULpjPP5gjIjnFBvb0XGaLed T5qwRdlFIICh2HVq72w2+rI19zwYoMjSRnG9a0RMLYmdLoYnTJEUzKV58EZYOCL9msxQ MtELOj33R3t7VGpF5bwi8G/yzVnkc/NeeTRVodS8VV+ZmpzI4ULy0S+jnXorxakIER+o QZJQ== 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=XHPlRvEYkjWZvuur66BnMpTjUaEKPHe54K3/PYmW4mQ=; b=xu44R+ZRMXQHPOhi0hdlVK8NbstVnlRN6ooaGNZbTek6mZcvV91D4oVukZ2R6lsoYG gvuuAqitkG6lBaKCkgQFF5ZNbAHvXGXpA84wkmZF0924ZsubIf1sNF0T6llIZt0TNLuA Ha92TPMtIlxIcg1e7y9hLINY0zNv5p6xOtvYMaymnJA0PEiXOLFHhY0sEjUmGNVwaGCM JurfyMArSatMiLqiiTf9AT01VWb6Q5t4TSrjvcwnlUir6goS+SJuWTbH1YoKSxkjOT4z QlhkbE9/GVTkEeFso5q/rcSmYCUVGnsDcQiggdOr0sR/CH1dOhdqVEL5NDT384uewjws qx1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=cFYStM7Z; 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 o186si14830085iof.310.2017.10.05.10.44.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Oct 2017 10:44: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=cFYStM7Z; 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 1e0AAO-0000yf-OB; Thu, 05 Oct 2017 17:42: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 1e0AAN-0000y6-Nu for xen-devel@lists.xen.org; Thu, 05 Oct 2017 17:42:35 +0000 Received: from [193.109.254.147] by server-6.bemta-6.messagelabs.com id DF/F8-03409-B0F66D95; Thu, 05 Oct 2017 17:42:35 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrLIsWRWlGSWpSXmKPExsVyMfTONl2O/Gu RBn2HNC2WfFzM4sDocXT3b6YAxijWzLyk/IoE1ozzDTOZC3ZyVbT9mcHYwHiMvYuRi0NIYCKj xIzu+awgDovAPGaJlTvWsIE4EgL9rBLbGvYwdzFyAjl5Et+2HWWDsNMk5nf3s0DYVRKt+zuAa jiARqlJrHkTBTG1j0niwfT/bCBxNgEdiXUzakHKRQSkJa59vswIYjMLREic/3AQbKSwQKDEx9 kvwGwWAVWJGb9ng43nFbCRWL92F9QJ8hK72i6ygticArYS63vusIPYQkA1y1ecZZ7AKLiAkWE Vo0ZxalFZapGuoYleUlFmekZJbmJmjq6hgZlebmpxcWJ6ak5iUrFecn7uJkZgwDEAwQ7G6xsD DjFKcjApifJ6ZV2LFOJLyk+pzEgszogvKs1JLT7EKMPBoSTBy58HlBMsSk1PrUjLzAGGPkxag oNHSYRXHiTNW1yQmFucmQ6ROsVoz3HhzqU/TBzHNl0Gkgf23AKSHTfv/mESYsnLz0uVEufdkw vUJgDSllGaBzcUFquXGGWlhHkZgc4U4ilILcrNLEGVf8UozsGoJMx7EGQKT2ZeCdzuV0BnMQG dNafpCshZJYkIKakGRj8t4yemImpnmEunrXzArKgz7Wgr+4yeH1mzvigx+QtdMXc/wB4boCw2 gd020VMwaeE/xvcXtyiEmS7jL64QnaN4oG/unxMfJi1zvcH7vEqOb+bqay/eLjWc+/ev4iv+I 1WJauHXX8zITI3a/suvs+HNn4d7u79fYiiZ87++8WzMcrkwnwcTjiqxFGckGmoxFxUnAgCPuh pu0AIAAA== X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-16.tower-27.messagelabs.com!1507225351!109980040!1 X-Originating-IP: [209.85.220.182] 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 16505 invoked from network); 5 Oct 2017 17:42:32 -0000 Received: from mail-qk0-f182.google.com (HELO mail-qk0-f182.google.com) (209.85.220.182) by server-16.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 5 Oct 2017 17:42:32 -0000 Received: by mail-qk0-f182.google.com with SMTP id 17so15471421qkq.8 for ; Thu, 05 Oct 2017 10:42:32 -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=+k2UxqB0X1AeCLQscuVEzKPYeWpws8w3xDjv/fTOxJ0=; b=cFYStM7ZFqctzavmRfNEbKhBppBeht4MpkV7ZvYB2ot1JS33l20dNtnfbkTPvqbX17 P5gUYeDTrQErdL0fIrsS350tYx0cYMPiGLcWHL+i3WAV2dFtD26PNYWYNgjuM8BYy1Xq 0XicJ5S3ObpHayXP+6G9Dm4dRk+QxPpEs+e+8= 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=+k2UxqB0X1AeCLQscuVEzKPYeWpws8w3xDjv/fTOxJ0=; b=tvchIoGzT5J226WMRiuap3+Nei+U3eDj5XaraWSqmW8KGKvfJDP/pa4OkeS99Nmy4d JfE1wGZc71p6UsLJNEcVcN6H2eDGbK2ajC1ZZjErTrRVpGr8BOvZ/JJA+FEO/6m7RnSu /YvTmf0g5Za9Ai1FgcXxKefTpEWKbdusrK8M/gCusl21a6ZBnJPeRGpFCsYEepj+4aYd D4y6c32S1e139VHhO7pZfuNeu6FChTNn6o0QQf1ghIJBHtm+ghZfnU4XAkW8rR/tORjU Ul3qTV64AjD27frU2HZETwgi5Vpye71R8ajQmpvjEqdai208xtw+Lesqoo7Z05kAsiFj cVuA== X-Gm-Message-State: AMCzsaXjIVCTF+chDXYhaYhvFW09RFpnG2ZERNWr4HnFMq+HsnNJSpaE ITp9C6doZbYyTgURvLWdpbIAY3/03A0= X-Google-Smtp-Source: AOwi7QBpJzK/2T5jU8ICq/YmTV+Vg/TgggWftVL4m3AtY7vaAb9QWlgK92MO9LKTndNA20dFvMvwsg== X-Received: by 10.55.23.101 with SMTP id i98mr29143759qkh.193.1507225351465; Thu, 05 Oct 2017 10:42:31 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id y63sm11815084qky.75.2017.10.05.10.42.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Oct 2017 10:42:31 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 5 Oct 2017 18:42:15 +0100 Message-Id: <20171005174222.29161-3-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171005174222.29161-1-julien.grall@linaro.org> References: <20171005174222.29161-1-julien.grall@linaro.org> Cc: Julien Grall , Stefano Stabellini Subject: [Xen-devel] [PATCH v2 2/9] 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 folow-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 --- Cc: Stefano Stabellini --- 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 Thu Oct 5 17:42: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: 114957 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp848289qgn; Thu, 5 Oct 2017 10:44:42 -0700 (PDT) X-Received: by 10.107.200.198 with SMTP id y189mr1100701iof.157.1507225482256; Thu, 05 Oct 2017 10:44:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507225482; cv=none; d=google.com; s=arc-20160816; b=yFbPllL9WC32LGtXlkk1hGPlQsmv/0gOSH8yA1MxYeT/FzwH6qUffn2xaN8+VYZt5F 0/4kl2Qxex8tYhY46j44PbqaNUVNwpVSV0aR6cCdxsB2GLgi4/wTpd2bBwV0nHy6B8ZU yNrH0uWTbZF3QyTnRVRfRXCCiS9YL+BqxjN8tpHh2QLpU55OMnJmJ1X0yr+JLM4/LgTU /GHu4awScziBwGtasmUAYI4Gq5znxN3lD2oJykpzlWGKzZB9K66a8xPKmgXkTgukwV1e TNPVdnnrZuyz3reUrrWMT/j9G4JY4XIPwxdLJ8cYrNcPpWxtsCQfl4urWBEZmhKKYqvE 6YXA== 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=KKV7XEDAhhHRco2kpMr5Dr9WGZG1jj4xQ/CaI/WAuKM=; b=pfMN2NL8DmdF2gbb2xVaWpqf2pC1t9oknqGWEbkqipeVM40exHhapQ5aRlepuzkVzJ F/bUX8S7O/wI9rbv6ni9YyUQkRb6L+FmCT29m1i4jApJ+IQsF63xJhJeKr190jjZe116 C2meo74eMttaL8im5u3X6fUTgr2TBpEBlg40BCDhqrqgGzA1yJbTqqBU+Lt1H0YqNUFH MTaBotYvVEN2F+joL8r6tv5T+fTayiWvOAU/X1IpvAryvoSmkXkHrPHd0ym8IFAy2ahV IpXWqv95brBEo/XdCCqWwO6nZuEz8t98qzywcqlXIoj/Mbgaa2OfxwdnLyz5jKhHZCl1 1fsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=SumVyzOA; 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 e18si15153286ioe.39.2017.10.05.10.44.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Oct 2017 10:44: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=SumVyzOA; 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 1e0AAO-0000yT-Gx; Thu, 05 Oct 2017 17:42: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 1e0AAN-0000y6-Bp for xen-devel@lists.xen.org; Thu, 05 Oct 2017 17:42:35 +0000 Received: from [85.158.143.35] by server-6.bemta-6.messagelabs.com id 3B/F8-03409-A0F66D95; Thu, 05 Oct 2017 17:42:34 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOIsWRWlGSWpSXmKPExsVyMfTOBl3O/Gu RBq+vWVks+biYxYHR4+ju30wBjFGsmXlJ+RUJrBmbFy9jLZjCU7Ht4Ea2BsZpXF2MnBxCAhMZ JX68E+xi5OJgEZjHLPFq7XZ2EEdCoJ9VYvfRJSwgVRICeRLzd71khrDTJL6f2sgGYddIfFoxF 8jmAJqkJrHmTRRIr5BAH5PEtcdTGEHibAI6Eutm1IKUiwhIS1z7fJkRpIZZ4BzQ4u5esPnCAg kSuw/0gs1kEVCVeDy5lQnE5hWwkfi27gXULnmJXW0XWUFsTgFbifU9d9ghPrCRWL7iLPMERsE FjAyrGDWKU4vKUot0DS30kooy0zNKchMzc3QNDcz0clOLixPTU3MSk4r1kvNzNzECA44BCHYw 3twYcIhRkoNJSZTXK+tapBBfUn5KZUZicUZ8UWlOavEhRhkODiUJ3su5QDnBotT01Iq0zBxg6 MOkJTh4lER4n4KkeYsLEnOLM9MhUqcYLTku3Ln0h4njwJ5bQLLj5t0/TEIsefl5qVLivHtAGg RAGjJK8+DGweLzEqOslDAvI9CBQjwFqUW5mSWo8q8YxTkYlYR5D4JM4cnMK4Hb+groICagg+Y 0XQE5qCQRISXVwFhQfczvsOLVxjy5/qrLMpvL/QzKtzNuW/bo74s3Vss3pqXZ1MxSln7qI7ai e+q7lAc7A54Jv26Pun+/pcp/5pq6mVPvtP2dJFm12Cvk/mTB9HdaW+penCr4O++WedvbTof9N j9dlf5J/nyaIi1ypCSaxyGp9lK63i45Hr75ez5tF48PiD0a36vEUpyRaKjFXFScCABU6keiyg IAAA== X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-12.tower-21.messagelabs.com!1507225353!76540053!1 X-Originating-IP: [209.85.220.176] 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 30200 invoked from network); 5 Oct 2017 17:42:33 -0000 Received: from mail-qk0-f176.google.com (HELO mail-qk0-f176.google.com) (209.85.220.176) by server-12.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 5 Oct 2017 17:42:33 -0000 Received: by mail-qk0-f176.google.com with SMTP id 17so15471511qkq.8 for ; Thu, 05 Oct 2017 10:42:33 -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=8XPw/nu3bqb0DtxAxapOeASD38s/mBNX5UBXFAHb0S4=; b=SumVyzOAsAv0X0iIaPM3cl/mIBOS6D8FhEWn518Voa6JtEaLl/vWflYNYGvx123T9/ tRm9YcWKFgkgSYiEVwO398u6Hg/7iXT6UnjXWnZQftXAURxXptAJ1cMjg2N+mv/lnWnN PEtJOch1fzXV9HnkFDBQxiXaBf80YPvNIP+14= 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=8XPw/nu3bqb0DtxAxapOeASD38s/mBNX5UBXFAHb0S4=; b=lHssqzRKqJC13a+Pvj3v/A7i2qUp8dlgTksovIeMI+j7xNrhXNHqPG9Sqz8pmEZ8Hd 51xwEF3RhBYjdgYEK9ISKqVs6CBSWoil+5MX5FFEUsSYfKQGe0zBpun9PpNoU5Tvt0vg ppQlNbBHAViNeLsE8hB324fFJpcOPheEGnqJlBrVYV8zP6D8YygX+wJENQ8R7xhfwrFM hGZI2EFQAEJ5ea05VSJ2ElRS1j4/QXKJsbzYql9jpnoT4nHg4b26nnpmYusLjnuZMoSt FNd1J9b0QVFQ++3RU+qKyikTYs1TtrFfQk+AKg68jPH+DqskWpd+8PiQQ5NpDj/NQvLt WIVw== X-Gm-Message-State: AMCzsaXbQueOcVYw3/BpSQERyTt3qqbOYjltoUdr/uZTkO/j9pxXvKgP X9vap/fQmAXDeYfLxgzidn50bTqGKWE= X-Google-Smtp-Source: AOwi7QAJuUWoAKFWVRxXs+WR7OxBcBwL2Cjj8UA8m+AonWU2n5ki+68Hy4LHg93EIgiQRt/b0FLYuA== X-Received: by 10.55.156.141 with SMTP id f135mr22093387qke.309.1507225352859; Thu, 05 Oct 2017 10:42:32 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id y63sm11815084qky.75.2017.10.05.10.42.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Oct 2017 10:42:32 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 5 Oct 2017 18:42:16 +0100 Message-Id: <20171005174222.29161-4-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171005174222.29161-1-julien.grall@linaro.org> References: <20171005174222.29161-1-julien.grall@linaro.org> Cc: George Dunlap , Andrew Cooper , Julien Grall , Tamas K Lengyel , Jan Beulich Subject: [Xen-devel] [PATCH v2 3/9] xen/x86: mem_sharing: Use copy_domain_page in __mem_sharing_unshare_page 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 function __mem_sharing_unshare_page contains an open-code version of copy_domain_page. Use the function to simplify a bit the code. At the same time replace _mfn(__page_to_mfn(...)) by page_to_mfn(...) given that the file given already provides a typesafe version of page_to_mfn. Signed-off-by: Julien Grall Reviewed-by: Andrew Cooper Acked-by: Tamas K Lengyel --- Cc: Tamas K Lengyel Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper Changes in v2: - New patch --- xen/arch/x86/mm/mem_sharing.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c index b856028c02..6f4be95515 100644 --- a/xen/arch/x86/mm/mem_sharing.c +++ b/xen/arch/x86/mm/mem_sharing.c @@ -1106,7 +1106,6 @@ int __mem_sharing_unshare_page(struct domain *d, p2m_type_t p2mt; mfn_t mfn; struct page_info *page, *old_page; - void *s, *t; int last_gfn; gfn_info_t *gfn_info = NULL; @@ -1185,11 +1184,7 @@ int __mem_sharing_unshare_page(struct domain *d, return -ENOMEM; } - s = map_domain_page(_mfn(__page_to_mfn(old_page))); - t = map_domain_page(_mfn(__page_to_mfn(page))); - memcpy(t, s, PAGE_SIZE); - unmap_domain_page(s); - unmap_domain_page(t); + copy_domain_page(page_to_mfn(page), page_to_mfn(old_page)); BUG_ON(set_shared_p2m_entry(d, gfn, page_to_mfn(page))); mem_sharing_gfn_destroy(old_page, d, gfn_info); From patchwork Thu Oct 5 17:42: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: 114954 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp848238qgn; Thu, 5 Oct 2017 10:44:38 -0700 (PDT) X-Received: by 10.107.131.155 with SMTP id n27mr37239237ioi.200.1507225478390; Thu, 05 Oct 2017 10:44:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507225478; cv=none; d=google.com; s=arc-20160816; b=oD3hbW3n2X7E2ZL6YpJzGY21SzOGGd5FFgGet5XSAqqydaSVDhfSQUFIdMpquAmkMc ncczx/COu40rRzkVtAf/xJy5NYP6j/46SOAS63FX6BENgu3EG0WipFMwrhMqs9fm6CFv 8Nt5DCWc/pWq0Mh+cgpYepuXNFJl5Gvv87i2vGz8towTHu03GS8926mZkHprHvxrmMAo 5s6Okcaw9J0hWIE3VpliHE6KUFKECHo7NjuWM56eY797lwnZqaTH9lr5JWpuNEgbZjw+ B62ADlLVc79hYvL+hPSbYy939Q/0F1uALhTyJkjLoSJI6ykjgVIUeWZoWXHNcEZAu+0O 0ilA== 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=jIDrm4B5iAAwrKJqwHGrn8hQeUsbHNrquATJvfdjzP0=; b=ciPoCfRBl1lTIU0jol232Loq3WSvy0wRDEx62AsEQRiPMfx3ZAHowywQXyxjLWZEXe ADKwFIl46JLJZEA0DP0UfnzGTvaQcoBqqXFTOs4LLFXUY4+3tGKPXPnGCdmsP0ziP+/G Kcj3K7tvyYZ72n8k1avCmRsWHWNttjreDU+NHyMLBtfZTrI9ZsAOfawZjhB8Fsdd11wq i1R6rp/Y97OkP8AmumSys2M+Kd9Btm1viOgxRx0dzsU7BfcFzW00M0caue4vH+5p/uYO pNeEvLWkHUhvb0N5oAGKrV3HoyTsvxbCEYB/zxlNKATmflrT4/bbh+ylAgRzulovashI IXRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=VO6lhbDS; 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 y202si15408240ioy.44.2017.10.05.10.44.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Oct 2017 10:44: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; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=VO6lhbDS; 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 1e0AAQ-0000z4-Vl; Thu, 05 Oct 2017 17:42:38 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e0AAP-0000ye-8z for xen-devel@lists.xen.org; Thu, 05 Oct 2017 17:42:37 +0000 Received: from [85.158.137.68] by server-11.bemta-3.messagelabs.com id 1F/FF-01777-C0F66D95; Thu, 05 Oct 2017 17:42:36 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrGIsWRWlGSWpSXmKPExsVyMfTOVl3u/Gu RBr3r1C2WfFzM4sDocXT3b6YAxijWzLyk/IoE1oxdx3eyFeyXrWjsOc7ewHhbvIuRi0NIYDKj xN91y9hBHBaBecwSz5c0gDkSAv2sEn+v/WTrYuQEcvIk3rX+YYaw0ySWPN4EFa+S2Pr9G2MXI wfQKDWJNW+iIKb2MUn8f7uWGSTOJqAjsW5GLUi5iIC0xLXPlxlBbGaBD4wST9+Ig9jCAqkSbz //YQKxWQRUJQ4vvQ42nlfARuLO1XcsEKvkJXa1XWQFsTkFbCXW99xhB7GFgGqWrzjLPIFRcAE jwypG9eLUorLUIl1DvaSizPSMktzEzBxdQwNjvdzU4uLE9NScxKRiveT83E2MwHBjAIIdjMs/ Oh1ilORgUhLl9cq6FinEl5SfUpmRWJwRX1Sak1p8iFGGg0NJgpc/DygnWJSanlqRlpkDDHyYt AQHj5IIrzxImre4IDG3ODMdInWK0ZLjwp1Lf5g4Duy5BSQ7bt79wyTEkpeflyolzrsnF6hBAK QhozQPbhwsOi8xykoJ8zICHSjEU5BalJtZgir/ilGcg1FJmPcPyBSezLwSuK2vgA5iAjpoTtM VkINKEhFSUg2M03+ceh3b91adVdI4ruNtCsN39XUdX299zNC9bq06TXrvc69TUbME7TWCFMqT Pexv67rP2sDwoe7pRAYn7Y/iz1c1vawuzmlbkCf6uzgnpufPpXMLrj6fGDLROdfCa93XjVdFr uckc1g2uzOva0o2OyBlZdi5O8Atk2O1R8zUU4v322b9uhyhxFKckWioxVxUnAgAtxsHSMkCAA A= X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-4.tower-31.messagelabs.com!1507225354!60020380!1 X-Originating-IP: [209.85.220.181] 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 38164 invoked from network); 5 Oct 2017 17:42:35 -0000 Received: from mail-qk0-f181.google.com (HELO mail-qk0-f181.google.com) (209.85.220.181) by server-4.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 5 Oct 2017 17:42:35 -0000 Received: by mail-qk0-f181.google.com with SMTP id w134so15534241qkb.0 for ; Thu, 05 Oct 2017 10:42:35 -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=XTzhc8+XdhAhVoZpUsKCIQHl8xTiHwlaHDjoVEOUOyE=; b=VO6lhbDSHmOb9PEzUabPjSgiiqbQKkxQojWEtkTd5mOhk8C48DxCKVWwekhVUJpJT0 6bxUjTlLCXRl8AiQXcySlZ+OkSP4WnUlapcaPVTvoyOxX1Y+hIHzSqMnyA046/gBqqUS bJo3swOjVq2ojY9IW4PXmNPQvkmGTpuMf2uis= 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=XTzhc8+XdhAhVoZpUsKCIQHl8xTiHwlaHDjoVEOUOyE=; b=eku8DSnVg5gnkaiJTF6ECljVaQ4vI7T+gtJOKI1ahW0SFM0yUSPXwaO1xbUutssirM D12bt5JpZyt88xkazL4+NhG6OMK1U+2lRptzB8D0fXC0P1iztzw5MgWiGQvDFk1l1ytF Jd75Szg+U/ObJTkUnYWpEL2L6aTljpFS9MQ1dD4Izf2uG/vjr4m9/hPfZbUr5tlNe0nP l2yrF2DPym/WC4vJKOUkdYIRXRMq+4zVG0pmjUwJ64gyA/827xFBJWO8zB59r5d8rVow wzogKFtGdmgj0j/RgBOwYRlSNROzVv11xDxnctV/qg/mYQ5XdtjcDW2KhQrhZZ4s2etr yExg== X-Gm-Message-State: AMCzsaWuypIGJKsw704E/282raywOmp2Y21iRj1tRi9daSRsassDKmyT g0YHVD5h0abMgOWHsHWnyDTBp5RhxeM= X-Google-Smtp-Source: AOwi7QA8aAbCusbZ0ooWm4W2jEgNrOsRYOhx+CY5xQg8CzD90ISctO9wCI6ha9xICRcTywliuuSGRg== X-Received: by 10.55.112.65 with SMTP id l62mr26875620qkc.357.1507225354425; Thu, 05 Oct 2017 10:42:34 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id y63sm11815084qky.75.2017.10.05.10.42.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Oct 2017 10:42:34 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 5 Oct 2017 18:42:17 +0100 Message-Id: <20171005174222.29161-5-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171005174222.29161-1-julien.grall@linaro.org> References: <20171005174222.29161-1-julien.grall@linaro.org> Cc: Elena Ufimtseva , George Dunlap , Andrew Cooper , Julien Grall , Tim Deegan , Jan Beulich Subject: [Xen-devel] [PATCH v2 4/9] xen/x86: Use maddr_to_page and maddr_to_mfn to avoid open-coded >> PAGE_SHIFT 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 constructions _mfn(... > PAGE_SHIFT) and mfn_to_page(... >> PAGE_SHIFT) could respectively be replaced by maddr_to_mfn(...) and maddr_to_page(...). Signed-off-by: Julien Grall Reviewed-by: Andrew Cooper --- Cc: Elena Ufimtseva Cc: Jan Beulich Cc: Andrew Cooper Cc: Tim Deegan Cc: George Dunlap Changes in v2: - Add Andrew's reviewed-by --- xen/arch/x86/debug.c | 2 +- xen/arch/x86/mm/shadow/common.c | 2 +- xen/arch/x86/mm/shadow/multi.c | 6 +++--- xen/common/kimage.c | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/debug.c b/xen/arch/x86/debug.c index 1c10b84a16..9159f32db4 100644 --- a/xen/arch/x86/debug.c +++ b/xen/arch/x86/debug.c @@ -98,7 +98,7 @@ dbg_pv_va2mfn(dbgva_t vaddr, struct domain *dp, uint64_t pgd3val) l2_pgentry_t l2e, *l2t; l1_pgentry_t l1e, *l1t; unsigned long cr3 = (pgd3val ? pgd3val : dp->vcpu[0]->arch.cr3); - mfn_t mfn = _mfn(cr3 >> PAGE_SHIFT); + mfn_t mfn = maddr_to_mfn(cr3); DBGP2("vaddr:%lx domid:%d cr3:%lx pgd3:%lx\n", vaddr, dp->domain_id, cr3, pgd3val); diff --git a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/common.c index 86186cccdf..f65d2a6523 100644 --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -2640,7 +2640,7 @@ static int sh_remove_shadow_via_pointer(struct domain *d, mfn_t smfn) ASSERT(sh_type_has_up_pointer(d, sp->u.sh.type)); if (sp->up == 0) return 0; - pmfn = _mfn(sp->up >> PAGE_SHIFT); + pmfn = maddr_to_mfn(sp->up); ASSERT(mfn_valid(pmfn)); vaddr = map_domain_page(pmfn); ASSERT(vaddr); diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c index 28030acbf6..1e42e1d8ab 100644 --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -2425,7 +2425,7 @@ int sh_safe_not_to_sync(struct vcpu *v, mfn_t gl1mfn) sp = mfn_to_page(smfn); if ( sp->u.sh.count != 1 || !sp->up ) return 0; - smfn = _mfn(sp->up >> PAGE_SHIFT); + smfn = maddr_to_mfn(sp->up); ASSERT(mfn_valid(smfn)); #if (SHADOW_PAGING_LEVELS == 4) @@ -2434,7 +2434,7 @@ int sh_safe_not_to_sync(struct vcpu *v, mfn_t gl1mfn) ASSERT(sh_type_has_up_pointer(d, SH_type_l2_shadow)); if ( sp->u.sh.count != 1 || !sp->up ) return 0; - smfn = _mfn(sp->up >> PAGE_SHIFT); + smfn = maddr_to_mfn(sp->up); ASSERT(mfn_valid(smfn)); /* up to l4 */ @@ -2442,7 +2442,7 @@ int sh_safe_not_to_sync(struct vcpu *v, mfn_t gl1mfn) if ( sp->u.sh.count != 1 || !sh_type_has_up_pointer(d, SH_type_l3_64_shadow) || !sp->up ) return 0; - smfn = _mfn(sp->up >> PAGE_SHIFT); + smfn = maddr_to_mfn(sp->up); ASSERT(mfn_valid(smfn)); #endif diff --git a/xen/common/kimage.c b/xen/common/kimage.c index cf624d10fd..ebc71affd1 100644 --- a/xen/common/kimage.c +++ b/xen/common/kimage.c @@ -504,7 +504,7 @@ static void kimage_free_entry(kimage_entry_t entry) { struct page_info *page; - page = mfn_to_page(entry >> PAGE_SHIFT); + page = maddr_to_page(entry); free_domheap_page(page); } @@ -636,8 +636,8 @@ static struct page_info *kimage_alloc_page(struct kexec_image *image, if ( old ) { /* If so move it. */ - mfn_t old_mfn = _mfn(*old >> PAGE_SHIFT); - mfn_t mfn = _mfn(addr >> PAGE_SHIFT); + mfn_t old_mfn = maddr_to_mfn(*old); + mfn_t mfn = maddr_to_mfn(addr); copy_domain_page(mfn, old_mfn); clear_domain_page(old_mfn); From patchwork Thu Oct 5 17:42: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: 114959 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp848322qgn; Thu, 5 Oct 2017 10:44:44 -0700 (PDT) X-Received: by 10.107.156.134 with SMTP id f128mr852025ioe.226.1507225483994; Thu, 05 Oct 2017 10:44:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507225483; cv=none; d=google.com; s=arc-20160816; b=MaFCBKEHBA+zmiP59I4dVZeC+F0rmyqNs/33MoT+IyxD94PXo+aUV3bYdy0MBt3U/R k69Us/0wyFHlEuZjtkF9sWH//mdAdcxQJG099HAL1Y9Q3h0fpi4lfYnUWnbpri/8KHul EuN4n7+K1ji52nTEEULNpSyANQxZDiBT/1pOeMGWvHC1q1f4EXjI+kN18FXhG+y8kTYK 1Pb1rWqANNXP6u0Gp9QOrZ/ZiBZifpFWKb+3+z3k5oUwvRCq8OvUr3XnTbWEHZrxQNX1 v+J4nPZ8ERjyf42wdrkIxBn3cD79vM8r2SRBmK0PQToXl2JjE0aq5iX/ceQLznS0WT8D XzmQ== 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=8Ermcb+dITnbdWldycVRFFdEVNZUv1JdnH5dszJ8zM0=; b=cdnA7N5x6T0ROZXkJ2BdH6upFCNcwiWKanaAZzjcXK8KOKigY3mAFcLXl4XP/pbK9F JsDo6Wn9UrDa7jHi/9Z0MLXL/BlA4/31uZRBXM4194V3N8j657ucpRe4QBU0NrmP22PS tvG3s7mf7Ch84DsfEJMPMOFDCLbuf7a8yk7YOZnUFeV0m67MD12O6NsnANMSisugFiST 0NVGcAs7ew0peo18lEDGNvG0xB7tc/5o3tPLcG/v+RQVMiDAD/whM2O6dp5wjx8TMFJ+ JvsGk64AnasWBQOMsjJ2R58bDvE37Ctkak2iqW11yeC0lcBKjHimk/tX04EFOuVYO0EN OuQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Fq3hGUeo; 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 x189si193035ite.199.2017.10.05.10.44.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Oct 2017 10:44:43 -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=Fq3hGUeo; 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 1e0AAS-00010q-AW; Thu, 05 Oct 2017 17:42:40 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e0AAQ-0000yw-67 for xen-devel@lists.xen.org; Thu, 05 Oct 2017 17:42:38 +0000 Received: from [85.158.143.35] by server-9.bemta-6.messagelabs.com id D1/69-03428-D0F66D95; Thu, 05 Oct 2017 17:42:37 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrMIsWRWlGSWpSXmKPExsVyMfTOGl2e/Gu RBo9/q1ss+biYxYHR4+ju30wBjFGsmXlJ+RUJrBmXPl9gK+jnqHi6eTlbA+Msti5GTg4hgYmM Eut+5nUxcnGwCMxjlrj+6TUjiCMh0M8qcXX1epYuRg4gJ09i7+5KCDNN4sEHc5BeCYEKidvvt jOBhIUE1CTWvIkC6RQS6GOSuPryCyNInE1AR2LdjFqQchEBaYlrny8zgtjMAmESBx+fYAaxhQ XcJaZtOMQCYrMIqEpM3/CdFcTmFbCROPlhJiPEKnmJXW0XweKcArYS63vusEOcbyOxfMVZ5gm MggsYGVYxqhenFpWlFula6iUVZaZnlOQmZuboGhqY6eWmFhcnpqfmJCYV6yXn525iBAYaAxDs YLy7KeAQoyQHk5Ior1fWtUghvqT8lMqMxOKM+KLSnNTiQ4wyHBxKErz8eUA5waLU9NSKtMwcY MjDpCU4eJREeOVB0rzFBYm5xZnpEKlTjJYcF+5c+sPEcWDPLSDZcfPuHyYhlrz8vFQpcd49uU ANAiANGaV5cONgcXmJUVZKmJcR6EAhnoLUotzMElT5V4ziHIxKwrxWIGt5MvNK4La+AjqICei gOU1XQA4qSURISTUwLmh+7vwxUdzVTGZV7vKNXHMm9u1o/K2w6dd/ozohQ9PnPHvOWBhw7dmW tZ7pfs7tQ7/D83qfsddzXre+a73s3rbvnLe338y/9+yz2gqPGMYM1j1nQ/dM2px+Ov9M7oI3w gus5iywkDBdJdTSeuC6cNisJ/M3Vl8SmJul0scVstuHszZp8RHxDUosxRmJhlrMRcWJAJhRvn 3GAgAA X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-7.tower-21.messagelabs.com!1507225355!76593519!1 X-Originating-IP: [209.85.220.172] 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 6520 invoked from network); 5 Oct 2017 17:42:36 -0000 Received: from mail-qk0-f172.google.com (HELO mail-qk0-f172.google.com) (209.85.220.172) by server-7.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 5 Oct 2017 17:42:36 -0000 Received: by mail-qk0-f172.google.com with SMTP id s14so2251120qks.6 for ; Thu, 05 Oct 2017 10:42:36 -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=pXA3m86mp6W7YlPpFv0VpJPYiQEror6TiQpdixAbzcc=; b=Fq3hGUeoDnvhyGoqKgFfEDFXVCQnGRtKPyhKAWnpK5L3eFr4u7vSgzt3MKKvNrxhnB CqZ1r7KnmBw5GGUL0PiV3XLkhUQrH57ulLF+9ucv4govfdHFKz6nGxRGEkMBJGP6nEo4 IbuSDuhNBxZHt5O58hPowuo1tQFuAIYaoO43I= 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=pXA3m86mp6W7YlPpFv0VpJPYiQEror6TiQpdixAbzcc=; b=bOhJeFIYs1HPbK3Skwt86kv/iZgbZFGLYmwfP0sUxI+FGR6DcgCYQRVmSwnd6j34/S BvqLndfk7EaXpAs/lEvYkssZs2DWb1KZMC5pQyn6rCFnW2UvxVKnap9bK24lamzLUA9T 8v4FyFVgMriBdd8Nb7GxUHeN1j2Ib6znpvhVwVnuuN1wFR04eC+v5fe+TYETVJMqrA1d 5YVMFQRdfeJRrE3mrVYshfFxye4/83SU/++jCDSEB7wWVfeScY5oNDEiaEsXjyLF4jid Cg+oPzy5SJPeTH7WL39r0vcKTlQra6DbgrQVsuWz2nkwnAalmRij3i8YqXKOCVFEjubF c8rw== X-Gm-Message-State: AMCzsaWtJjuJTBdfuGgiogSzKcrvq7ODWfZzsKnxTm1t86jDd5bOSoNx JjO2RKwKI0lOYHvw5NM6uVcdJ+5Mgog= X-Google-Smtp-Source: AOwi7QACQNko7AlRZlCB6k+lB7UZAU6e8e85Ha/bRt7LAUe8PpExJF7eIMYjttAxse0lFFfgnhaeAQ== X-Received: by 10.55.209.27 with SMTP id s27mr19931710qki.4.1507225355459; Thu, 05 Oct 2017 10:42:35 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id y63sm11815084qky.75.2017.10.05.10.42.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Oct 2017 10:42:35 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 5 Oct 2017 18:42:18 +0100 Message-Id: <20171005174222.29161-6-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171005174222.29161-1-julien.grall@linaro.org> References: <20171005174222.29161-1-julien.grall@linaro.org> Cc: Andrew Cooper , Julien Grall Subject: [Xen-devel] [PATCH v2 5/9] xen/kimage: Remove defined but unused variables 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" In the function kimage_alloc_normal_control_page, the variables mfn and emfn are defined but not used. Remove them. Signed-off-by: Julien Grall Reviewed-by: Andrew Cooper --- Cc: Andrew Cooper Changes in v3: - Add Andrew's reviewed-by --- xen/common/kimage.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/xen/common/kimage.c b/xen/common/kimage.c index ebc71affd1..07587896a4 100644 --- a/xen/common/kimage.c +++ b/xen/common/kimage.c @@ -310,14 +310,11 @@ static struct page_info *kimage_alloc_normal_control_page( * destination page. */ do { - unsigned long mfn, emfn; paddr_t addr, eaddr; page = kimage_alloc_zeroed_page(memflags); if ( !page ) break; - mfn = page_to_mfn(page); - emfn = mfn + 1; addr = page_to_maddr(page); eaddr = addr + PAGE_SIZE; if ( kimage_is_destination_range(image, addr, eaddr) ) From patchwork Thu Oct 5 17:42: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: 114955 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp848267qgn; Thu, 5 Oct 2017 10:44:40 -0700 (PDT) X-Received: by 10.36.94.130 with SMTP id h124mr32358145itb.2.1507225480415; Thu, 05 Oct 2017 10:44:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507225480; cv=none; d=google.com; s=arc-20160816; b=TbulP0c+pOEiCE9B+V65PJUYWkJoq+YPq0An0grEOtBq30azyK6+AvzIh8yYm/7UgP /wNB8KHjezdqoBj3CiQ96YcQtzwQCiH2Qt9+OKT+qh1MVLAzy3RnzkEpYMcyqC77nZ+Q +tR6sk0Ym/k4fuas6Lm4qo3P/qCbf83n000SXD/+YGiOXECrKTPG7WptRdQjaDmnXhVl fnUQwuJ9P4Z/1BcXvMeNKcUk9qJ0NkaljJEiGEy/I2fvv9SFY27bQ/MpwlRccT+UTrIe mRgdYwJDkGywFGyDyO35ARXza5S4IvGOGtg71Ft0x4WiKqeX5VSpAi8HEl7SC6s+dH3I XP0w== 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=cJ5x3sCsaROmt3jk5OIwt4XUR0eflg8wSjsVcYmG5y8=; b=M7576Te1B5XCv04VsuU16aBmP8mwdDQ6PtGCAlCNiT75b91fzUkZuJejWZljGZLljB iabQxU2uPLybGEt78+apBBIJIPfjrICAeUuhH5OQHZHqzbvmF0TTnlpou+AJUAxdGk5K r2HekuW5UBnI4SgXF19772e1zRC938gjvaA0qAxGj01xKn2Ol2PpwApwh8Q7QpjGf/Gj 8mgs7/iMx0vl116L6Ge0l1b72WucfCwgSszg4LmfkeFjDm+AD8ySUB7u5Gb4Zujfu0qv dYgt5pv202rKZq9qX5OPTRufTiOGR68taEwaGgNPg1X8fLZpZm1epfsA9zDXwlTNX3B8 cE0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=AHv4rDd8; 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 o194si15076632ioo.340.2017.10.05.10.44.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Oct 2017 10:44:40 -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=AHv4rDd8; 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 1e0AAS-00011E-IT; Thu, 05 Oct 2017 17:42:40 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e0AAR-0000z9-FM for xen-devel@lists.xen.org; Thu, 05 Oct 2017 17:42:39 +0000 Received: from [193.109.254.147] by server-5.bemta-6.messagelabs.com id 37/D8-03453-E0F66D95; Thu, 05 Oct 2017 17:42:38 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrEIsWRWlGSWpSXmKPExsVyMfTOVl2+/Gu RBjvmMlks+biYxYHR4+ju30wBjFGsmXlJ+RUJrBnP7x5kLzhnVjFv3XPGBsYvGl2MXBxCAhMZ JS7eOMXYxcjJwSIwj1ni7XtDkISEQD+rxLVZ68ESEgJ5Ej/+fQSyOYDsNImuRXoQZpXElDXhI KaQgJrEmjdRECP7mCSedT1iA4mzCehIrJtRCzJEREBa4trny2ADmQW0JH6eWwJWIiwQIfHljy TEAaoSs7oms4CEeQVsJC7vSoVYLy+xq+0iK4jNKWArsb7nDjuILQRUsnzFWeYJjIILGBlWMWo UpxaVpRbpGhnrJRVlpmeU5CZm5ugaGpjp5aYWFyemp+YkJhXrJefnbmIEhhkDEOxg/DM/8BCj JAeTkiivV9a1SCG+pPyUyozE4oz4otKc1OJDjDIcHEoSvPx5QDnBotT01Iq0zBxgwMOkJTh4l ER4n+YCpXmLCxJzizPTIVKnGC05Lty59IeJ48CeW0Cy4+bdP0xCLHn5ealS4rzGIPMEQBoySv PgxsGi8hKjrJQwLyPQgUI8BalFuZklqPKvGMU5GJWEeQ+CrOXJzCuB2/oK6CAmoIPmNF0BOag kESEl1cAoPOVAoEjF+U1fvsr6WtjtM1aL2NqlwfSl0//+Y6+OnVl+u21b3fP8X73ctq52w9VN B02Mq491vm22TJB3vXbm9relH4+JBV0oO+UtUqsS4f76J88JU9Ofu291T+mRFo581c7L9evS8 79+4UcfJ2o8zfmqlLa6T+FW44Ly2Vtu/tL4lpFsW6GuxFKckWioxVxUnAgA9A3xAcUCAAA= X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-2.tower-27.messagelabs.com!1507225357!50752389!1 X-Originating-IP: [209.85.220.181] 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 16849 invoked from network); 5 Oct 2017 17:42:37 -0000 Received: from mail-qk0-f181.google.com (HELO mail-qk0-f181.google.com) (209.85.220.181) by server-2.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 5 Oct 2017 17:42:37 -0000 Received: by mail-qk0-f181.google.com with SMTP id s14so2251185qks.6 for ; Thu, 05 Oct 2017 10:42:37 -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=IbrwkmISdeyT/h3aspC38nqOUgqTwVCohE7dZ/T7lq4=; b=AHv4rDd82nfz9nh6SRjNb8T3Ix8GagWfIde0aHZuislnO4FE4mudh3eXoqV3YH/Lts fvUfqd0l4OvqX9t2IXQNmzwTZ3KyOVmdBRqrm/2awBYyYnksDExhUO9wEqUN/9dMLQas 84CcPJ56mtQaRtbCNmLEIp8zMJFe2nLTWwhuw= 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=IbrwkmISdeyT/h3aspC38nqOUgqTwVCohE7dZ/T7lq4=; b=YgV/7TqmcWSNx2thFgqrwciLe809sUUwUKuxGRtEBbhb1nzAQS9VM2aZvjtZG2Fef3 Ry0j577Sxlx/HwoCGl8jgsngK77G3DBI7AhT5omyGZwLuZd1IJ5+J/fBawA3hxtvYlTT M7TAVkkP4K8VWHWy42oe0YB5II38c66SFDQxyWPkudLEFJZeRf0R0lz4LpeXCW8tWCyb 3HPGwGrJCOd4PIHkEHMew76+nmkIWzkMzeeDt7LrP3wPiMQX1/zkZOZqvFRGAgAE6Ej5 453i5hCDPq0cfnvMUKosusP1GJMjV470xwVLC0AWkSnYaafoEAE86ca+/6d1yZbT7noZ lsTg== X-Gm-Message-State: AMCzsaVsVqZHr1qxQ2IV20bPqTsVv/KPbXD9HDrJ2/BWgHrPK1Pbjqgq Gc911rhauDWn4UVKB4qYeq6g8HT1lH0= X-Google-Smtp-Source: AOwi7QAHEdFXeA9g+uaDtljM1LeC1irNtc/4PPJbUeyBxNdSf5hSaU4taT/DCMYIPzpQ1o8uF6e6YA== X-Received: by 10.55.178.65 with SMTP id b62mr31887532qkf.348.1507225356627; Thu, 05 Oct 2017 10:42:36 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id y63sm11815084qky.75.2017.10.05.10.42.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Oct 2017 10:42:36 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 5 Oct 2017 18:42:19 +0100 Message-Id: <20171005174222.29161-7-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171005174222.29161-1-julien.grall@linaro.org> References: <20171005174222.29161-1-julien.grall@linaro.org> Cc: Julien Grall Subject: [Xen-devel] [PATCH v2 6/9] xen/kexec, kimage: Convert kexec and kimage to use typesafe mfn_t 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" At the same time, correctly align one the prototype changed. Signed-off-by: Julien Grall Reviewed-by: Andrew Cooper --- xen/common/kexec.c | 16 ++++++++-------- xen/common/kimage.c | 30 ++++++++++++++++++------------ xen/include/xen/kimage.h | 4 ++-- 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/xen/common/kexec.c b/xen/common/kexec.c index fcc68bd4d8..c14cbb2b9c 100644 --- a/xen/common/kexec.c +++ b/xen/common/kexec.c @@ -905,11 +905,11 @@ static uint16_t kexec_load_v1_arch(void) #endif } -static int kexec_segments_add_segment( - unsigned int *nr_segments, xen_kexec_segment_t *segments, - unsigned long mfn) +static int kexec_segments_add_segment(unsigned int *nr_segments, + xen_kexec_segment_t *segments, + mfn_t mfn) { - paddr_t maddr = (paddr_t)mfn << PAGE_SHIFT; + paddr_t maddr = mfn_to_maddr(mfn); unsigned int n = *nr_segments; /* Need a new segment? */ @@ -930,7 +930,7 @@ static int kexec_segments_add_segment( return 0; } -static int kexec_segments_from_ind_page(unsigned long mfn, +static int kexec_segments_from_ind_page(mfn_t mfn, unsigned int *nr_segments, xen_kexec_segment_t *segments, bool_t compat) @@ -939,7 +939,7 @@ static int kexec_segments_from_ind_page(unsigned long mfn, kimage_entry_t *entry; int ret = 0; - page = map_domain_page(_mfn(mfn)); + page = map_domain_page(mfn); /* * Walk the indirection page list, adding destination pages to the @@ -961,7 +961,7 @@ static int kexec_segments_from_ind_page(unsigned long mfn, break; case IND_INDIRECTION: unmap_domain_page(page); - entry = page = map_domain_page(_mfn(mfn)); + entry = page = map_domain_page(mfn); continue; case IND_DONE: goto done; @@ -990,7 +990,7 @@ static int kexec_do_load_v1(xen_kexec_load_v1_t *load, int compat) xen_kexec_segment_t *segments; uint16_t arch; unsigned int nr_segments = 0; - unsigned long ind_mfn = load->image.indirection_page >> PAGE_SHIFT; + mfn_t ind_mfn = maddr_to_mfn(load->image.indirection_page); int ret; arch = kexec_load_v1_arch(); diff --git a/xen/common/kimage.c b/xen/common/kimage.c index 07587896a4..afd8292cc1 100644 --- a/xen/common/kimage.c +++ b/xen/common/kimage.c @@ -23,6 +23,12 @@ #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 @@ -76,7 +82,7 @@ static struct page_info *kimage_alloc_zeroed_page(unsigned memflags) if ( !page ) return NULL; - clear_domain_page(_mfn(page_to_mfn(page))); + clear_domain_page(page_to_mfn(page)); return page; } @@ -405,7 +411,7 @@ static struct page_info *kimage_alloc_crash_control_page(struct kexec_image *ima if ( page ) { image->next_crash_page = hole_end; - clear_domain_page(_mfn(page_to_mfn(page))); + clear_domain_page(page_to_mfn(page)); } return page; @@ -641,7 +647,7 @@ static struct page_info *kimage_alloc_page(struct kexec_image *image, *old = (addr & ~PAGE_MASK) | IND_SOURCE; unmap_domain_page(old); - page = mfn_to_page(mfn_x(old_mfn)); + page = mfn_to_page(old_mfn); break; } else @@ -840,11 +846,11 @@ kimage_entry_t *kimage_entry_next(kimage_entry_t *entry, bool_t compat) return entry + 1; } -unsigned long kimage_entry_mfn(kimage_entry_t *entry, bool_t compat) +mfn_t kimage_entry_mfn(kimage_entry_t *entry, bool_t compat) { if ( compat ) - return *(uint32_t *)entry >> PAGE_SHIFT; - return *entry >> PAGE_SHIFT; + return maddr_to_mfn(*(uint32_t *)entry); + return maddr_to_mfn(*entry); } unsigned long kimage_entry_ind(kimage_entry_t *entry, bool_t compat) @@ -854,7 +860,7 @@ unsigned long kimage_entry_ind(kimage_entry_t *entry, bool_t compat) return *entry & 0xf; } -int kimage_build_ind(struct kexec_image *image, unsigned long ind_mfn, +int kimage_build_ind(struct kexec_image *image, mfn_t ind_mfn, bool_t compat) { void *page; @@ -862,7 +868,7 @@ int kimage_build_ind(struct kexec_image *image, unsigned long ind_mfn, int ret = 0; paddr_t dest = KIMAGE_NO_DEST; - page = map_domain_page(_mfn(ind_mfn)); + page = map_domain_page(ind_mfn); if ( !page ) return -ENOMEM; @@ -873,7 +879,7 @@ int kimage_build_ind(struct kexec_image *image, unsigned long ind_mfn, for ( entry = page; ; ) { unsigned long ind; - unsigned long mfn; + mfn_t mfn; ind = kimage_entry_ind(entry, compat); mfn = kimage_entry_mfn(entry, compat); @@ -881,14 +887,14 @@ int kimage_build_ind(struct kexec_image *image, unsigned long ind_mfn, switch ( ind ) { case IND_DESTINATION: - dest = (paddr_t)mfn << PAGE_SHIFT; + dest = mfn_to_maddr(mfn); ret = kimage_set_destination(image, dest); if ( ret < 0 ) goto done; break; case IND_INDIRECTION: unmap_domain_page(page); - page = map_domain_page(_mfn(mfn)); + page = map_domain_page(mfn); entry = page; continue; case IND_DONE: @@ -913,7 +919,7 @@ int kimage_build_ind(struct kexec_image *image, unsigned long ind_mfn, goto done; } - copy_domain_page(_mfn(page_to_mfn(xen_page)), _mfn(mfn)); + copy_domain_page(page_to_mfn(xen_page), mfn); put_page(guest_page); ret = kimage_add_page(image, page_to_maddr(xen_page)); diff --git a/xen/include/xen/kimage.h b/xen/include/xen/kimage.h index d10ebf7844..cbfb9e9054 100644 --- a/xen/include/xen/kimage.h +++ b/xen/include/xen/kimage.h @@ -48,9 +48,9 @@ struct page_info *kimage_alloc_control_page(struct kexec_image *image, unsigned memflags); kimage_entry_t *kimage_entry_next(kimage_entry_t *entry, bool_t compat); -unsigned long kimage_entry_mfn(kimage_entry_t *entry, bool_t compat); +mfn_t kimage_entry_mfn(kimage_entry_t *entry, bool_t compat); unsigned long kimage_entry_ind(kimage_entry_t *entry, bool_t compat); -int kimage_build_ind(struct kexec_image *image, unsigned long ind_mfn, +int kimage_build_ind(struct kexec_image *image, mfn_t ind_mfn, bool_t compat); #endif /* __ASSEMBLY__ */ From patchwork Thu Oct 5 17:42: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: 114960 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp848342qgn; Thu, 5 Oct 2017 10:44:45 -0700 (PDT) X-Received: by 10.36.111.148 with SMTP id x142mr33475388itb.72.1507225485590; Thu, 05 Oct 2017 10:44:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507225485; cv=none; d=google.com; s=arc-20160816; b=BSUo3Qsi7CTlCmwiXO5AetVAKI1CEKOUHKH7V4AgvHxrXFyNIxKAIPY6mg0UDCXmEc 7ov8z5kaxw8jQAmlAKyPmj4aC7kmrnr0PPSu2OUp86g8x+4EONT1eoyD9rkH7sE9jLKV r7TSMj6i3oxNbB7ZEFod8cDMswiyp32D3hC6sixbJSTkY8q6C5nS17p/TvmdXgMeg0Wi qGjWxj+tXQQayQMG0TJyz/0iJVy2IWDfDwO5JYpEqfwNe5hBtn+Q7fqxhEJsciQqPjdD 3b7xA/EnNT/wN7v9pJOyFL8nYlQ7bQHV921u31nSvgSEAHsK1vJO0zOdxwphcGYbokf4 UwuQ== 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=9BCAMH0aQtNCA+wDAnLWT0sS8gFt0qQJrxyRG4kkmg8=; b=U+y0crdozqA6eKzNcCqHRKI6AVbg7bTnSI/jVtGg8S2jxzVOaDOWz+6r4ex2z4oVw8 G9TV5iLvnr+ViGG+cRpGUC+ymQApWj3yf8lx6Dv70YAizadyfzp59hQqq6x9WWuD5bZc m0dVudRU/Uq3GXFAlD4u8TWr+7W3HfQnve4HRKthSd0MZ3fkKQm+Yy4GZN8QINxtBn+q WZYFDVmwiJMvBZiqWKxOgYv3MYiTlPQ757xk9+MUPCKlvzxofasTigZapBl7hj+Ysjgh +IAC4maS9eBsuzH73M2tXD5X6UX6Bl9G+aHr8ITKZ5b0s0ljobkGWARB92RgsTT++3Bp yCMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=QOQtK6Wa; 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 p10si200553itp.143.2017.10.05.10.44.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Oct 2017 10:44:45 -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=QOQtK6Wa; 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 1e0AAU-000132-QS; Thu, 05 Oct 2017 17:42:42 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e0AAT-000122-Vw for xen-devel@lists.xen.org; Thu, 05 Oct 2017 17:42:42 +0000 Received: from [193.109.254.147] by server-11.bemta-6.messagelabs.com id 62/FE-03638-11F66D95; Thu, 05 Oct 2017 17:42:41 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrKIsWRWlGSWpSXmKPExsVyMfTOJl3+/Gu RBl8fG1os+biYxYHR4+ju30wBjFGsmXlJ+RUJrBmt3e/YC9olKi5ff8LUwPhJqIuRi0NIYBKj xI9pDewgDovAPGaJ6+vWs3UxcnJICPSzSiycow1h50lcX/yYqYuRA8hOk3g7wxfCrJa48DoGx BQSUJNY8yYKYmQfk0Tv7ptg1WwCOhLrZtSCDBERkJa49vkyI0gNs8ArJonW5wvYQRLCAl4Sj9 9+BLNZBFQl3h1dD2bzCthIPJv1lR3iAnmJXW0XWUFsTgFbifU9d8DiQkA1y1ecZZ7AKLiAkWE Vo0ZxalFZapGusZFeUlFmekZJbmJmjq6hgZlebmpxcWJ6ak5iUrFecn7uJkZgsDEAwQ7G0+sC DzFKcjApifJ6ZV2LFOJLyk+pzEgszogvKs1JLT7EKMPBoSTBy58HlBMsSk1PrUjLzAGGPUxag oNHSYRXHiTNW1yQmFucmQ6ROsVoyXHhzqU/TBwH9twCkh037/5hEmLJy89LlRLn3ZML1CAA0p BRmgc3DhablxhlpYR5GYEOFOIpSC3KzSxBlX/FKM7BqCTMawWyliczrwRu6yugg5iADprTdAX koJJEhJRUA6PNXMO3ifwhHudWrtzOtOaeUP/kPsa5eTyfGVu+iOrfefuW5ZaCRwuXqavSm398 W+bM3yj4PGO/bmdvoKf17y6Vo1f/t12rW7Dsvb7R5XMFMx5Hx32Qu5Gxnfd7aUC/SRH3HZGDh nolK37dat7wa73oj6tT2fOmSW2/1CbLL3gix1rh+33mt4eUWIozEg21mIuKEwEjL+ajyAIAAA == X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-12.tower-27.messagelabs.com!1507225358!108850717!1 X-Originating-IP: [209.85.220.178] 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 8343 invoked from network); 5 Oct 2017 17:42:39 -0000 Received: from mail-qk0-f178.google.com (HELO mail-qk0-f178.google.com) (209.85.220.178) by server-12.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 5 Oct 2017 17:42:39 -0000 Received: by mail-qk0-f178.google.com with SMTP id n5so13263815qke.11 for ; Thu, 05 Oct 2017 10:42:39 -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=mWQLWwILqk9oSTywGUlMW6L5946TJfO99va/8bLjfzQ=; b=QOQtK6Wam0f0JAV/Qit8jqrS/99WmzFQamdedeB1qJTqBYVzE1mUgKft59pmnCVsOS f4I7HENoaH2c66GB86oX1vBBeHLg7I98JM0MlrTnQM23U0HhBAgDPcAcbj470uan30I/ Jc0dlGLZfs4CbbefEM67F8qm17q1CBfTHikQE= 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=mWQLWwILqk9oSTywGUlMW6L5946TJfO99va/8bLjfzQ=; b=ENsqOeIWFvWzz+ktjsSAJELhPAvZI5owStL/04uVPOTaWkT3AylenF/LpTUucd61k0 71VRz6Xr/v2udEumPTvn7VtVTlxG2FDz+2Cj++XShGdqUTTor9TEJwuHhpRMqMRTx6Md 0JtRS+7XJQ3MUGvZfXI0Ut6aFR1C0R5wyGrPj9+Aj/wR0DlksL9gzQBvRu+0q+b4rgEO 76VG8Vw7Z4tHMuaQTK+2tH67vGZ4u9ysn+xakWRbLqV5OFGlYavcvAiJ8n7LyUWDOwgA znTXlJ5KkENxiiL/ATs2v9cpbnMppavQSssAPR7w4nefaVgdsAJKxjlWlkkS5zVv8dZ1 M3CQ== X-Gm-Message-State: AMCzsaUJCnXTWxmPyQQrRethRlFG/TWHnWutRax0j94f0SFR72MIfGfN SF0B7MqIG1UGYAGmV4qn6SNF26nKqtM= X-Google-Smtp-Source: AOwi7QBOS4WCEo43cicq/faitrieOxJyofzeZwi5VktsKIvCuZxyv6rRS7vgwMevI+uGAQydTDIkoA== X-Received: by 10.55.204.157 with SMTP id n29mr28754391qkl.243.1507225358464; Thu, 05 Oct 2017 10:42:38 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id y63sm11815084qky.75.2017.10.05.10.42.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Oct 2017 10:42:38 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 5 Oct 2017 18:42:20 +0100 Message-Id: <20171005174222.29161-8-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171005174222.29161-1-julien.grall@linaro.org> References: <20171005174222.29161-1-julien.grall@linaro.org> Cc: Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Julien Grall , Ian Jackson , Tim Deegan , Jan Beulich Subject: [Xen-devel] [PATCH v2 7/9] xen/xenoprof: Convert the file 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/xenoprof.c is now converted to use typesafe. This is requiring to override the macros virt_to_mfn and mfn_to_page to make them work with mfn_t. Also, add a couple of missing newlines in the code modified. Signed-off-by: Julien Grall Reviewed-by: Andrew Cooper --- 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 Changes in v2: - Add missing newlines - Add Andrew's reviewed-by --- xen/common/xenoprof.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/xen/common/xenoprof.c b/xen/common/xenoprof.c index a5fe6204a5..5acdde5691 100644 --- a/xen/common/xenoprof.c +++ b/xen/common/xenoprof.c @@ -19,6 +19,12 @@ #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)) +#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 @@ -134,25 +140,27 @@ static void xenoprof_reset_buf(struct domain *d) } static int -share_xenoprof_page_with_guest(struct domain *d, unsigned long mfn, int npages) +share_xenoprof_page_with_guest(struct domain *d, mfn_t mfn, int npages) { int i; /* Check if previous page owner has released the page. */ for ( i = 0; i < npages; i++ ) { - struct page_info *page = mfn_to_page(mfn + i); + struct page_info *page = mfn_to_page(mfn_add(mfn, i)); + if ( (page->count_info & (PGC_allocated|PGC_count_mask)) != 0 ) { printk(XENLOG_G_INFO "dom%d mfn %#lx page->count_info %#lx\n", - d->domain_id, mfn + i, page->count_info); + d->domain_id, mfn_x(mfn_add(mfn, i)), page->count_info); return -EBUSY; } page_set_owner(page, NULL); } for ( i = 0; i < npages; i++ ) - share_xen_page_with_guest(mfn_to_page(mfn + i), d, XENSHARE_writable); + share_xen_page_with_guest(mfn_to_page(mfn_add(mfn, i)), + d, XENSHARE_writable); return 0; } @@ -161,11 +169,12 @@ static void unshare_xenoprof_page_with_guest(struct xenoprof *x) { int i, npages = x->npages; - unsigned long mfn = virt_to_mfn(x->rawbuf); + mfn_t mfn = virt_to_mfn(x->rawbuf); for ( i = 0; i < npages; i++ ) { - struct page_info *page = mfn_to_page(mfn + i); + struct page_info *page = mfn_to_page(mfn_add(mfn, i)); + BUG_ON(page_get_owner(page) != current->domain); if ( test_and_clear_bit(_PGC_allocated, &page->count_info) ) put_page(page); From patchwork Thu Oct 5 17:42: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: 114953 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp848233qgn; Thu, 5 Oct 2017 10:44:38 -0700 (PDT) X-Received: by 10.36.68.207 with SMTP id o198mr821662ita.74.1507225477952; Thu, 05 Oct 2017 10:44:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507225477; cv=none; d=google.com; s=arc-20160816; b=qLwVd7Zdal+kAMpI0C424ylZQHFxf/fvUBWPoGV842C3L5IDODc4/+HHoZRQNDUDej 377Qj5kc1apLcwRniXTqVsdPH+k8p3EoSx7GgilbKMMl9gnP97fpHEEdyTZHeuPQlgJu byQEHaLR2U0Ln8gM6o4UVeDg1qAujtAgwJGKfRAxxo0tPSXoL4xbq4V3LnGoO/533hEj ZFDRryuA2ZlwOfAVXxCNgCv5CAmh7fO/9voN5zjEbN3UMdbvXOOlmCXKI4kxRTZ3V6Et t2uFz+E2gp3AZB/2rPgEcT8qbfwudVliZZYVLA3HMi14D7U3ns0I7Kf+9gC+V2LJDqVi pxZw== 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=U+4c0a08NZdwYT8VjyvTvKTh75YxJGnAO0kin8oN/5tkUlAQXFe5XwYNZv1LT38ly4 AWTOWbixwD+/JgQ8o/DiInkD6kVjtq2mRX/YJl4LHu9mXh54czC3adtNHnVSIx6+yv+l MIXyAYAP0djEqhUyb/HawLTZdjw7YGCgpmeEvBHsgHnsN+6vxy2vDkhwRIIWlRgziEel WI01kTfFguwKY2OJOne27UjyoB1UbdiJlY7XQ1lrO1tw7CeMfWY+j/XuHJOdtajZEVly +y0iQMypMPmKsmv+ri0qWWY1Lq9fPS4FjKdH9Tt3QCeKRWK0OKVkBalJqZrqwA6Q1Uon 0XJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=enhj/DXi; 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 r90si677789ioe.128.2017.10.05.10.44.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Oct 2017 10:44: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; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=enhj/DXi; 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 1e0AAW-00014P-1b; Thu, 05 Oct 2017 17:42:44 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e0AAU-00012U-FW for xen-devel@lists.xen.org; Thu, 05 Oct 2017 17:42:42 +0000 Received: from [85.158.137.68] by server-1.bemta-3.messagelabs.com id 96/EB-02047-11F66D95; Thu, 05 Oct 2017 17:42:41 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrCIsWRWlGSWpSXmKPExsVyMfTOGl2B/Gu RBquvW1ks+biYxYHR4+ju30wBjFGsmXlJ+RUJrBkvmw8zFlxRq2g/vJO5gfGHbBcjJ4eQwGRG ie7F7l2MXBwsAvOYJXZc/MYM4kgI9LNKTD11gxWkSkIgT+Jl13kmCDtN4t+cDewQdqXEl80rg OIcQJPUJNa8iQLpFRLoY5K4MfkAI0icTUBHYt2MWpByEQFpiWufLzOC2MwC0RLXfh8CaxUWiJ D4PssdJMwioCpxb95isE28AjYS5xc8ZIPYJC+xq+0i2DWcArYS63vusEPcbyOxfMVZ5gmMggs YGVYxqhenFpWlFuka6iUVZaZnlOQmZuboGhoY6+WmFhcnpqfmJCYV6yXn525iBIYaAxDsYFz+ 0ekQoyQHk5Ior1fWtUghvqT8lMqMxOKM+KLSnNTiQ4wyHBxKErz8eUA5waLU9NSKtMwcYNDDp CU4eJREeOVB0rzFBYm5xZnpEKlTjJYcF+5c+sPEcWDPLSDZcfPuHyYhlrz8vFQpcd49uUANAi ANGaV5cONgkXmJUVZKmJcR6EAhnoLUotzMElT5V4ziHIxKwrx/QKbwZOaVwG19BXQQE9BBc5q ugBxUkoiQkmpgzC2dtPArd/4nrofKN0N7z4jvfnq8/oPyBl3lrhV/HWSmxnqvqr8nENcftPpv ieu96A3V81u8vjh2ZtsvXjjTU/6ueQwDw1vRN7WWthsnV+9eX2fCd7gtdvfLgAfW2lntst9Wt XW8XNCSuuOJiX+BWJnxjF1xbz458yxwrL5g1jy9RMP3W+RPJZbijERDLeai4kQAATDnZccCAA A= X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-10.tower-31.messagelabs.com!1507225360!117421887!1 X-Originating-IP: [209.85.220.172] 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 12512 invoked from network); 5 Oct 2017 17:42:40 -0000 Received: from mail-qk0-f172.google.com (HELO mail-qk0-f172.google.com) (209.85.220.172) by server-10.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 5 Oct 2017 17:42:40 -0000 Received: by mail-qk0-f172.google.com with SMTP id l194so5505053qke.13 for ; Thu, 05 Oct 2017 10:42:40 -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=enhj/DXiLeGW5TsuMgcltHk0TCcAXE+tX3mQsx86Q3R105Tl42QPf00DeYdV99TcaH u6dshrzNvKEXZDF0skfTCh+o8yBzQZABhbNgevkgPK0QVMSZZHXK/tGAy8gHG6x1cX1w RD4e91FleRWubRpEW6RfMutQYSAoumfgsT7Tg= 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=U9LKAsA1ShwEFxsROBs9VgiVNBi5HiYSnQFzpfxyrdxPX5Je414v9UGM5jz4PyGj9a iUxYZZUNIeKGTq4fNHegNb6tCLIGPdStLnvgeNcR/A9IYodx81GeVN3Wkwh+vP7KX5qP +spWm0ycFaU749946px+Ku4JDjVA+IKVfZAibXLsSiDmS5V0fvdE4wv8ln9TlL+fFpJO c0rx3o+5nfbcRNoarhEWdlWB9H9DrHgxABYqV6glWcBOe2hbqDiutNSPXKQm/Y5ZkqAN gFdA++HqYnyhRApxDg4e3v5mGvcjIRtPwqPZcvsn1d+pVdT+iBElSvkwp0qfZwFEr3ZN cMyQ== X-Gm-Message-State: AMCzsaWXvfdLya/2X1TSWB6kUJ9/b9cF7RfD6/gfut9g2qUo4VLublq9 U3eK2rHrHJnpI29eyHmesWM6t73dZh4= X-Google-Smtp-Source: AOwi7QDnS1JP2mepuLenmFBmfBPQIfBs8cZB5DRcch4h4v1STurQ1gyO3HkchsnouXh3r3mdfptlAQ== X-Received: by 10.55.22.13 with SMTP id g13mr32467689qkh.153.1507225359614; Thu, 05 Oct 2017 10:42:39 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id y63sm11815084qky.75.2017.10.05.10.42.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Oct 2017 10:42:39 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 5 Oct 2017 18:42:21 +0100 Message-Id: <20171005174222.29161-9-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171005174222.29161-1-julien.grall@linaro.org> References: <20171005174222.29161-1-julien.grall@linaro.org> Cc: Julien Grall , Konrad Rzeszutek Wilk Subject: [Xen-devel] [PATCH v2 8/9] 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 --- 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 Thu Oct 5 17:42: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: 114962 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp848936qgn; Thu, 5 Oct 2017 10:45:25 -0700 (PDT) X-Received: by 10.36.213.133 with SMTP id a127mr16946352itg.76.1507225525882; Thu, 05 Oct 2017 10:45:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507225525; cv=none; d=google.com; s=arc-20160816; b=p+7If7kfJCvJyl5+6uZLELzzhKPXTQatnDrAhKrNkIFR44gDXS2mWQjo4+s24uAWlo 3dyM/BRh0WtqJ32ZQzZWvUXlhbgtmAMTCxqXjAxKZX3R9T1O/cTSnnVzzZMZk7d7wHZs topqKmz5OkzAl45ctUQrywPcYwjNY7iLGdDWEzu5ZRYAJxTNv33udw1B8lG0n3mo8X/9 B3jujfJ7qURKBcz+6zl9+QkT7VYclpsS13psoNLrNb9xo+5JKOxOSY6q4y3ajC0tuvAr kG6HUzQCDP01T0MdT6k9nJbCxdX39V+ZlEfcwZxcpaCzUdXHDROwVkZ+7ppN8rQzNPk0 RMHg== 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=caadtTpMWZD3vhiZcYEAfBvTZTJhI1gTVTeBfv1THaI=; b=yghESFrvJqvdM5iRlXnP35MBzIBFxbEu4Kw2lQOZAKfUW6ck809xiKiXOY3LBc9Lpy 1NytSlJ1mFlCZzMa2ah8fXODtvlATxZeZrhQMoovZOOOEElBr8dRIx+MosqvxEG4ltKc 30qxCZR8AA0iLchWRrTHFqMpCfOETKzPDUkn4210zdoKv1UeLeaP99bIC0MFv8+NETEs k337erri6744Uf4wISnNxG/jP26SXSbDJs8kv6ECmzB3zMRdvs4aJzy7KYrk8b3b6GpW mNkDy3JN+F2jywv+nbG0P2F9vtlVZ10+04R89wAAv3QIE5AqMJ/d/CaPvMLDwyOC2ujU Errw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Hf5a63Sd; 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 k14si205286ita.104.2017.10.05.10.45.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Oct 2017 10:45:25 -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=Hf5a63Sd; 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 1e0AAe-0001BI-EV; Thu, 05 Oct 2017 17:42: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 1e0AAc-000199-9D for xen-devel@lists.xen.org; Thu, 05 Oct 2017 17:42:50 +0000 Received: from [85.158.143.35] by server-9.bemta-6.messagelabs.com id 92/C9-03428-91F66D95; Thu, 05 Oct 2017 17:42:49 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrHIsWRWlGSWpSXmKPExsVyMfTGal2R/Gu RBhfazC2WfFzM4sDocXT3b6YAxijWzLyk/IoE1ozrM++xFcx/xVzR2zSLqYGxqYO5i5GLQ0hg AqPEqzn7WUEcFoF5zBId786AZSQE+lkl7i1/y9TFyAnk5EksnvaSrYuRA8hOk9ixSRwiXCWx8 spBsLCQgJrEmjdRIGEhgT4miZ2rK0DCbAI6Eutm1IKERQSkJa59vswIMp1ZYAubRMvnyywgNc ICERL7N+uA1LAIqEp82T+bHSTMK2ArMe+5LcQieYldbRdZQWxOoPD6njvsEJtsJJavOMs8gVF wASPDKkaN4tSistQiXUMzvaSizPSMktzEzBxdQwMzvdzU4uLE9NScxKRiveT83E2MwHBjAIId jPc3BhxilORgUhLl9cq6FinEl5SfUpmRWJwRX1Sak1p8iFGGg0NJgtczDygnWJSanlqRlpkDD HyYtAQHj5IIr2kuUJq3uCAxtzgzHSJ1ijGQ48KdS3+YOI5tugwkD+y5BSQf3bgLJDtugshNYH LD9wd/mIRY8vLzUqXEefeADBIAGZRRmge3BhbNlxhlpYR5GYEOF+IpSC3KzSxBlX/FKM7BqCT MawVyLU9mXgncNa+ADmUCOnRO0xWQQ0sSEVJSDYzGniUmmVtWqKic5117yjhr94s/TiZdKye3 1kWXzD5xXzcqtr/4RWvMpD8TlsRIzeA9Yy+ccLmsVd3eemnopd8/Hy52ypwS//g6i/MN4xefr HdVtmQ+T9Gq/y/g9eHwlKm9j1feTfczkLYJmqV44mOj3bQnFjl+Z45JtOrU9V7MOrmhJ1Nhyx MlluKMREMt5qLiRAC4haU54QIAAA== X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-15.tower-21.messagelabs.com!1507225363!76406141!1 X-Originating-IP: [209.85.216.171] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 23195 invoked from network); 5 Oct 2017 17:42:44 -0000 Received: from mail-qt0-f171.google.com (HELO mail-qt0-f171.google.com) (209.85.216.171) by server-15.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 5 Oct 2017 17:42:44 -0000 Received: by mail-qt0-f171.google.com with SMTP id 6so17763545qtw.3 for ; Thu, 05 Oct 2017 10:42:44 -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=d2kE24x2vf0JOzLRTOH+fkKVQqrRBqlbbMc/3YR6ecI=; b=Hf5a63SdlxV+7EE/+oifLbrhuwZ7I6vxLLDR8cZIpkIJrzSeNPt6p8+d9X1bhP1Spp Rcwgub7S1CcfScdpwm36Tq6TI64HoeHsleXKTrVQZcEKTPVPzdPPsLGRd4oEsAwxxFry YniM6uFIbhZja0VTuYhzoqqoDVkwjXtj6jaes= 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=d2kE24x2vf0JOzLRTOH+fkKVQqrRBqlbbMc/3YR6ecI=; b=OrMaXkp36uJOdAfyPk7W0vFOX2WW4/kmJqlz+4RwGMhpzPEGKkMQStEVswV26nbXBH 2q84Sfmwr6MfnYluEytT5MWgo2exkH0hXtDqkfSUnIVdkZg9kutb4jcEHYj+RFfQumw8 CNLJsL8DatbkJOVfgPHALyaPTK4BBbXNVe49aqw20QgEE5CpqUM9ynTwSZUBgzT/x8Xv WF2K6+SHVBZlNTHGNdubE9DnwSL45Tc9WeRtxXaWrQOUSVPdwm2qcDzSRTBh2/BLtGnU k7WO2OoCUTv1dJw/Nu/LxG0mZ3kFhcCE65+VqrD3OW31DxT1pO6hu9fv9lp+GScKFvcD iatA== X-Gm-Message-State: AMCzsaVyjhBvt2J0qxHRr5HELpW4L9uTnFlmS7Ko0RiY9aZQm5MvF08N C0GWORr793DmQ4lJ1s2bOnlStcGG8gs= X-Google-Smtp-Source: AOwi7QCsmInVshWFi1F3uHHmiPUX+Kkt1NnoxUg+2GdtgJwDfda+0yz3hFIzc9aNs26yNd/PjNY1Ug== X-Received: by 10.237.44.194 with SMTP id g60mr26641009qtd.92.1507225362903; Thu, 05 Oct 2017 10:42:42 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id y63sm11815084qky.75.2017.10.05.10.42.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Oct 2017 10:42:42 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 5 Oct 2017 18:42:22 +0100 Message-Id: <20171005174222.29161-10-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171005174222.29161-1-julien.grall@linaro.org> References: <20171005174222.29161-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 v2 9/9] 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 Acked-by: Razvan Cojocaru Reviewed-by: Boris Ostrovsky Reviewed-by: Kevin Tian --- 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 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 | 8 +------- 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/hvm.c | 14 +++++++------- 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/mm.c | 2 +- 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 | 2 +- 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, 161 insertions(+), 234 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 167711b4fa..a6b471e2f6 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 9c183f96da..f391938640 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 9a37f29ce6..ebce2320ec 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 @@ -1286,7 +1286,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 0410b1e86b..1e7a0c6c40 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)); + 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 fd2fcacc26..376e80b6c7 100644 --- a/xen/arch/x86/cpu/vpmu.c +++ b/xen/arch/x86/cpu/vpmu.c @@ -657,7 +657,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) ) @@ -679,7 +679,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 bb1ffa3222..395ef6145a 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); } @@ -1114,7 +1115,7 @@ int arch_set_info_guest( l4_pgentry_t *l4tab; l4tab = map_domain_page(_mfn(pagetable_get_pfn(v->arch.guest_table))); - *l4tab = l4e_from_pfn(page_to_mfn(cr3_page), + *l4tab = l4e_from_pfn(mfn_x(page_to_mfn(cr3_page)), _PAGE_PRESENT|_PAGE_RW|_PAGE_USER|_PAGE_ACCESSED); unmap_domain_page(l4tab); } @@ -1941,7 +1942,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 540ba089d7..9292ae5118 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 9cf53b551c..1a83f27c0b 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 e8f746c70b..7789f6e571 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/hvm.c b/xen/arch/x86/hvm/hvm.c index 205b4cb685..dc7a018d1d 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); } @@ -3201,7 +3201,7 @@ 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)); + 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 f2e0b3f74a..5bd5cd788e 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 f62fe7e217..471d224539 100644 --- a/xen/arch/x86/hvm/vmx/vmcs.c +++ b/xen/arch/x86/hvm/vmx/vmcs.c @@ -1441,7 +1441,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 9cfa9b6965..40b91933bf 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -2951,7 +2951,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; @@ -2960,10 +2960,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; @@ -2974,7 +2974,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 cd0ee0a307..35f7cde81a 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 ) @@ -1704,7 +1704,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 { @@ -1790,7 +1790,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 d9df5ca69f..39038723ce 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -129,12 +129,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 dc85e828cd..e45c1a1913 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 054827aa88..24de202a1b 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 3fbc537da6..2194b35bc7 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 0eb409758f..ba950af4a8 100644 --- a/xen/arch/x86/physdev.c +++ b/xen/arch/x86/physdev.c @@ -241,7 +241,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 dcbee43e8f..e9a893ba47 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -22,6 +22,12 @@ #include "mm.h" +/* 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 90d5569be1..4ca3205821 100644 --- a/xen/arch/x86/pv/domain.c +++ b/xen/arch/x86/pv/domain.c @@ -16,12 +16,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 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 dd90713acf..9ccbd021ef 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/mm.c b/xen/arch/x86/pv/mm.c index e45d628deb..bdb09bfa75 100644 --- a/xen/arch/x86/pv/mm.c +++ b/xen/arch/x86/pv/mm.c @@ -169,7 +169,7 @@ void init_guest_l4_table(l4_pgentry_t l4tab[], const struct domain *d, BUILD_BUG_ON(root_pgt_pv_xen_slots != ROOT_PAGETABLE_PV_XEN_SLOTS); #endif l4tab[l4_table_offset(LINEAR_PT_VIRT_START)] = - l4e_from_pfn(domain_page_map_to_mfn(l4tab), __PAGE_HYPERVISOR_RW); + l4e_from_mfn(domain_page_map_to_mfn(l4tab), __PAGE_HYPERVISOR_RW); l4tab[l4_table_offset(PERDOMAIN_VIRT_START)] = l4e_from_page(d->arch.perdomain_l3_pg, __PAGE_HYPERVISOR_RW); if ( zap_ro_mpt || is_pv_32bit_domain(d) ) 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 3ca716c59f..663966bc74 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..b85394d1f9 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -811,7 +811,7 @@ 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); + gmfn, page ? mfn_x(page_to_mfn(page)) : -1UL, base); return 0; } diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index 11746730b4..971ccfcbbe 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 6d20b17739..2afde596d9 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 472c6fe329..5e7d74e274 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 c955cf7167..1adb96f00c 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 f2e0f498c4..984f54c3fa 100644 --- a/xen/include/asm-x86/mm.h +++ b/xen/include/asm-x86/mm.h @@ -259,7 +259,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))) @@ -369,7 +369,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)) ) { @@ -463,10 +463,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 70f00c332f..18eac537c9 100644 --- a/xen/include/asm-x86/p2m.h +++ b/xen/include/asm-x86/p2m.h @@ -480,7 +480,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;