From patchwork Mon Oct 2 12:59:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 114606 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp653853qgn; Mon, 2 Oct 2017 06:02:09 -0700 (PDT) X-Google-Smtp-Source: AOwi7QChVLJTZOJ7Dcz1K6UFnBi5qpgCwvti0C5jXwHtyqeD0Kt6k8U6H9RwJcGcmIEIWE3k71Nb X-Received: by 10.107.132.204 with SMTP id o73mr23199680ioi.89.1506949329847; Mon, 02 Oct 2017 06:02:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506949329; cv=none; d=google.com; s=arc-20160816; b=m6rAVAxIqYloewdY2bI4bgGdBchJt2cd5fHKdsEboNfuRTFPp8qz/LttrxemX2/L2d a1yPLrhyMd/W1FBAfzJWKkD49wcjIFwOi/PnU2L+n4NXfK9B4iK/zfsmIBgtWCn6I8DP NAPh348/9cjRTvfs7SVNAqTCeZjIzKudi5ukWCgHMvwdlwpL9xo9o6dPeiqB2snv7KfY W4lAIN4GbUI21AVrPDfbe3/u1CSA4dgd5o2tRS+pT4JEU2jp4H1JqyXY8LoEXmwnusOb q1NnUn+QYGgYTxUQ1Qbc9LX0PASBXGyPA0Psp46O/7HNTClwSL3U0r9wQr5btW84/HCf vzNg== 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=2lfdPwEPwr8Z9d0LI7FjztxCjhHMqRyuGAqwZ/IsnZA=; b=ezvfu4Z8gmYy6e+EDPadEM8uNX72mLwmfT2FzdB2gIpZx0Xl/F+BhIxnrRdsIRB81+ z0KO6jHmM7hbsrE/Rpj5i3ubYFqFWldF4YV91jA8m4wGxgNecJ+0H/BkF2mkTMejkI6O xvm6QCDKztHCLbW2iV/QMveu/Xgj7lTx9OH0R1OTHcrYSzke+78KLEoKMzzyrpxNzrLZ asAzj4LRxzMhYq+JM21wr89S6NKsmF+Jwb4cp86/4BFX1MZCx8LWSH5EpyUG3XpxJcCk PgmiLJfLKysXaX91bfibAGMf531DoQdXobwpJq2MuwAdF+CVIteDeAK8+4vaI8eo3M1x KmFg== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id w191si8911915ith.6.2017.10.02.06.02.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Oct 2017 06:02:09 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.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 1dz0KY-0004QR-4K; Mon, 02 Oct 2017 13:00:18 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz0KX-0004OI-3l for xen-devel@lists.xen.org; Mon, 02 Oct 2017 13:00:17 +0000 Received: from [193.109.254.147] by server-9.bemta-6.messagelabs.com id FD/20-03422-06832D95; Mon, 02 Oct 2017 13:00:16 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrJLMWRWlGSWpSXmKPExsVysyfVTdfX4lK kwY4rlhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa0bzh+esBSdFKloOzGZsYNzG38XIxSEksJlR Ysmsm0wQzmlGiV1tB4EcTg42AU2JO58/gdkiAtIS1z5fZgQpYhZYzCjxeX8vM0hCWMBD4uL9P +xdjBwcLAKqEgsvuoGEeQUsJa5v3sMGYksIyAPNvMgKYnMKWEm8P/4RzBYCqjnePYlpAiP3Ak aGVYwaxalFZalFukZGeklFmekZJbmJmTm6hgZmermpxcWJ6ak5iUnFesn5uZsYgR5mAIIdjGv mBx5ilORgUhLlZTa8FCnEl5SfUpmRWJwRX1Sak1p8iFGGg0NJgjfFHCgnWJSanlqRlpkDDDWY tAQHj5II7wRToDRvcUFibnFmOkTqFKMxx49JV/4wcXTcvPuHSYglLz8vVUqc978ZUKkASGlGa R7cIFgMXGKUlRLmZQQ6TYinILUoN7MEVf4VozgHo5IwLxfIPTyZeSVw+14BncIEdMqcrgsgp5 QkIqSkGhinXD80/2zshHMuFwsmO0bE/phTmfyB42S16Zu/RZMUfmlsO6HtbmHoeXv5l8+9N/Y /Y2lVv3XZ69ZXqx054hsWnP5l17V/g9DaZp6773+qiVR292QIOUpHX0kqmVvG/nrujuNXqr7E OyScyig/UWO/5rOvq8wq6dNzVPZVBy9w/t+1RNMp4cwpJZbijERDLeai4kQAyyKw33wCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-4.tower-27.messagelabs.com!1506949197!118733057!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 35796 invoked from network); 2 Oct 2017 12:59:57 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-4.tower-27.messagelabs.com with SMTP; 2 Oct 2017 12:59:57 -0000 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 3CC4A164F; Mon, 2 Oct 2017 05:59:57 -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 2DE523F53D; Mon, 2 Oct 2017 05:59:56 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 2 Oct 2017 13:59:32 +0100 Message-Id: <20171002125941.11274-7-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171002125941.11274-1-julien.grall@arm.com> References: <20171002125941.11274-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v3 06/15] xen/x86: p2m-pod: Clean-up use of typesafe MFN X-BeenThere: xen-devel@lists.xen.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.xen.org Sender: "Xen-devel" Some unboxing/boxing can be avoided by using mfn_add(...) instead. Signed-off-by: Julien Grall Acked-by: Andrew Cooper Reviewed-by: George Dunlap Reviewed-by: Wei Liu --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper Changes in v3: - Add George's and Wei's reviewed-by Changes in v2: - Add Andrew's acked-by --- xen/arch/x86/mm/p2m-pod.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c index bcc87aee03..34f5239b6d 100644 --- a/xen/arch/x86/mm/p2m-pod.c +++ b/xen/arch/x86/mm/p2m-pod.c @@ -101,7 +101,7 @@ p2m_pod_cache_add(struct p2m_domain *p2m, * promise to provide zero pages. So we scrub pages before using. */ for ( i = 0; i < (1UL << order); i++ ) - clear_domain_page(_mfn(mfn_x(page_to_mfn(page)) + i)); + clear_domain_page(mfn_add(page_to_mfn(page), i)); /* First, take all pages off the domain list */ lock_page_alloc(p2m); @@ -743,7 +743,7 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn) mfn0 = mfn; type0 = type; } - else if ( type != type0 || mfn_x(mfn) != (mfn_x(mfn0) + i) ) + else if ( type != type0 || !mfn_eq(mfn, mfn_add(mfn0, i)) ) goto out; n = 1UL << min(cur_order, SUPERPAGE_ORDER + 0U); @@ -758,7 +758,7 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn) for ( i = 0; i < SUPERPAGE_PAGES; i++ ) { /* Quick zero-check */ - map = map_domain_page(_mfn(mfn_x(mfn0) + i)); + map = map_domain_page(mfn_add(mfn0, i)); for ( j = 0; j < 16; j++ ) if ( *(map + j) != 0 ) @@ -783,7 +783,7 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn) */ for ( i = 0; i < SUPERPAGE_PAGES; i++ ) { - mfn = _mfn(mfn_x(mfn0) + i); + mfn = mfn_add(mfn0, i); if ( (mfn_to_page(mfn)->count_info & PGC_count_mask) > 1 ) { reset = 1; @@ -794,7 +794,7 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn) /* Finally, do a full zero-check */ for ( i = 0; i < SUPERPAGE_PAGES; i++ ) { - map = map_domain_page(_mfn(mfn_x(mfn0) + i)); + map = map_domain_page(mfn_add(mfn0, i)); for ( j = 0; j < (PAGE_SIZE / sizeof(*map)); j++ ) if ( *(map+j) != 0 )