From patchwork Tue Apr 3 15:32:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 132763 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp3954189ljb; Tue, 3 Apr 2018 08:35:20 -0700 (PDT) X-Google-Smtp-Source: AIpwx48K5L4W8ibyZI8eIxREIf/ZSBm66bY4ijAGQ4smgjF+SOhvmQR0n6GUjXkC1tyOVmJzjbaU X-Received: by 2002:a24:5151:: with SMTP id s78-v6mr5531604ita.103.1522769720075; Tue, 03 Apr 2018 08:35:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522769720; cv=none; d=google.com; s=arc-20160816; b=UnNtPjciwI58Ke/evvtKcGuPJbptZY8sADgLUCbkfUN0IwgG0Gd9yUXqny5tW+rarH nK9TBjvJ5q7TVs84iUn5qDPKeSfFelMpmw50BpBVYC0QTQjt4LSP+BxuvMH3UsyfDAlg Igj+dY8CKfopf6aVhM5C3GJN62ZvH7gyprL0cIt/2kj7fAC2kqMZnZl0EP3pmWlrYRH7 s8ihKLbAo+540L6f8Y9w3/c+cwAPEN6p3hs+6JbRrmhkPX8ZAg0PIW3X0LDwTXkXiotv 2ZDBeKTKD9eYLMCeHOG81RiaOAQEtWNNOCUxF7nrhO1A2ttpuu+t6rWq9hIfXJFBC1wM en1Q== 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:cc :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:references:in-reply-to:message-id:date:to:from :arc-authentication-results; bh=J8iteA1Jfgxm1XEuLmfF5dtZYb46HBOS1DYhqSIrADs=; b=Ujwbv4d2VAvqg1YXOWitwdPozpXGbfLfdsYbW/mSPUAMufDAJ8Y6colxhjYr00m/Jd MSGdqu0maGSfltS1+PTBoLyb8qLyJ8R49PdKCYzARGKmtIc4GGA3lOx4qjAAwmNxoftl f08uwnez6jZURBFdHRJvgawVXcBt1myErs1yxDvOvi5df3hqne3SlPxdYpFL3nmDx4Mt P8cweq1VmoaFe509PDeasdQEM+KlQGt+OfLpry1gV6D5R4u03g8+oFYYfsoFz0jZsJJf l1BnDgOkpIygV1fltgs2mKTYlRyT7n1/cGyvTYbZYn/cqCzvx7mnrGK3jeO7ab0rRnEE 7dZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id d12-v6si2287664itj.71.2018.04.03.08.35.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Apr 2018 08:35:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1f3Nvl-0007mX-T1; Tue, 03 Apr 2018 15:33:05 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1f3Nvl-0007mR-2l for xen-devel@lists.xen.org; Tue, 03 Apr 2018 15:33:05 +0000 X-Inumbo-ID: 768ef89b-3754-11e8-8249-2fda3a446a53 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas1.inumbo.com (Halon) with ESMTP id 768ef89b-3754-11e8-8249-2fda3a446a53; Tue, 03 Apr 2018 15:34:14 +0000 (UTC) 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 3D3A61596; Tue, 3 Apr 2018 08:33:03 -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 2FB063F24A; Tue, 3 Apr 2018 08:33:02 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 3 Apr 2018 16:32:36 +0100 Message-Id: <20180403153251.19595-2-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180403153251.19595-1-julien.grall@arm.com> References: <20180403153251.19595-1-julien.grall@arm.com> Subject: [Xen-devel] [for-4.11][PATCH v7 01/16] x86/mm: skip incrementing mfn if it is not a valid mfn X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Julien Grall , Wei Liu , Jan Beulich MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu In a follow-up patch, some callers will be switched to pass INVALID_MFN instead of zero for non-present mappings. So skip incrementing mfn if it is not a valid one. Signed-off-by: Wei Liu Signed-off-by: Julien Grall [Rework the commit message] Reviewed-by: Jan Beulich --- Cc: Jan Beulich Cc: Andrew Cooper Changes in v7: - Add Jan's reviewed-by - Fix typo in the commit message Changes in v6: - Update commit message Changes in v5: - Patch added --- xen/arch/x86/mm.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 17558e0c8c..3aed94bda5 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -4725,7 +4725,8 @@ int map_pages_to_xen( } virt += 1UL << L3_PAGETABLE_SHIFT; - mfn += 1UL << (L3_PAGETABLE_SHIFT - PAGE_SHIFT); + if ( !mfn_eq(_mfn(mfn), INVALID_MFN) ) + mfn += 1UL << (L3_PAGETABLE_SHIFT - PAGE_SHIFT); nr_mfns -= 1UL << (L3_PAGETABLE_SHIFT - PAGE_SHIFT); continue; } @@ -4750,7 +4751,8 @@ int map_pages_to_xen( if ( i > nr_mfns ) i = nr_mfns; virt += i << PAGE_SHIFT; - mfn += i; + if ( !mfn_eq(_mfn(mfn), INVALID_MFN) ) + mfn += i; nr_mfns -= i; continue; } @@ -4818,7 +4820,8 @@ int map_pages_to_xen( } virt += 1UL << L2_PAGETABLE_SHIFT; - mfn += 1UL << PAGETABLE_ORDER; + if ( !mfn_eq(_mfn(mfn), INVALID_MFN) ) + mfn += 1UL << PAGETABLE_ORDER; nr_mfns -= 1UL << PAGETABLE_ORDER; } else @@ -4847,7 +4850,8 @@ int map_pages_to_xen( if ( i > nr_mfns ) i = nr_mfns; virt += i << L1_PAGETABLE_SHIFT; - mfn += i; + if ( !mfn_eq(_mfn(mfn), INVALID_MFN) ) + mfn += i; nr_mfns -= i; goto check_l3; } @@ -4892,7 +4896,8 @@ int map_pages_to_xen( } virt += 1UL << L1_PAGETABLE_SHIFT; - mfn += 1UL; + if ( !mfn_eq(_mfn(mfn), INVALID_MFN) ) + mfn += 1UL; nr_mfns -= 1UL; if ( (flags == PAGE_HYPERVISOR) &&