From patchwork Mon Oct 2 12:59:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 9980813 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 A1B8B60365 for ; Mon, 2 Oct 2017 13:02:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94B58207A7 for ; Mon, 2 Oct 2017 13:02:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 897B3289C2; Mon, 2 Oct 2017 13:02:22 +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 873C8207A7 for ; Mon, 2 Oct 2017 13:02:21 +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 1dz0KR-0004GS-02; Mon, 02 Oct 2017 13:00:10 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz0KP-0004DW-Kv for xen-devel@lists.xen.org; Mon, 02 Oct 2017 13:00:09 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id D9/80-03093-85832D95; Mon, 02 Oct 2017 13:00:08 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTTfU4lK kwcsPkhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8brfbPYC17yVqyedJyxgXEaVxcjF4eQwGZG iR+TX7BAOKcZJaZ8msrUxcjJwSagKXHn8ycwW0RAWuLa58uMIEXMAosZJT7v72XuYuTgEBZwl 7j2ugikhkVAVWLBvweMIDavgJXEu1snwWwJAXmJXW0XWUFsTqD4++MfwWwhAUuJ492TmCYwci 9gZFjFqFGcWlSWWqRrbKyXVJSZnlGSm5iZo2toYKaXm1pcnJiempOYVKyXnJ+7iRHoYQYg2MG 4c33gIUZJDiYlUV5mw0uRQnxJ+SmVGYnFGfFFpTmpxYcYZTg4lCR4NcyBcoJFqempFWmZOcBQ g0lLcPAoifCagqR5iwsSc4sz0yFSpxh1OTpu3v3DJMSSl5+XKiXO+98MqEgApCijNA9uBCzsL zHKSgnzMgIdJcRTkFqUm1mCKv+KUZyDUUmY1wVkFU9mXgncpldARzABHTGn6wLIESWJCCmpBs Yrcmvmp/+ofDHVOeist6WG/4npEc+z1zlfYQ7oOWsm/+5ytPW14unBBx7UVK8Idr52oONdzuL I5cWl31+cv3XOONnioukXj33tn0/l18wV536w2CZ+3u3Mo9MWFxd5MrJ91CyI1d49f9rtWfwf TnxPlra4MbMpzqF0jdGCdjWhH2J7GTyl1skrsRRnJBpqMRcVJwIAxfxDVnYCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-3.tower-21.messagelabs.com!1506949204!82141557!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 57315 invoked from network); 2 Oct 2017 13:00:05 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-3.tower-21.messagelabs.com with SMTP; 2 Oct 2017 13:00:05 -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 B218A1682; Mon, 2 Oct 2017 06:00:04 -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 A30723F53D; Mon, 2 Oct 2017 06:00:03 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 2 Oct 2017 13:59:37 +0100 Message-Id: <20171002125941.11274-12-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 11/15] xen/x86: p2m-pod: Clean-up p2m_pod_zero_check 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 Signed-off-by: Julien Grall Acked-by: Andrew Cooper Reviewed-by: George Dunlap --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper Changes in v3: - Replace (foo == 0) by !foo - Remove uneeded parentheses Changes in v2: - Add Andrew's acked-by --- xen/arch/x86/mm/p2m-pod.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c index 176d06cb42..6581f8d82f 100644 --- a/xen/arch/x86/mm/p2m-pod.c +++ b/xen/arch/x86/mm/p2m-pod.c @@ -861,17 +861,19 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long *gfns, int count) for ( i = 0; i < count; i++ ) { p2m_access_t a; + struct page_info *pg; mfns[i] = p2m->get_entry(p2m, _gfn(gfns[i]), types + i, &a, 0, NULL, NULL); + pg = mfn_to_page(mfns[i]); + /* * If this is ram, and not a pagetable or from the xen heap, and * probably not mapped elsewhere, map it; otherwise, skip. */ - if ( p2m_is_ram(types[i]) - && ( (mfn_to_page(mfns[i])->count_info & PGC_allocated) != 0 ) - && ( (mfn_to_page(mfns[i])->count_info & (PGC_page_table|PGC_xen_heap)) == 0 ) - && ( (mfn_to_page(mfns[i])->count_info & PGC_count_mask) <= max_ref ) ) + if ( p2m_is_ram(types[i]) && (pg->count_info & PGC_allocated) && + !(pg->count_info & (PGC_page_table | PGC_xen_heap)) && + ((pg->count_info & PGC_count_mask) <= max_ref) ) map[i] = map_domain_page(mfns[i]); else map[i] = NULL;