From patchwork Tue May 14 12:21:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 164165 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp2552369ili; Tue, 14 May 2019 05:23:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqz2d6XE04JbP3dymATndl1Rak41fvm/S0x7i9J3I/hfp02kfOAayZ2vsFUeSf1mMwELZb8h X-Received: by 2002:a24:320c:: with SMTP id j12mr2974121ita.131.1557836602419; Tue, 14 May 2019 05:23:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557836602; cv=none; d=google.com; s=arc-20160816; b=Q9z9UtxdpEyhJV6R9WU66/V6JviXuTN0CY0DRFxxM/L6xFSVMbG9pvRTL2VgZkGz+2 2ox8Hs0SiH6PtzZm8fKEOHWv8a0KjxeSnjHg93a+uoOW6Kck2qth/HGlMblxtxuoUpHk je2A90PJk0dQXTbEywHoZTF83zF8C0M+O1yod59Nd2dzjLJh1lqvrnhXsfgwBUi1iKA3 4AmTzYGfVUX28amiAUvLiRFwpTmfoccYp9na03kodFa2xgXXQ2gZWWWXb3mWFcIUPBe2 Mg4V3N8ZSvBEcXr/fJ69WlwbyP5Y8od4nw/K7sWTwdakDNZ43iSIgpubUeEhAGWSY3Hr kphQ== 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=Py+BjY5hw5qju9cux+1+KLgu52CoNyXrmrwH3H0tjNE=; b=n/IS/Qo/ISoTGoZYABkb5zBMka4K3bpz+PKL5Tq5yoOALPJVDAuYCyRv15ZKZ2+W9E wFafErmKUuajpss4nzhKKAlPmaq00u24NfnkXxi1I9VR5MhqiQOJwnuXJ2cIfPmox/Ma VTGSJb/sL2ADPqWgZQgKCXOG3SwYkiX0J46K7zIf6lRZxwpxLflvQTzj/yoDxmgafeeE XgmUlBSZFmHS+zpIbNjEmzZRBOVhWcop4uzszwYBe3vtv0+cPhdUTw0HsGcSkgy0JLac UoqUvz3Qq7VuPAiX/+oTX5SogNLPc1anG2I5ISglu3mKEoazGP/ZQkn+jE0hM4tNQpLk xkHQ== 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 72si485307itk.58.2019.05.14.05.23.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 May 2019 05:23:22 -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 1hQWRs-0000UG-5I; Tue, 14 May 2019 12:22:24 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hQWRr-0000TC-KV for xen-devel@lists.xenproject.org; Tue, 14 May 2019 12:22:23 +0000 X-Inumbo-ID: ec586b83-7642-11e9-8980-bc764e045a96 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id ec586b83-7642-11e9-8980-bc764e045a96; Tue, 14 May 2019 12:22: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 771E8341; Tue, 14 May 2019 05:22:21 -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 43BD43F71E; Tue, 14 May 2019 05:22:20 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 14 May 2019 13:21:35 +0100 Message-Id: <20190514122136.28215-27-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190514122136.28215-1-julien.grall@arm.com> References: <20190514122136.28215-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH MM-PART2 v2 18/19] xen/arm: mm: Check start is always before end in {destroy, modify}_xen_mappings 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" The two helpers {destroy, modify}_xen_mappings don't check that the start is always before the end. This should never happen but if it happens, it will result to unexpected behavior. Catch such issues earlier on by adding an ASSERT in destroy_xen_mappings and modify_xen_mappings. Signed-off-by: Julien Grall Reviewed-by: Andrii Anisov --- Changes in v2: - Add Andrii's reviewed-by --- xen/arch/arm/mm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index eacc1647e0..b408de7c75 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -1077,11 +1077,13 @@ int populate_pt_range(unsigned long virt, unsigned long nr_mfns) int destroy_xen_mappings(unsigned long v, unsigned long e) { + ASSERT(v <= e); return create_xen_entries(REMOVE, v, INVALID_MFN, (e - v) >> PAGE_SHIFT, 0); } int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int flags) { + ASSERT(s <= e); return create_xen_entries(MODIFY, s, INVALID_MFN, (e - s) >> PAGE_SHIFT, flags); }