From patchwork Wed May 8 16:16:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 163635 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:81:0:0:0:0 with SMTP id l1csp2885552ilm; Wed, 8 May 2019 09:17:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqyfef49YgmSCDt0C1aPzo/A0Phj61ht0X5LpCWvSI6Nc4Ft+UQdZzhxmRSO+8o1O76N6aYV X-Received: by 2002:a24:2fcb:: with SMTP id j194mr4438557itj.14.1557332261647; Wed, 08 May 2019 09:17:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557332261; cv=none; d=google.com; s=arc-20160816; b=i3BH870/MtZaOSHlMTGh8Mkjzj0T6DI14PCsmD2T23VNz4ZDGFvkkDxAUd0xEULVPS V7gs0a0JX+YQCxSzvjfyPuD63xioH2zCO9aF7ezYvotI2JCIwya+m0Di0qawuevh5nii HOczakYMMdUdDdQhWSVhm8bBzlKNFosEvuV+ZaVNDwm0G1DxFEL8NEWA+3h4/7xuSFs2 euiDwFx6T3B5ExW7TNf6QeAJkI+m6G3xklE4e5YVljHlLcaCdqXQqpswUqVNPjm3I8tM PrjGSaZLa971Mm5RnEEnGhTZPkynB4b+PG5vFsM2krmAP7NWwCcbt9jiqjZeudOfjQgy O5OQ== 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=h4qucULm9utmZfFmFq+FElQErh6gNmI8fsaX/GtbH94=; b=hWC4rEmUrC3xV+6bE4ADjfu1CoAPNtIamGiykRk4f3ZsPtWJ6V0VWZFYTPMTTVziJe SjrGV00JYgrtjwbNHdotCsCnZaac/XHTE4IXzE3nEusgqVwMDtdhwurrVzfvsNbRZqYm TG2i0ejoMGzSXMvcoAscGECdDBc7JHRpeGMoSq2e3ycheOT190Tz8Ufu6p+HQmJiw5nx H5ZxCCOr9HdNJHhEHljEpNaevS6xkKSYherl1X3+jjP/IX0xd3DQK5NoYBegmsKJqA1k NuKBxoZ8VOhhKrPaddGOZ0Q8tLdTSHCdLdfOP5NH2MBgPuxeaM1uKeyLeV+FbpyYK+iF w9eQ== 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 m4si2424775ioq.50.2019.05.08.09.17.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 08 May 2019 09:17:41 -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 1hOPEz-0008JD-7F; Wed, 08 May 2019 16:16:21 +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 1hOPEy-0008IK-0W for xen-devel@lists.xenproject.org; Wed, 08 May 2019 16:16:20 +0000 X-Inumbo-ID: 9cb39e44-71ac-11e9-b79a-5f8566900e7a Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 9cb39e44-71ac-11e9-b79a-5f8566900e7a; Wed, 08 May 2019 16:16:19 +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 A319E374; Wed, 8 May 2019 09:16:18 -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 6FE603F238; Wed, 8 May 2019 09:16:17 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Wed, 8 May 2019 17:16:03 +0100 Message-Id: <20190508161603.21964-8-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190508161603.21964-1-julien.grall@arm.com> References: <20190508161603.21964-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH v2 7/7] xen/arm: mm: Flush the TLBs even if a mapping failed in create_xen_entries 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" At the moment, create_xen_entries will only flush the TLBs if the full range has successfully been updated. This may lead to leave unwanted entries in the TLBs if we fail to update some entries. Signed-off-by: Julien Grall Reviewed-by: Andrii Anisov Reviewed-by: Stefano Stabellini --- Changes in v2: - Add Andrii's reviewed-by --- xen/arch/arm/mm.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 8ee828d445..9d584e4cbf 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -984,7 +984,7 @@ static int create_xen_entries(enum xenmap_operation op, unsigned long nr_mfns, unsigned int flags) { - int rc; + int rc = 0; unsigned long addr = virt, addr_end = addr + nr_mfns * PAGE_SIZE; lpae_t pte, *entry; lpae_t *third = NULL; @@ -1013,7 +1013,8 @@ static int create_xen_entries(enum xenmap_operation op, { printk("%s: trying to replace an existing mapping addr=%lx mfn=%"PRI_mfn"\n", __func__, addr, mfn_x(mfn)); - return -EINVAL; + rc = -EINVAL; + goto out; } if ( op == RESERVE ) break; @@ -1030,7 +1031,8 @@ static int create_xen_entries(enum xenmap_operation op, { printk("%s: trying to %s a non-existing mapping addr=%lx\n", __func__, op == REMOVE ? "remove" : "modify", addr); - return -EINVAL; + rc = -EINVAL; + goto out; } if ( op == REMOVE ) pte.bits = 0; @@ -1043,7 +1045,8 @@ static int create_xen_entries(enum xenmap_operation op, { printk("%s: Incorrect combination for addr=%lx\n", __func__, addr); - return -EINVAL; + rc = -EINVAL; + goto out; } } write_pte(entry, pte); @@ -1052,11 +1055,14 @@ static int create_xen_entries(enum xenmap_operation op, BUG(); } } +out: + /* + * Flush the TLBs even in case of failure because we may have + * partially modified the PT. This will prevent any unexpected + * behavior afterwards. + */ flush_xen_tlb_range_va(virt, PAGE_SIZE * nr_mfns); - rc = 0; - -out: return rc; }