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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 196B4CF34AD for ; Wed, 19 Nov 2025 14:32:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:Subject:References:In-Reply-To:Message-Id:Cc:To:From:Date: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=R6D6QeZI1FMy5FBGvryMzW9jVA/82yWzAxvTxR3x6wk=; b=MjFYTuUOCDlvbxW7jbgdKoWWLR CpLIJpSxoH1/DA0Rd8d7Fkwkb7gnKbf5Z1Js/VJY6MP3ZRqYQ/pE2ISqkZYull4thWhcVcWIKTgUH 6xEGxD/bJukGNPqssNeVfryZ7MtOHYmkfKO2+EgKlH7FqdaMrzlgMVR/kQHbT8fjP2f5+mlReIggc YC3PMd2T70tathf9sBV4HJZiqPEyXRGl2PuA8b0XcOJ3RNXQdg88pJ+OTtLUp+TLQcnRh31rCIQV3 DXzwEzomT8oaQ26MtY4OrrpmXOU7rUKBGa1DHGgBtOxmN+suHGDoZhqyc9d3SSGu/JPbarME21eLI 7hEXu2dQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vLjDx-00000003NfX-2AGm; Wed, 19 Nov 2025 14:31:57 +0000 Received: from tor.source.kernel.org ([172.105.4.254]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vLjDw-00000003NfB-0KD2 for linux-arm-kernel@lists.infradead.org; Wed, 19 Nov 2025 14:31:56 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 9A05960169; Wed, 19 Nov 2025 14:31:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E319EC2BCB0; Wed, 19 Nov 2025 14:31:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763562714; bh=t7JHEvub1bQJal+g6fm+oWNxS6WRDvkPwGmxdErav44=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=Ea4bojU3b4uuNYkYVwnmXHYKrqlrEyIaRN7/uuLqQ0tjPkP+0CBl8L7OWP74jMhkR 6BEZWebMdOXDsVMaFdTA/3c4Ol/FfmWfZJ7I77nIstjY/8MxmX60jwnojnAv9c5OB6 yiaxqYjeyx5Rbc+bcCTpfw9nnAVkEBGMQ7n8TQ68Sdv8V0/fXWca/2aZJ+PdDOCe1Z fgqUw43kE8xbSlEr9OaiWF6IUiQPM10iJQo0m7vG74uwaC7eKHKSOTyPWFK+IxX8Cr NCsa459K8S2l9VNSLvncI+/+4fDDtvhtPnwSSP5VIBtd53subUnkzEeGp3uNl9yo2f QaAOeHd7myqGw== Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfauth.phl.internal (Postfix) with ESMTP id 560CFF4008D; Wed, 19 Nov 2025 09:31:51 -0500 (EST) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-01.internal (MEProxy); Wed, 19 Nov 2025 09:31:51 -0500 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddvvdeggeehucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepofggfffhvfevkfgjfhfutgfgsehtqhertdertdejnecuhfhrohhmpedftehnugih ucfnuhhtohhmihhrshhkihdfuceolhhuthhosehkvghrnhgvlhdrohhrgheqnecuggftrf grthhtvghrnhepjeejvddvtdehffdtgfejjeefgefgjeeggfeuteeiuedvtefgfffhvdej iefguedtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh eprghnugihodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdduudeiudekheei fedvqddvieefudeiiedtkedqlhhuthhopeepkhgvrhhnvghlrdhorhhgsehlihhnuhigrd hluhhtohdruhhspdhnsggprhgtphhtthhopeegkedpmhhouggvpehsmhhtphhouhhtpdhr tghpthhtohepjhgsrghrohhnsegrkhgrmhgrihdrtghomhdprhgtphhtthhopegsphesrg hlihgvnhekrdguvgdprhgtphhtthhopegrrhhnugesrghrnhgusgdruggvpdhrtghpthht ohepuggrvhgvmhesuggrvhgvmhhlohhfthdrnhgvthdprhgtphhtthhopehmrghthhhivg hurdguvghsnhhohigvrhhssegvfhhfihgtihhoshdrtghomhdprhgtphhtthhopegsohhq uhhnrdhfvghnghesghhmrghilhdrtghomhdprhgtphhtthhopehurhgviihkihesghhmrg hilhdrtghomhdprhgtphhtthhopehrohhsthgvughtsehgohhoughmihhsrdhorhhgpdhr tghpthhtohepjhgrnhhnhhesghhoohhglhgvrdgtohhm X-ME-Proxy: Feedback-ID: ieff94742:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 1FAFE700054; Wed, 19 Nov 2025 09:31:51 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface MIME-Version: 1.0 X-ThreadId: A2ZwPDH9FoLc Date: Wed, 19 Nov 2025 06:31:30 -0800 From: "Andy Lutomirski" To: "Valentin Schneider" , "Linux Kernel Mailing List" , linux-mm@kvack.org, rcu@vger.kernel.org, "the arch/x86 maintainers" , linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-arch@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "Dave Hansen" , "H. Peter Anvin" , "Peter Zijlstra (Intel)" , "Arnaldo Carvalho de Melo" , "Josh Poimboeuf" , "Paolo Bonzini" , "Arnd Bergmann" , "Frederic Weisbecker" , "Paul E. McKenney" , "Jason Baron" , "Steven Rostedt" , "Ard Biesheuvel" , "Sami Tolvanen" , "David S. Miller" , "Neeraj Upadhyay" , "Joel Fernandes" , "Josh Triplett" , "Boqun Feng" , "Uladzislau Rezki" , "Mathieu Desnoyers" , "Mel Gorman" , "Andrew Morton" , "Masahiro Yamada" , "Han Shen" , "Rik van Riel" , "Jann Horn" , "Dan Carpenter" , "Oleg Nesterov" , "Juri Lelli" , "Clark Williams" , "Yair Podemsky" , "Marcelo Tosatti" , "Daniel Wagner" , "Petr Tesarik" , "Shrikanth Hegde" Message-Id: <65ae9404-5d7d-42a3-969e-7e2ceb56c433@app.fastmail.com> In-Reply-To: <20251114151428.1064524-9-vschneid@redhat.com> References: <20251114150133.1056710-1-vschneid@redhat.com> <20251114151428.1064524-9-vschneid@redhat.com> Subject: Re: [RFC PATCH v7 29/31] x86/mm/pti: Implement a TLB flush immediately after a switch to kernel CR3 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Nov 14, 2025, at 7:14 AM, Valentin Schneider wrote: > Deferring kernel range TLB flushes requires the guarantee that upon > entering the kernel, no stale entry may be accessed. The simplest way = to > provide such a guarantee is to issue an unconditional flush upon switc= hing > to the kernel CR3, as this is the pivoting point where such stale entr= ies > may be accessed. > Doing this together with the PTI CR3 switch has no actual benefit: MOV C= R3 doesn=E2=80=99t flush global pages. And doing this in asm is pretty g= ross. We don=E2=80=99t even get a free sync_core() out of it because IN= VPCID is not documented as being serializing. Why can=E2=80=99t we do it in C? What=E2=80=99s the actual risk? In or= der to trip over a stale TLB entry, we would need to deference a pointer= to newly allocated kernel virtual memory that was not valid prior to ou= r entry into user mode. I can imagine BPF doing this, but plain noinstr = C in the entry path? Especially noinstr C *that has RCU disabled*? We = already can=E2=80=99t follow an RCU pointer, and ISTM the only style of = kernel code that might do this would use RCU to protect the pointer, and= we are already doomed if we follow an RCU pointer to any sort of memory. We do need to watch out for NMI/MCE hitting before we flush.