From patchwork Mon Jun 3 16:03:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 165665 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4660586ili; Mon, 3 Jun 2019 09:05:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqzHvENd00CGlnm1h6i/ZTxV/qttir6F29c4JOM6l5ogOXT9DpD0hDfHmsGIocgg9Y4fIv9o X-Received: by 2002:a24:7cd8:: with SMTP id a207mr8488991itd.68.1559577933409; Mon, 03 Jun 2019 09:05:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559577933; cv=none; d=google.com; s=arc-20160816; b=FFreKVUn4ub0uP12VJadHhCS6BnzgcKSRTYrJqX7Glatnd8OZIlIR9Sjngh1906gL7 UAwZcJiqSUP9xYqc8e8hOLOkOi6GX2EwcX+XcKzjnccGbw+qC3faml/Uf15FDCcjEiMg 1E0l0aEtwwzyV+TGw4DMAAUOabWp2Prlbltd8HdS+/hWjO5KHYvqGslsA9p1CXpldvFG 9iFh1ZJJ3fGtpg31iQmQa6M5X8WLHpZnx84+8jvs4Gw3PyWZQPuIbkQfXiOUNF0NmFcr z/gLmhnputDEMfxUvXdl9ismR3iCFgkA4UyO9OP8dZ9JUCfBwXBPBnKstG9pLZ93STGo IRfg== 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; bh=FqW0tXfX40NoB53FUeOU+i8GYSkLn5dqY/2768yw0JU=; b=C5pNWO4XK30MPTwnFON+MedLJDr4MpDX5/zTcQoEacVREW4qVWH+Dg8KiAC4/tQFFA QrmoIAvBUuQsfmpRrykq6dZ34vF9FNVvYczRx3qyjfukgqQAnBJiAehJHJ5YCwlZtSol vZO+IrYPdXS0yHCBCPs4TQ7oLdXxp2aMig6UAOfhb6IVOfiNInnVa1yxClc8sqF0mpFo blo++FOdZ8bxjwOH2OVcZdHOiXnEbZfMTY3f4Phd57ldcqHB659v1ktexSga4ALmXg5X XiQs4ivxnHm+ogo55xLhhepV6ryq+kT3V47jABSTnB6ILZ4N69COsri7q0jxvo0IV2xY o1vQ== 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 x16si10283689jaq.80.2019.06.03.09.05.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 Jun 2019 09:05:33 -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 1hXpRU-0001zI-Rt; Mon, 03 Jun 2019 16:04:12 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hXpRU-0001yr-GW for xen-devel@lists.xenproject.org; Mon, 03 Jun 2019 16:04:12 +0000 X-Inumbo-ID: 39df92f4-8619-11e9-8980-bc764e045a96 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 39df92f4-8619-11e9-8980-bc764e045a96; Mon, 03 Jun 2019 16:04:11 +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 5C8A7A78; Mon, 3 Jun 2019 09:04:11 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 48CED3F246; Mon, 3 Jun 2019 09:04:09 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 3 Jun 2019 17:03:42 +0100 Message-Id: <20190603160350.29806-7-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190603160350.29806-1-julien.grall@arm.com> References: <20190603160350.29806-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH v3 06/14] xen: Convert is_xen_heap_mfn to use typesafe 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: Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , George Dunlap , Tim Deegan , Julien Grall , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" No functional changes. Signed-off-by: Julien Grall Reviewed-by: Jan Beulich Acked-by: Stefano Stabellini Reviewed-by: George Dunlap --- Changes in v3: - Add George's reviewed-by Changes in v2: - Fix coding style - Merge the declaration for gpfn and old_gpfn - Don't open-code mfn_valid - Add Jan's reviewed-by - Use mfn_add(mfn, -1) - Add Stefano's acked-by for ARM parts --- xen/arch/x86/mm.c | 10 +++++----- xen/arch/x86/mm/p2m.c | 2 +- xen/arch/x86/mm/shadow/multi.c | 2 +- xen/common/page_alloc.c | 4 ++-- xen/include/asm-arm/mm.h | 8 ++++---- xen/include/asm-x86/mm.h | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 2f620d9aeb..3d3d8bd7a8 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -4458,8 +4458,8 @@ int xenmem_add_to_physmap_one( gfn_t gpfn) { struct page_info *page = NULL; - unsigned long gfn = 0; /* gcc ... */ - unsigned long prev_mfn, old_gpfn; + unsigned long gfn = 0 /* gcc ... */, old_gpfn; + mfn_t prev_mfn; int rc = 0; mfn_t mfn = INVALID_MFN; p2m_type_t p2mt; @@ -4505,12 +4505,12 @@ int xenmem_add_to_physmap_one( } /* Remove previously mapped page if it was present. */ - prev_mfn = mfn_x(get_gfn(d, gfn_x(gpfn), &p2mt)); - if ( mfn_valid(_mfn(prev_mfn)) ) + prev_mfn = get_gfn(d, gfn_x(gpfn), &p2mt); + if ( mfn_valid(prev_mfn) ) { if ( is_xen_heap_mfn(prev_mfn) ) /* Xen heap frames are simply unhooked from this phys slot. */ - rc = guest_physmap_remove_page(d, gpfn, _mfn(prev_mfn), PAGE_ORDER_4K); + rc = guest_physmap_remove_page(d, gpfn, prev_mfn, PAGE_ORDER_4K); else /* Normal domain memory is freed, to avoid leaking memory. */ rc = guest_remove_page(d, gfn_x(gpfn)); diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index 279278715e..e03f0ae630 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -2970,7 +2970,7 @@ int p2m_add_foreign(struct domain *tdom, unsigned long fgfn, prev_mfn = get_gfn(tdom, gpfn, &p2mt_prev); if ( mfn_valid(prev_mfn) ) { - if ( is_xen_heap_mfn(mfn_x(prev_mfn)) ) + if ( is_xen_heap_mfn(prev_mfn) ) /* Xen heap frames are simply unhooked from this phys slot */ rc = guest_physmap_remove_page(tdom, _gfn(gpfn), prev_mfn, 0); else diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c index 74681ba85c..26798b317c 100644 --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -559,7 +559,7 @@ _sh_propagate(struct vcpu *v, * caching attributes in the shadows to match what was asked for. */ if ( (level == 1) && is_hvm_domain(d) && - !is_xen_heap_mfn(mfn_x(target_mfn)) ) + !is_xen_heap_mfn(target_mfn) ) { int type; diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 71e24dbb2d..04c9dc0c65 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -2104,9 +2104,9 @@ void init_xenheap_pages(paddr_t ps, paddr_t pe) * Yuk! Ensure there is a one-page buffer between Xen and Dom zones, to * prevent merging of power-of-two blocks across the zone boundary. */ - if ( ps && !is_xen_heap_mfn(paddr_to_pfn(ps)-1) ) + if ( ps && !is_xen_heap_mfn(mfn_add(maddr_to_mfn(ps), -1)) ) ps += PAGE_SIZE; - if ( !is_xen_heap_mfn(paddr_to_pfn(pe)) ) + if ( !is_xen_heap_mfn(maddr_to_mfn(pe)) ) pe -= PAGE_SIZE; memguard_guard_range(maddr_to_virt(ps), pe - ps); diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h index b56018aace..a9c8352b94 100644 --- a/xen/include/asm-arm/mm.h +++ b/xen/include/asm-arm/mm.h @@ -138,16 +138,16 @@ extern vaddr_t xenheap_virt_start; #endif #ifdef CONFIG_ARM_32 -#define is_xen_heap_page(page) is_xen_heap_mfn(mfn_x(page_to_mfn(page))) +#define is_xen_heap_page(page) is_xen_heap_mfn(page_to_mfn(page)) #define is_xen_heap_mfn(mfn) ({ \ - unsigned long mfn_ = (mfn); \ + unsigned long mfn_ = mfn_x(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) #define is_xen_heap_mfn(mfn) \ - (mfn_valid(_mfn(mfn)) && is_xen_heap_page(mfn_to_page(_mfn(mfn)))) + (mfn_valid(mfn) && is_xen_heap_page(mfn_to_page(mfn))) #endif #define is_xen_fixed_mfn(mfn) \ @@ -246,7 +246,7 @@ static inline paddr_t __virt_to_maddr(vaddr_t va) #ifdef CONFIG_ARM_32 static inline void *maddr_to_virt(paddr_t ma) { - ASSERT(is_xen_heap_mfn(ma >> PAGE_SHIFT)); + ASSERT(is_xen_heap_mfn(maddr_to_mfn(ma))); ma -= mfn_to_maddr(xenheap_mfn_start); return (void *)(unsigned long) ma + XENHEAP_VIRT_START; } diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h index 0d954e1bd8..e420d88137 100644 --- a/xen/include/asm-x86/mm.h +++ b/xen/include/asm-x86/mm.h @@ -278,7 +278,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)))) + (mfn_valid(mfn) && is_xen_heap_page(mfn_to_page(mfn))) #define is_xen_fixed_mfn(mfn) \ (((mfn_to_maddr(mfn)) >= __pa(&_stext)) && \ ((mfn_to_maddr(mfn)) <= __pa(&__2M_rwdata_end)))