From patchwork Wed Mar 21 04:47:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 132188 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1696745ljb; Tue, 20 Mar 2018 21:50:35 -0700 (PDT) X-Google-Smtp-Source: AG47ELsXp64XIOJgTLxLo7jiubPWWziQjRRWuX7S+uHtmatwRvra2ZEhtSFTvpqWVk1Fvr8eSU9s X-Received: by 2002:a24:4a53:: with SMTP id k80-v6mr2693063itb.45.1521607835151; Tue, 20 Mar 2018 21:50:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521607835; cv=none; d=google.com; s=arc-20160816; b=Khdk+a9Kmful8iLC3WF7C9qTYT2Hx8m2LWscH6NW3+Yz4DhB2bCw/S1ihTllyvY3i2 LJZCPmlfpAYQ2Pr6p3n9mO2CD1c71LzGTqWIOeyGc+HYpQ4Bplg7st7DCbQyHVl6IzSz SBzyg6deKT/8gYTHT9dDenIZzi9b9qEEE805qH9DDhY3szYtIVm1f9T8YN+Tpp1e3y3B CAvyX9x5ZOARqtRueimTqMiw9VuFREfb25AkNqgkTDSGVKWkf7NOorERQydnl9bnWPTn b9+0JfwZ2Bh6GQjI+UHiXiLq2YBCrZS1BLAswT+M4kcvwRUhmtQ2H+ihvSBkZx5icoVu 9vYA== 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=eqKvmFqL1sHmjlrdaXa9om42XsdxyzKLwUrG6hZRaqA=; b=dhf0Yxb3dGUusfAJgRnxAS/KLuFmK0K9uXVuq+CIvDo9TNfoSWrmaeLYgM4W2wqEmD KkdfwE2as3CMqiL2QcezsnitkF1ZbiDWS5pmOgyXaxljQWKADVqEMSpmwS6vsPPTNrfK vCxqrsCTN6+DfjyMk5SVPr+F7U2xMkTDHu7Ks3JgOp42OCpR7FmtGJFWh5uLRKc2zOD2 U96R4urfsqxho+p1817zhli5diflKvLfkBVqWkTIRSi1wpVeWB3mMe7IOAC3iP4In2O0 7eLDModt4nfEkQtAx+KdY0tC8c+AG3cGVIfEiZzgxsb6Z1Sw1xV0M1c+WvkV4QGs8l8P NTVw== 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 d62-v6si223438itb.72.2018.03.20.21.50.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Mar 2018 21:50:35 -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 1eyVfH-0006mi-Ky; Wed, 21 Mar 2018 04:47:55 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1eyVfG-0006mO-8e for xen-devel@lists.xen.org; Wed, 21 Mar 2018 04:47:54 +0000 X-Inumbo-ID: 14bc471b-2cc3-11e8-8248-2fda3a446a53 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas1.inumbo.com (Halon) with ESMTP id 14bc471b-2cc3-11e8-8248-2fda3a446a53; Wed, 21 Mar 2018 04:48:21 +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 5820115B2; Tue, 20 Mar 2018 21:47:53 -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 4AC663F487; Tue, 20 Mar 2018 21:47:52 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 21 Mar 2018 04:47:22 +0000 Message-Id: <20180321044737.20794-2-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180321044737.20794-1-julien.grall@arm.com> References: <20180321044737.20794-1-julien.grall@arm.com> Subject: [Xen-devel] [for-4.11][PATCH v6 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 patches, 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 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) &&