From patchwork Tue Apr 3 15:32:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 132766 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp3954290ljb; Tue, 3 Apr 2018 08:35:26 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/ZyEbdrqMwjhPa+hTjDe4kx2eru1V1fMa93E3NhGMeE1BDCfU/7uCAt4nXH9nj80NakMIm X-Received: by 2002:a24:4fc2:: with SMTP id c185-v6mr1383203itb.34.1522769726124; Tue, 03 Apr 2018 08:35:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522769726; cv=none; d=google.com; s=arc-20160816; b=pWY/DquxPBXPlmeu2wpiTTEIrnulXWoZzmhD0+cN5hpSA2jujRbk8OVvoN38ONYvH0 bsQI639uKBOlu6tw5szI0mrCws7pRDQY04ZmtkZYm277cHlrE8UXKogIJcDTNVraUNSn vgpo7AsCj2N59R4wWXhpRFZ+2L91scupShXQBzQnIML7CamIXEiz589XJxV4BsXh/rJ4 Afr2UmSOkGb3C/D9mSEEIctVXQDnGSeaoux37/IP4W/TYSBOcZYKLT3ekl/UI2crqkCs iF3V8ZeQUBvbVdzl65nHCVl2kSEScZHOFZ9HCzKj81G5q+1xfqKhIViO+yNhZgHY1TEJ SvYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:references:in-reply-to:message-id:date:to:from :arc-authentication-results; bh=t7/nX8fEypv4gDvupUC0S9DMCuMKHL9MMXSlk/QRjug=; b=RsASnwnofwY+C8j5f2nyxi52RyvWFx/1ktdCVg2NXx8YYIyy4a9l3uhgi/rMzNYz6f kmgzfC5BIqhp30v0V8etzLSjqnfb19DqsHVeG1gDedmbxbsdG7TTUYf7HfxiD5XCZ5H5 ClzQcHO1G8o3/Kh/uCg2dwiIPkfjIintNrazk8p4c7Yy7YdEqSL6z37AsWiIDOPXh9AP 9gC4zifHbvgOQSQQrNNpOa9sIohsK4feoudOBs8POtf+FNXZh+4WsHVFjyioXQaue71L +4z6Fw6wQRXJkaGCtEtb5J6h9iG4pvLW3nUsNJ5D02dSaYwKtdFUI2Ejz9lmmG1zuxzL qUxA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id k185si2038156iok.258.2018.04.03.08.35.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Apr 2018 08:35:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1f3Nvs-0007rJ-Up; Tue, 03 Apr 2018 15:33:12 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1f3Nvr-0007qK-Ot for xen-devel@lists.xen.org; Tue, 03 Apr 2018 15:33:11 +0000 X-Inumbo-ID: 7aeb825d-3754-11e8-8249-2fda3a446a53 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas1.inumbo.com (Halon) with ESMTP id 7aeb825d-3754-11e8-8249-2fda3a446a53; Tue, 03 Apr 2018 15:34:21 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8375B1596; Tue, 3 Apr 2018 08:33:10 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 995E73F24A; Tue, 3 Apr 2018 08:33:09 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 3 Apr 2018 16:32:42 +0100 Message-Id: <20180403153251.19595-8-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180403153251.19595-1-julien.grall@arm.com> References: <20180403153251.19595-1-julien.grall@arm.com> Subject: [Xen-devel] [for-4.11][PATCH v7 07/16] xen/x86: mm: Switch x86/mm.c to use typesafe for virt_to_mfn X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Julien Grall , Jan Beulich MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" No functional change intended. While we are here, use PFN_DOWN() rather than open coding it. Signed-off Julien Grall Acked-by: Jan Beulich --- Cc: Jan Beulich Cc: Andrew Cooper Changes in v6: - Add George's reviewed-by - Add a word about using PFN_DOWN in the commit message Changes in v5: - Add Jan's acked-by - Use PFN_DOWN Changes in v4: - Patch added --- xen/arch/x86/mm.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 3aed94bda5..605f4377fa 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -135,6 +135,8 @@ #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)) +#undef virt_to_mfn +#define virt_to_mfn(v) _mfn(__virt_to_mfn(v)) /* Mapping of the fixmap space needed early. */ l1_pgentry_t __section(".bss.page_aligned") __aligned(PAGE_SIZE) @@ -379,7 +381,7 @@ void __init arch_init_memory(void) l3tab[i] = l3idle[i]; for ( ; i < L3_PAGETABLE_ENTRIES; ++i ) l3tab[i] = l3e_empty(); - split_l4e = l4e_from_pfn(virt_to_mfn(l3tab), + split_l4e = l4e_from_mfn(virt_to_mfn(l3tab), __PAGE_HYPERVISOR_RW); } else @@ -4149,7 +4151,7 @@ int xenmem_add_to_physmap_one( { case XENMAPSPACE_shared_info: if ( idx == 0 ) - mfn = _mfn(virt_to_mfn(d->shared_info)); + mfn = virt_to_mfn(d->shared_info); break; case XENMAPSPACE_grant_table: rc = gnttab_map_frame(d, idx, gpfn, &mfn); @@ -4775,7 +4777,7 @@ int map_pages_to_xen( if ( (l3e_get_flags(*pl3e) & _PAGE_PRESENT) && (l3e_get_flags(*pl3e) & _PAGE_PSE) ) { - l3e_write_atomic(pl3e, l3e_from_pfn(virt_to_mfn(pl2e), + l3e_write_atomic(pl3e, l3e_from_mfn(virt_to_mfn(pl2e), __PAGE_HYPERVISOR)); pl2e = NULL; } @@ -4873,7 +4875,7 @@ int map_pages_to_xen( if ( (l2e_get_flags(*pl2e) & _PAGE_PRESENT) && (l2e_get_flags(*pl2e) & _PAGE_PSE) ) { - l2e_write_atomic(pl2e, l2e_from_pfn(virt_to_mfn(pl1e), + l2e_write_atomic(pl2e, l2e_from_mfn(virt_to_mfn(pl1e), __PAGE_HYPERVISOR)); pl1e = NULL; } @@ -5082,7 +5084,7 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) if ( (l3e_get_flags(*pl3e) & _PAGE_PRESENT) && (l3e_get_flags(*pl3e) & _PAGE_PSE) ) { - l3e_write_atomic(pl3e, l3e_from_pfn(virt_to_mfn(pl2e), + l3e_write_atomic(pl3e, l3e_from_mfn(virt_to_mfn(pl2e), __PAGE_HYPERVISOR)); pl2e = NULL; } @@ -5136,7 +5138,7 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) if ( (l2e_get_flags(*pl2e) & _PAGE_PRESENT) && (l2e_get_flags(*pl2e) & _PAGE_PSE) ) { - l2e_write_atomic(pl2e, l2e_from_pfn(virt_to_mfn(pl1e), + l2e_write_atomic(pl2e, l2e_from_mfn(virt_to_mfn(pl1e), __PAGE_HYPERVISOR)); pl1e = NULL; } @@ -5540,8 +5542,7 @@ static void __memguard_change_range(void *p, unsigned long l, int guard) if ( guard ) flags &= ~_PAGE_PRESENT; - map_pages_to_xen( - _p, virt_to_maddr(p) >> PAGE_SHIFT, _l >> PAGE_SHIFT, flags); + map_pages_to_xen(_p, mfn_x(virt_to_mfn(p)), PFN_DOWN(_l), flags); } void memguard_guard_range(void *p, unsigned long l)