From patchwork Wed Apr 24 16:59:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 162790 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp895700jan; Wed, 24 Apr 2019 10:01:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqxo86qGC4ayMhLMXSa+UqeRbMY237sqzv6WYTn3cwiDUWfPWnsWmxpIGd3CH+NntNIdgac9 X-Received: by 2002:a81:1e51:: with SMTP id e78mr29121392ywe.302.1556125314757; Wed, 24 Apr 2019 10:01:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556125314; cv=none; d=google.com; s=arc-20160816; b=G6k9Wa1e93gbaIErmN9dwtR9dbTM988B2CMVnGtlzzWAP2UvYIcaEJgnUBz4ssZlVi Y8x+4c8hwBeXp4jNmJMkNki5HigcwLhTMmnc+wdIoYZLMoWIzhSCOYEriUuEKpJfCLn+ AtU9Nt/qYA8fkUfR244uY4hzgoCKYnjZyhDY2JfqJkSnebAIXcD5jv+o+Rs70aX2Tr+e bis3R2BtX/iIr29clLwMTdq9rbfKrU5DNhiw4XvMZ8ymhCOVDF7Clv2GBfiZ2/Ok2Fyo hq0JNCyQ3ybqPNFp9nWHyzOhpLJ6Na+zMbc1E6I84alQ+W12xh9XleEypzCH8Uf2wkZv HRtw== 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=7igDFhkOrVPnO9OKdiiGnD56bNDkqOWtgF14/LjV8Jg=; b=kdpPSySi0QcA31sTWpwXfYYAy0GXMBaC4JsWPs1Pw1iTDSJABmKdOVMM1agN4A++zO Ub1rMvcGEqc0ZxX+TCJWTcVFe2HjAwfH+ftbM5ECfgPDAxRJl9vPnN59wwvAJU82550O e+gvDIiGwghkaMwHGAtUh9ZScX3Gftdkuckr3PV856aWPiEVCVrc4omreiKv52sUf/sv v1+hQvFIesZy21dLj51wb2B/mBjKD26u7CfpeSiu6q4cNnjqbqgOsFhymoLDxFz9sjMz ZX6S9hbVC+tSjL2OA4fWIfEgX2w4kUwbgckp9iygpIxYYiyztLGDdRVmRqGIZ7OqkUm0 XgVQ== 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 20si13039389ywo.36.2019.04.24.10.01.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2019 10:01:54 -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 1hJLFl-0007nY-9o; Wed, 24 Apr 2019 17:00:13 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hJLFk-0007nN-9Z for xen-devel@lists.xenproject.org; Wed, 24 Apr 2019 17:00:12 +0000 X-Inumbo-ID: 6c1ccaee-66b2-11e9-ace0-d3443eb28cba Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 6c1ccaee-66b2-11e9-ace0-d3443eb28cba; Wed, 24 Apr 2019 17:00:11 +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 5A9E115BE; Wed, 24 Apr 2019 10:00:11 -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 3FD433F557; Wed, 24 Apr 2019 10:00:10 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Wed, 24 Apr 2019 17:59:48 +0100 Message-Id: <20190424165955.23718-6-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190424165955.23718-1-julien.grall@arm.com> References: <20190424165955.23718-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 05/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 , sstabellini@kernel.org, Andrii_Anisov@epam.com 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 --- 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 b61217abd0..eee7122c88 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -1046,11 +1046,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); } /*