From patchwork Thu Sep 21 12:40:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 113251 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp1846103edb; Thu, 21 Sep 2017 05:43:02 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBn8mvsRVh35cFrjd1MftuqQ8O3vWEE7ePsjFnKXvrB3JvlzDThpXj4WlCFTekS5E3T9XIy X-Received: by 10.107.139.215 with SMTP id n206mr2843136iod.155.1505997782431; Thu, 21 Sep 2017 05:43:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505997782; cv=none; d=google.com; s=arc-20160816; b=aLviISCW4ua9H9PKC0QV7rlPyxg/RPjbPoQQP0T11mgxMZY3qfyp9+RiJ3rwiDVoTj s9vDokzgaZQfZrDt/CmXwhKI4n4he+dGNhEKCjhTJXvAELmyQde4n25PNmIH/zLameLa ZzzfRFNiVf3MX+eq33zH8tJCh1ZYr0y4RZF6BNMBTFBAFYjjSGhBJe7EjGnn3GbimkZZ t9e8781Y86sDU/WvxNVAkdIrP3n3cLyHkYsVk//YlYsWHuLTGncw7qfR93dOfXnBI/KV Q1IFDHKSaV+07Vp3Cpz6gt+lapxXtumZeii3xnDfUG2fQrHUYjqpulEbenpaY2RRMeKE y2fQ== 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=tjFu/9hn6Tvny2ZWSd96qNYNS0oYu56Q40P5B/Wchw8=; b=0qFHtKmAHTeGs3bi+oyeQTK2pEaV/tRgilOlNyNB7ErGiN8uzIrZnBF4gjlII/8Nh5 4JSk/leb+1VIzSxughyr8haHZmCkT630FKKmTPS9xiAf6/xIqZQvikp+CnrcWebyZ/cS fqpBVpCmnEq6HJYuJAJslJr/QWS1e7ztBaBv6KmNJit5ZgrGWEsKyFif66BpLLNugUTK U6hT2BwKBGchJ0WirtLJ6IdjdSUBekeIMb3L4S7jknXDDLCW7ycnobhuFkh7TTdArC6L uk2szujyZF2LVzYYt/926vwM46j0KjNGuYV29lWiuKZGhBSpbSjpjlIP7zeHZqiRWgir V70g== 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 n63si1368626ite.79.2017.09.21.05.43.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Sep 2017 05:43:02 -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 1dv0ms-0001RP-VE; Thu, 21 Sep 2017 12:41:02 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dv0mr-0001PY-Sz for xen-devel@lists.xen.org; Thu, 21 Sep 2017 12:41:02 +0000 Received: from [85.158.137.68] by server-13.bemta-3.messagelabs.com id 66/8F-01916-D53B3C95; Thu, 21 Sep 2017 12:41:01 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrJLMWRWlGSWpSXmKPExsVysyfVTTd48+F Ig5afyhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa0bbrNvsBcuFK1ovP2FrYNzE18XIySEksJlR 4nJrchcjF5B9mlFi2qJjbCAJNgFNiTufPzGB2CIC0hLXPl9mBCliFljMKPF5fy8zSEJYwENiy +o3YDaLgKrE+rfLWUFsXgELidPL94DZEgLyErvaLoLZnAKWEm2Hv7FCbLaQ+DXhBOsERu4FjA yrGDWKU4vKUot0jUz0kooy0zNKchMzc3QNDYz1clOLixPTU3MSk4r1kvNzNzECPVzPwMC4g/H Vcb9DjJIcTEqivO/WHY4U4kvKT6nMSCzOiC8qzUktPsQow8GhJMHLuQkoJ1iUmp5akZaZAww1 mLQEB4+SCO+EjUBp3uKCxNzizHSI1ClGY44fk678YeLouHn3D5MQS15+XqqUOO9KkFIBkNKM0 jy4QbAYuMQoKyXMy8jAwCDEU5BalJtZgir/ilGcg1FJmDcW5B6ezLwSuH2vgE5hAjole8MBkF NKEhFSUg2M2qa8FtMv3z+9yzjIwPyIrL5PNjNXgezRQ5rbr1utXJtvMDf0eKauy9FOX2vnJ79 OxR8Rkdec0/joXETK5K2NztETyntP5ZdlRRkqmlzLeVYs1s5tl9Qgd1fmqyTn6lWRs29GnL64 WreOX+eHzFeHl2efSR5s7hGLkju4teBA0n5e5XOcZqxKLMUZiYZazEXFiQASMc1qfAIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-4.tower-31.messagelabs.com!1505997651!57810137!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 59579 invoked from network); 21 Sep 2017 12:40:51 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-4.tower-31.messagelabs.com with SMTP; 21 Sep 2017 12:40:51 -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 CF11D1529; Thu, 21 Sep 2017 05:40:50 -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 BEBCB3F58C; Thu, 21 Sep 2017 05:40:49 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 21 Sep 2017 13:40:25 +0100 Message-Id: <20170921124035.2410-7-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170921124035.2410-1-julien.grall@arm.com> References: <20170921124035.2410-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v2 06/16] 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: Wei Liu Reviewed-by: George Dunlap --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper 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 )