From patchwork Wed Mar 14 18:20:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 131713 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp157101ljb; Wed, 14 Mar 2018 11:22:40 -0700 (PDT) X-Google-Smtp-Source: AG47ELumcU5p5s6lfIkP/8OzGb8OB78xRYpNr7zWHwMVGhs7ASEt//4YT+WVwOntDuaxgxj252oi X-Received: by 10.107.5.199 with SMTP id 190mr6149674iof.107.1521051759920; Wed, 14 Mar 2018 11:22:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521051759; cv=none; d=google.com; s=arc-20160816; b=lumdKbpbJlGg+A+e6nbtEUPv6Q5NAlDeX/qW+3yD/2gMo4cgJauIHPAaBnK0vU7U91 xYz24EKQIsxA/tZe1JhWAXP0VyIMOfCIuK8wO3MMlwhlXz5+NpNokBNxT0BO174UHZkZ IxUwS06Xu5co2dIwPzjKVqKtgEuMgvOgII8a9kyIQ2ndO5RE0OslRgrEvXyV81SQvzX/ b2vmy1BcpwWz+YH88QG1bchQw/BLVvmgcCC3Pe0ZqcsfMKS1M+poaSRQYZj1ufNOinOx V3avdv9YAngQl7J9VCOHMiS5S3xMIeAMVg3YyX65ZTb8VGS2c0C/F4JTdDRCoRuAKp7Y 63Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=KYENDiaiYvxnCTJUoTlXfDJ8BNNS+rppRGFaHPBaw4I=; b=B7Kfk9vfoxCnhSuf/HkQMBZk8k4zdoT1sPRSnE8gxZpNFNbfywqIHmjOnaR7Km53wk gIN5tlrUo66lp/9c9E0w9T95cSHqjWOk4cyKwA59kMWXlTrkgEsMuO+D6A+bUtnjHXHI JvnWfeVYirXMPVLYiCxgJmB4/nPP/6pGHpZh6X0rinnpvpZhl+dngOGrcFNNP5WBzrjp XeLnE/TJsFoXJq0BnGcJAHPEX48j5C+7wCPlwlVV2+FVcsRvzlafwRWQnfKs7paCfrSn 8bm4l66ytlynyTEzUGZ031SvEPq1JreEghSvaNWcIHVtvIGZ18I9Jt+ghvR2kt8waLmy pRww== 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 e186si1189770itb.32.2018.03.14.11.22.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Mar 2018 11:22:39 -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.84_2) (envelope-from ) id 1ewB0r-0006uN-Nk; Wed, 14 Mar 2018 18:20:33 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ewB0p-0006nR-R9 for xen-devel@lists.xen.org; Wed, 14 Mar 2018 18:20:31 +0000 X-Inumbo-ID: 61fb0d47-27b4-11e8-8248-2fda3a446a53 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas1.inumbo.com (Halon) with ESMTP id 61fb0d47-27b4-11e8-8248-2fda3a446a53; Wed, 14 Mar 2018 18:20:32 +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 601FF80D; Wed, 14 Mar 2018 11:20:25 -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 74E833F53D; Wed, 14 Mar 2018 11:20:24 -0700 (PDT) From: julien.grall@arm.com To: xen-devel@lists.xen.org Date: Wed, 14 Mar 2018 18:20:00 +0000 Message-Id: <20180314182009.14274-8-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180314182009.14274-1-julien.grall@arm.com> References: <20180314182009.14274-1-julien.grall@arm.com> Cc: Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v5 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.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.xenproject.org Sender: "Xen-devel" From: Julien Grall No functional change intended. Signed-off Julien Grall Acked-by: Jan Beulich Reviewed-by: George Dunlap --- Cc: Jan Beulich Cc: Andrew Cooper 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 5f5577c7c2..ab10f552ea 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) @@ -380,7 +382,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 @@ -4155,7 +4157,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); @@ -4781,7 +4783,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; } @@ -4879,7 +4881,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; } @@ -5088,7 +5090,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; } @@ -5142,7 +5144,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; } @@ -5546,8 +5548,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)