From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED8C2C4743C for ; Wed, 23 Jun 2021 11:06:05 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B74EF61026 for ; Wed, 23 Jun 2021 11:06:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B74EF61026 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QsaJSf5+N18Wvric70tEy/MHXUFn/aeqoqHnE7rs/ww=; b=nOnPs2jJ74deuG Z1VLEuVCRkXVeMa40/yfsWBGWcuqKkJELMHqMEuWvdhPd7zXaU8iltD/ZbPKw/pAXM9rxE41qYF1G 40fcgBkR4uqRCRFwIoe2DK0HeWtTbH5Cm1Nd4NWV8Jo9oGxD4+pja9fgNsMW1s71nHPOOXTn8zEX7 QL9MuK7mD/ZOO/j12A9m+pEr4GNURHaIO7UBFSgTl52GwkCf5cv016U/yUxrG5i3X7H7gsDfv5Gna EUkIbfvmuuxM3khQme+AkUMFVY/OaL36xgsq01R62BBU8HFBXoR2DtOI1/D+oTNL63s4mE6V1iPNN WgoyUYp24hXQ83lulWvg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lw0gA-00AO9X-BM; Wed, 23 Jun 2021 11:04:22 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lw0g6-00AO8j-TV for linux-arm-kernel@lists.infradead.org; Wed, 23 Jun 2021 11:04:20 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3E85E61003; Wed, 23 Jun 2021 11:04:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624446258; bh=SQLZ3jEqT4yhyhpj0Bb9UFclPy9A7MyuqA/xQ21E19o=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nFel0oGOMMRKsUQpOzA8E0CCodJoyPdxcszRZjPwq2EF6srqWdV01nWToiHko05qr z4OoIBK2qzIUUUqLi/+1Gvaeq1z/zXhEREhS7P6V+BZdsMAMzIgeofMC0LMKzq5y+n 1csrxIqsmn/WulaMO7Mbf9WQjRdjHAJawSFsK2Y0e6dY6WVzN2K/wPJVVzwSvUO86F mW72uxO54TkbohQpB88ly/TTkjX7bt7ioUcsI+SbQ3wM1fv11Tz40VtNvJ94aR1DB1 OC7Rqt8S2FO3m8tUJGaII25RYFNWSq8XxR5rNaJ/nNUETYfy/n4Fvz8eabCU7nHi8c SIOV/J/fx2MjQ== Date: Wed, 23 Jun 2021 12:04:12 +0100 From: Will Deacon To: Zhenyu Ye Cc: Catalin Marinas , aneesh.kumar@linux.ibm.com, Marc Zyngier , steven.price@arm.com, Peter Zijlstra , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, Xiexiangyou , liushixin2@huawei.com, huyaqin , zhurui3@huawei.com Subject: Re: [PATCH v1] arm64: tlb: fix the TTL value of tlb_get_level Message-ID: <20210623110412.GA32177@willie-the-truck> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210623_040419_005876_856E2CA8 X-CRM114-Status: GOOD ( 23.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Jun 23, 2021 at 03:05:22PM +0800, Zhenyu Ye wrote: > The TTL field indicates the level of page table walk holding the *leaf* > entry for the address being invalidated. But currently, the TTL field > may be set to an incorrent value in the following stack: > > pte_free_tlb > __pte_free_tlb > tlb_remove_table > tlb_table_invalidate > tlb_flush_mmu_tlbonly > tlb_flush > > In this case, we just want to flush a PTE page, but the tlb->cleared_pmds > is set and we get tlb_level = 2 in the tlb_get_level() function. This may > cause some unexpected problems. > > This patch set the TTL field to 0 if tlb->freed_tables is set. The > tlb->freed_tables indicates page table pages are freed, not the leaf > entry. > > Fixes: c4ab2cbc1d87 ("arm64: tlb: Set the TTL field in flush_tlb_range") > Reported-by: ZhuRui > Signed-off-by: Zhenyu Ye > --- > arch/arm64/include/asm/tlb.h | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/arch/arm64/include/asm/tlb.h b/arch/arm64/include/asm/tlb.h > index 61c97d3b58c7..c995d1f4594f 100644 > --- a/arch/arm64/include/asm/tlb.h > +++ b/arch/arm64/include/asm/tlb.h > @@ -28,6 +28,10 @@ static void tlb_flush(struct mmu_gather *tlb); > */ > static inline int tlb_get_level(struct mmu_gather *tlb) > { > + /* The TTL field is only valid for the leaf entry. */ > + if (tlb->freed_tables) > + return 0; > + > if (tlb->cleared_ptes && !(tlb->cleared_pmds || > tlb->cleared_puds || > tlb->cleared_p4ds)) Thanks. I can't see a better way around this, so I'll queue the patch. The stage-2 page-table code looks ok afaict, but please can you check it too? Cheers, Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel