From patchwork Wed Sep 13 17:59:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 9951813 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2A5386038F for ; Wed, 13 Sep 2017 18:02:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D1B928C41 for ; Wed, 13 Sep 2017 18:02:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 11D2D28C4A; Wed, 13 Sep 2017 18:02:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B1A8928C41 for ; Wed, 13 Sep 2017 18:02:45 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsBxO-0007t0-Li; Wed, 13 Sep 2017 18:00:14 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsBxM-0007rU-Rn for xen-devel@lists.xen.org; Wed, 13 Sep 2017 18:00:12 +0000 Received: from [193.109.254.147] by server-2.bemta-6.messagelabs.com id 34/94-15060-C2279B95; Wed, 13 Sep 2017 18:00:12 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrBLMWRWlGSWpSXmKPExsVysyfVTVezaGe kQd9maYslHxezODB6HN39mymAMYo1My8pvyKBNePm18tMBfuFKv6c2svSwPiIt4uRi0NIYDOj xKVjNxghnNOMElOXLmbqYuTkYBPQlLjz+ROYLSIgLXHt82WwImaBxYwSn/f3MoMkhAVcJVZPm sIGYrMIqErc/74XLM4rYClx4NphdhBbQkBeYlfbRVYQm1PASmLm1wVAQzmAtllKnO6JmsDIvY CRYRWjenFqUVlqka6JXlJRZnpGSW5iZo6uoYGZXm5qcXFiempOYlKxXnJ+7iZGoH8ZgGAHY/d l/0OMkhxMSqK8e3V3RgrxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4JUoBMoJFqWmp1akZeYAAw0m LcHBoyTC+7YAKM1bXJCYW5yZDpE6xWjM8WPSlT9MHB037/5hEmLJy89LlRLnXQ9SKgBSmlGaB zcIFgGXGGWlhHkZgU4T4ilILcrNLEGVf8UozsGoJMz7DWQKT2ZeCdy+V0CnMAGdcub0DpBTSh IRUlINjJLi67zsJ80RMj4TNOtpyY8Z/q5rGl5WvPR7ePxSXV7Suyz72R8mXz3PtaWmx1R7t+H nU7Jrl6XUsL62dPNersLa/GjzTa5+k1mbMw/emZ1a7igg+9iQb9eyteHuV1NyVDdbyj0NS3g3 g2XTrcKNvEznIzbMc1X75soVsu3upMsFx6P8GA/GTVNiKc5INNRiLipOBAC0s28QewIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-12.tower-27.messagelabs.com!1505325609!115149528!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 27693 invoked from network); 13 Sep 2017 18:00:09 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-12.tower-27.messagelabs.com with SMTP; 13 Sep 2017 18:00:09 -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 B6AC81435; Wed, 13 Sep 2017 11:00:08 -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 A4F593F483; Wed, 13 Sep 2017 11:00:07 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 13 Sep 2017 18:59:44 +0100 Message-Id: <20170913175953.16942-7-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170913175953.16942-1-julien.grall@arm.com> References: <20170913175953.16942-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 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" X-Virus-Scanned: ClamAV using ClamSMTP Some unboxing/boxing can be avoided by using mfn_add(...) instead. Signed-off-by: Julien Grall --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper --- 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 )