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: 112464 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1226577qgf; Wed, 13 Sep 2017 11:02:22 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBDo95aYZVHfnrGPWHmChLKY6u5qzDJfShU2t7brg3H70PynVYb4v78rSgd9PD1vGpba7/W X-Received: by 10.107.47.11 with SMTP id j11mr15332100ioo.217.1505325742724; Wed, 13 Sep 2017 11:02:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505325742; cv=none; d=google.com; s=arc-20160816; b=KRfQFuaSJypdD0mFl6B4n2LNf4HwI7urE0xTcS3Wj5HrAdYsj/IR4ZnB0Gd4JNwK+9 VPgpiwJ/V4Nv2hi2N//Eg38Y/hdXi5zghdeb5w1PH2Vba6G+9dJ60jgP7Hau0rwrLlgF 34SsmOSJ6Psulstw1m/SHb8LcFS8JTuAGk8PZP/ZZO6DQfynuN/HIJCRsWpZC2OsvdR+ Amwa8DtChAGEvC1aF2VMrT7tHcym1d0Dto3QpnSaVEm2lFV9moWXX0ikkBUPcun3sA6E 6X8vIC6JM4D4ft1OUWxMlEaLjlChcNaGPwf9TTLc+6Ic9B9Megsy+l/xEoqwfA1JqSMN JU6g== 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=MYQJL4yYp/QQdVyNvCJPcX9/fwrlOxaqZVk4Cy9exIs=; b=pu/gmlPOBMl5yUjetVz0JDE6yAGXacIWPsoQzxzrlTjKcRzk3qw0Uyzxpej4rWaVwU mtojXNmKVfB2RYPs/XIWqPGwbMnX93kA2BFyJzQ+aGcORUsJ/IzKt96UActrTh0Yw5X4 uYEj+NEf2/elF6U0AAxTcAHu8fXEPCWClm+MC1GhCvtIR5S7JU/f5841DbAhgeLoKA9p O9xO0WIKfNlj1jSZxC2CkTMF7cMrrA1O/8ac2c6aTK6ISziKmQ8BuSdpTePaBOKFQJx7 a4RmvY2bleyV8DTzV5JZ0tIC62RCBfubejc1mexAvghq3jID+cb/+uq4d+cP2GYzlUZ+ 9LSQ== 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 m13si4978212iob.280.2017.09.13.11.02.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Sep 2017 11:02:22 -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 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" 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 )