From nobody Tue Feb 10 03:38:01 2026 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1555523980; cv=none; d=zoho.com; s=zohoarc; b=cA8Dk7Cd6jW06tBOVqk3jo+5hOx3jaajsg2YGqBrGH0W0RFu0MgsDb9UPaKb8JsJRUC/puTSKmbAbKDcdpTlV4e5HrrlD3apIcPoDMB0/A/9LO+lP/ySYoKl+8efnoo4KtKB4UfvfGLEQ+p+z70r+khLAsXDlcKqeJbNW+kAuMk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555523980; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=047f3LoULHuz8PW+Oy68iOnaeN6g48i9e51KMBC2AmM=; b=W+M08saZ2yC5aCg2EfLavEjQiIQoz3g0XrzdHD+WADmgvGLRveyJwSXJVkLmvt5YAXjDKmqrSBzSxRf1vsORCZomHXtqaSzGJum+vyZlr22aWqPLHfbIhzDBwYPApoRcuov9ryN8LLx657MLRZZjpvOQ1CzzY/fd1531SpwWjpU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1555523980482662.3490880230364; Wed, 17 Apr 2019 10:59:40 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hGopN-0004Eq-FK; Wed, 17 Apr 2019 17:58:33 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hGopM-0004DH-4e for xen-devel@lists.xenproject.org; Wed, 17 Apr 2019 17:58:32 +0000 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 68f85e92-613a-11e9-92d7-bc764e045a96; Wed, 17 Apr 2019 17:58:30 +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 AC4BD1688; Wed, 17 Apr 2019 10:58:30 -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 9C1773F59C; Wed, 17 Apr 2019 10:58:29 -0700 (PDT) X-Inumbo-ID: 68f85e92-613a-11e9-92d7-bc764e045a96 From: Julien Grall To: xen-devel@lists.xenproject.org Date: Wed, 17 Apr 2019 18:58:15 +0100 Message-Id: <20190417175815.16905-8-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190417175815.16905-1-julien.grall@arm.com> References: <20190417175815.16905-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 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 , sstabellini@kernel.org, Andrii_Anisov@epam.com MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 --- 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 =3D 0; unsigned long addr =3D virt, addr_end =3D addr + nr_mfns * PAGE_SIZE; lpae_t pte, *entry; lpae_t *third =3D NULL; @@ -1013,7 +1013,8 @@ static int create_xen_entries(enum xenmap_operation o= p, { printk("%s: trying to replace an existing mapping addr= =3D%lx mfn=3D%"PRI_mfn"\n", __func__, addr, mfn_x(mfn)); - return -EINVAL; + rc =3D -EINVAL; + goto out; } if ( op =3D=3D RESERVE ) break; @@ -1030,7 +1031,8 @@ static int create_xen_entries(enum xenmap_operation o= p, { printk("%s: trying to %s a non-existing mapping addr= =3D%lx\n", __func__, op =3D=3D REMOVE ? "remove" : "modify= ", addr); - return -EINVAL; + rc =3D -EINVAL; + goto out; } if ( op =3D=3D REMOVE ) pte.bits =3D 0; @@ -1043,7 +1045,8 @@ static int create_xen_entries(enum xenmap_operation o= p, { printk("%s: Incorrect combination for addr=3D%lx\n= ", __func__, addr); - return -EINVAL; + rc =3D -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); =20 - rc =3D 0; - -out: return rc; } =20 --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel