From patchwork Wed Feb 21 14:02:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 129063 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp662387ljc; Wed, 21 Feb 2018 06:05:51 -0800 (PST) X-Google-Smtp-Source: AH8x225VgeFu6iE/xO1WdgJ4ogL7AqkEzUy4nH4y+qakcaFO4nLIIAn5qDB0T6hzT2cCSGQWu5zX X-Received: by 10.200.23.176 with SMTP id o45mr5520155qtj.255.1519221951268; Wed, 21 Feb 2018 06:05:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519221951; cv=none; d=google.com; s=arc-20160816; b=tQTzNMy5e9jH5+Z+Lu0kYREWsZjon7wu3kVDGSfQsp3B3PUt5ktfvR5PLGXrrg9/cZ h233hVpYvQM7kl/bBeOPDVf1lWp5NKaQmWIYvzFlS5mtcrwQF42qFo9bB10rRqfTeO5N fc7ocea+gaKLUOjnDOpoNibYGsXGEAe9wk1Oy4EIjuF94oBxgZO0zEnbQ/hgDAQkv5jj qCSqONci+eWNTQAQ4z7eUn4fvLqdyCOBfcUs1xQM+CONhMup7hshzZHDM4xbpkbvlS30 Lcxd48wi5sCTEjgiZJpQ4KtFYoJCRQlyQEe6U09LINBGVeDgLiidcQdTkzDxKOdKQR0m Mfeg== 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=2wXENkLmb673jiRzXY6TYQcs9ImXgjnNNbySpuJt1wk=; b=dszodZg9H4+7gb6lKRq48xvIrrBUdQvuxHYtU1DH050QuqKlMyiP50VTLTqknzKqjC +dJ0A8DAYnNZ7ROiUPV4B4UEEeBkVbHxdXahMA09YfRqXSDd0TlHj2hws2jLDoSIKdVS DMR4jihNUuK2Dmzxw4g428g/k6Ao5e4wzGtCkqHHOupzLsbJTojj2foQViXFe0FWc+wR LpUWXyB3PVOh25m04ir8Xgb0xbOEEvJ/sXPO8xXVCGtkgsRbiyXmxIAivBPQ6untxO+u ykGNOgJY96gc/jrzELQJ1BDcAuBgVoIkIOMvNC5TpRGjM35S3ItLD+SYBqlxn80Up6Nu mFpA== 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 v49si5921921qtc.31.2018.02.21.06.05.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Feb 2018 06:05:51 -0800 (PST) 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 1eoUzY-0004QT-M2; Wed, 21 Feb 2018 14:03:28 +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 1eoUzX-0004Oo-6F for xen-devel@lists.xen.org; Wed, 21 Feb 2018 14:03:27 +0000 X-Inumbo-ID: 328ab17b-1710-11e8-b9b1-635ca7ef6cff Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas1.inumbo.com (Halon) with ESMTP id 328ab17b-1710-11e8-b9b1-635ca7ef6cff; Wed, 21 Feb 2018 14:04:57 +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 780841435; Wed, 21 Feb 2018 06:03:20 -0800 (PST) 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 8C15A3F318; Wed, 21 Feb 2018 06:03:19 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 21 Feb 2018 14:02:50 +0000 Message-Id: <20180221140259.29360-8-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180221140259.29360-1-julien.grall@arm.com> References: <20180221140259.29360-1-julien.grall@arm.com> Cc: Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v4 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" No functional change intended. Signed-off Julien Grall Acked-by: Jan Beulich --- Cc: Jan Beulich Cc: Andrew Cooper 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 e1f089be14..eba1afaa31 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 @@ -4159,7 +4161,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); @@ -4783,7 +4785,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; } @@ -5087,7 +5089,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; } @@ -5141,7 +5143,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; } @@ -5545,8 +5547,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)), _l >> PAGE_SHIFT, flags); } void memguard_guard_range(void *p, unsigned long l)