From patchwork Tue May 14 12:31:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 164194 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp2561734ili; Tue, 14 May 2019 05:32:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqz/nhcmiOVsptLpPtnE7RGTlP4jPYZO8Hsh1ZoVLj3IxTq7IdISmOF6tHdVHK0KCAKa8+se X-Received: by 2002:a24:edc6:: with SMTP id r189mr3695795ith.158.1557837154970; Tue, 14 May 2019 05:32:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557837154; cv=none; d=google.com; s=arc-20160816; b=eleij6U9O4yBeY2fqQ/xU0Ro0aoKoaGWUHqhMbxd5XarsJUAx87bg/UWs3ZbzP8QpI xc5Sg103XUY2YUvMdxIApVFGlSLHBSKEb3/TKDLyeyIx5WI6WCBJ5CFC7vcXnXkBGdh2 gSfUtmAxS8MYhjQaHTrP/06eYPOP/6XzlqtRa7C2FLd6PmbdzsGbMYDdesCjOnqq2k4h 7pC3NSibL2mTlD8b06dS2okasQQlFCo/krSTek6iozdSO0VqN68vXYaLt9IMeVJAqJ96 SNOSdBLaortaCf0aAxkDfoZD0TXE9zBewDSwdwQUjACRZpJu6tEELxG5aHMj2AR/yYEv rzEw== 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; bh=C4BrL4lMuSUFy2yyQfrathgWRBWylzhjV7bD6DZgLuY=; b=mmjonJ8S4smDW7px8lQ/IiYMi+KA9F97Cq8hOu09BKsuS6edXRZw98CMaoayTHGnYV siRNEc/p3u1oM16ouc0wvztGzVMAGUmdXKgC6fWJhO9gazxVZAfYNPQvzbbwQCfgqHG8 QOpaMPL2f6RfRGpheIjMbjDn5xpbta3DMrJ123xJ0TsmkFhUrR5CvycKLyMYu6bZhHG+ PasBbMTG8vzAWWbRbKixWswUXD/pemHqPw3WoRVH5ihfkv5vvCnkvyRu5PC9YiFJ2Q0O tMDyHEzQ7eQ9AL7jEwHnFQlo7DGrWdokR4PqQPFpahLehe6GDH1U6a9Yym9MrFYln6fR LcFw== 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 r128si8906185ior.24.2019.05.14.05.32.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 May 2019 05:32:34 -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 1hQWap-0005MA-9c; Tue, 14 May 2019 12:31:39 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hQWao-0005Le-0o for xen-devel@lists.xenproject.org; Tue, 14 May 2019 12:31:38 +0000 X-Inumbo-ID: 377b0a74-7644-11e9-8980-bc764e045a96 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 377b0a74-7644-11e9-8980-bc764e045a96; Tue, 14 May 2019 12:31:37 +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 1FBEB15AB; Tue, 14 May 2019 05:31:37 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E08DF3F71E; Tue, 14 May 2019 05:31:35 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 14 May 2019 13:31:17 +0100 Message-Id: <20190514123125.29086-5-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190514123125.29086-1-julien.grall@arm.com> References: <20190514123125.29086-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH MM-PART3 v2 04/12] xen/arm: mm: Only increment mfn when valid in xen_pt_update 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: Oleksandr_Tyshchenko@epam.com, Julien Grall , Stefano Stabellini , Andrii Anisov MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Currently, the MFN will be incremented even if it is invalid. This will result to have a valid MFN after the first iteration. While this is not a major problem today, this will be in the future if the code expect an invalid MFN at every iteration. Such behavior is prevented by avoiding to increment an invalid MFN. Signed-off-by: Julien Grall Reviewed-by: Andrii Anisov --- Changes in v2: - Move the patch earlier on in the series - Add Andrii's reviewed-by --- xen/arch/arm/mm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index f956aa6399..9de2a1150f 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -1051,11 +1051,14 @@ static int xen_pt_update(enum xenmap_operation op, spin_lock(&xen_pt_lock); - for(; addr < addr_end; addr += PAGE_SIZE, mfn = mfn_add(mfn, 1)) + for( ; addr < addr_end; addr += PAGE_SIZE ) { rc = xen_pt_update_entry(op, addr, mfn, flags); if ( rc ) break; + + if ( !mfn_eq(mfn, INVALID_MFN) ) + mfn = mfn_add(mfn, 1); } /*