From patchwork Mon Apr 22 16:49: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: 162601 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp2801145jan; Mon, 22 Apr 2019 09:51:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqySw1nIxFln4hTkhazWoKDWXQgYyjRAVqkGUg0y/VnWB+e67FPW4I+C22x/9NuQM46K8daL X-Received: by 2002:a25:d08e:: with SMTP id h136mr16213800ybg.316.1555951866133; Mon, 22 Apr 2019 09:51:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555951866; cv=none; d=google.com; s=arc-20160816; b=BVJvst/6Ast7ThXdVwo1pTzLNWjfxi7Vwy3VMvMyE0bsFPiHMoI/kM74UZzd+mj2HW 5otylkUOtN2ddlbR5JiONpFu5WP3krkuewbYS/hJLvEaLmd6Yknv+AT3vxijFGuEAwMl 5tST2PTKXWAlIyZQJaGXaY52gu1foPlj94chDL9k796tbPe/9gPm2YrkKVGFcDa2dwQx 5I3hcLvJKD+Zu/DOp8gD/dOqvewwDHUuQBVzU2RJaKDnKDDdBsbxHiqe5Kpzi0L+UfCN n4zty9w2wbcENxnlGTE/FMS7AbFqlte4Z7GlSAlvdx0Mhf7d3wtF1corGAvSdDAY/sRz mO8w== 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=EXjBHqB9fSbkM3MIkS5nbRJx+ySoM+2QGhtbanEzSoU=; b=s4JukPZVgrfmDJaOH6b3uE1zVuhFkbylAUdQ9LSeKI3mYAAL4SB4Np8NN3NfcIYRUx jwI9mluZ7oii9MSGkUFR4UItr+dxVN8qYQNPNDGcVXpH3Nl1THe2V2q2MxhXdCPDp5sE 3vnRLuzRaO8LY6rpxS/Eq2KCPANjsFGm6mosterwQSoGyZN7auIEqryhkJY8Djdcdudu uQMB3y2PnvE2fhZY3Ph+MLFr+GBZMwhB3+4pi4RUOQhvE0oa77VafMrfGDOVEQn8KbtG D5EFnEausWGKR3R5xs24f8X22JZHPCD8tSDxSyqKq3X5WdiXd3jDnqFkNbewCzKX3ANt RQKQ== 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 y203si9737310ywa.294.2019.04.22.09.51.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Apr 2019 09:51:06 -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 1hIc94-0005Rd-Vz; Mon, 22 Apr 2019 16:50:18 +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 1hIc92-0005Ne-NJ for xen-devel@lists.xenproject.org; Mon, 22 Apr 2019 16:50:16 +0000 X-Inumbo-ID: b3e13c88-651e-11e9-aa2e-a7481e74956a Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id b3e13c88-651e-11e9-aa2e-a7481e74956a; Mon, 22 Apr 2019 16:50:15 +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 22EDC15AB; Mon, 22 Apr 2019 09:50:15 -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 12FCE3F557; Mon, 22 Apr 2019 09:50:13 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Apr 2019 17:49:35 +0100 Message-Id: <20190422164937.21350-19-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190422164937.21350-1-julien.grall@arm.com> References: <20190422164937.21350-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 18/20] 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 , sstabellini@kernel.org, Andrii_Anisov@epam.com 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 --- 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 ee541a38e3..d6157c35d6 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -1072,11 +1072,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); }