From patchwork Wed Mar 21 04:47:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 132181 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1696522ljb; Tue, 20 Mar 2018 21:50:16 -0700 (PDT) X-Google-Smtp-Source: AG47ELuxJ4xaGG67Sy3gnAUQx3Vosc1+QmlFdTHXsfibheeN0qxaT24YioheQUalConSECbHyLxO X-Received: by 2002:a24:6748:: with SMTP id u69-v6mr2479919itc.4.1521607816257; Tue, 20 Mar 2018 21:50:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521607816; cv=none; d=google.com; s=arc-20160816; b=P8EFnRPOFI07xtVf2iqsDFSf9sFAZ9mUwM4Jp1sX909Ug1B9LhnE2ugst+wXvwKFeY GzRPPbkpv9VrHtR6+53Fg5iqtBbnB4KE5u5ZKvTFkSpAcVP1N+UPX37C4Ui4FSBpXxmt 8L+PZf1e7nWnQXmLf4zqz++dsQyOyGkTMxz+8C8zu7hGs1sgEsVXc31WmKJlisonEiMN YOCye/cId4h3pQegXeTEny4aRaCArDQLr/V5U9xzYhyCJpcq7RhPSzm/h0VkEuHC7/gs 59M/A7yt5Z5XSdBW7DGAX9a7xUhvFY5J/S3E9Rge8nzHWc/rDXfH7QatC17g8RFEaB2i ASbA== 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=APYkDJEGaslFC9kAsnqRa9adnWCg1nQyR0JU49WIs4NxJ8c1bFaASCZPI4kTySJzAC A0pVfm1XjDsN7qluBsWl3BEnL4nUhHJLtkX4FtSRQC5CrRJXbH+HX+YKukECnxx4E94L VufQutGktcAclTdxbv0dyzUVurFCOh+nmwQmvwOsSu2++zzEMVDWIxl/LQhJYhvqpXoV t76RYEkJ94W4BnfgTdz9kRH02uPRXVIn7CE2gUl0Yq8oMUsXHJTi8sk5yS7KFFTC52B9 8jqVSN1XeNgyoH1iNmlOoTfinr68X9o6wk333YdHiIPNo49uNW+ZcbV+LMZnCsH1zhC3 xOeQ== 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 127si2392495ioy.8.2018.03.20.21.50.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Mar 2018 21:50:16 -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 1eyVfP-0006ok-GS; Wed, 21 Mar 2018 04:48:03 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1eyVfO-0006nx-2O for xen-devel@lists.xen.org; Wed, 21 Mar 2018 04:48:02 +0000 X-Inumbo-ID: 18ed83a9-2cc3-11e8-8248-2fda3a446a53 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas1.inumbo.com (Halon) with ESMTP id 18ed83a9-2cc3-11e8-8248-2fda3a446a53; Wed, 21 Mar 2018 04:48:28 +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 5A0F715BF; Tue, 20 Mar 2018 21:48:00 -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 6B61C3F487; Tue, 20 Mar 2018 21:47:59 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 21 Mar 2018 04:47:28 +0000 Message-Id: <20180321044737.20794-8-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180321044737.20794-1-julien.grall@arm.com> References: <20180321044737.20794-1-julien.grall@arm.com> Subject: [Xen-devel] [for-4.11][PATCH v6 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)