From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA77537EFEA for ; Wed, 4 Mar 2026 18:02:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772647329; cv=none; b=iKJjOwIw9wErdJJhNMiugixCFjhYG6pNCqvjfAxO3tFc9QYyTTRhjYmGNNzWCELgYVNEWA1dfGPmk+Uh3aUll1pekPSZQny+cgkOJBLnm1P+JxdZw+aXyfOaRIIjP6iHgW5GxjyuyFIVw4E80Rb3EgpXbilEtWW9B73HY+RxzEw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772647329; c=relaxed/simple; bh=zY28AMsvF7T+RvWhG01tRXdNUdtyXfNlkKH91AV4J1A=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Y1CFXN8pZblLQ1it2b4SeaLg8K13UnM5qZXez/AiGZtAQ/0w8Xv9EXfgBfhfyX7Tkt4tUS5T14L2ec5PfHdZTZfueORZ9PPQE9OslFK8MgLy0PsZ5Lw/OrQNICym+exVncVtOaIU6S2pgcWT8R2QlLeFtORygJq7GtyKhFfSFho= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rRzDlCoI; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rRzDlCoI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 100F2C2BCB1; Wed, 4 Mar 2026 18:02:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772647329; bh=zY28AMsvF7T+RvWhG01tRXdNUdtyXfNlkKH91AV4J1A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=rRzDlCoIB+D+6AhZmrSA8aWYW4yYNe77jijnZlgHii/7b0CGlOgBJhLZIa8oALbKe fNwLtU72/KNINGkFcdk9jPOuDuMvhUGvCctiJfT7KEKnwPK6JslAkRB7MUSY5Kso9a MvbK5Gvy27dW5UgDfMw0Xrc1YYi38jjTlSZryUFlEyiS3txYv9zuOego8sqrj/keyB uAb7HROjCc+Zdraz7u4k07Mb4m0BuX8lZlj5QMFcqbBzulzigHJ7OCqqe9YP6x5aMp vmEarglqT3NgJW4WKJbfKYx4NKMdKmCG614puoymcDtnJ0j1qVBtFyPHtYYiDJUmtq T4/SqYfbRw+5A== Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfauth.phl.internal (Postfix) with ESMTP id 9F5A9F40069; Wed, 4 Mar 2026 13:02:07 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Wed, 04 Mar 2026 13:02:07 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvieegudejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepmfhirhihlhcu ufhhuhhtshgvmhgruhcuoehkrghssehkvghrnhgvlhdrohhrgheqnecuggftrfgrthhtvg hrnhepueeijeeiffekheeffffftdekleefleehhfefhfduheejhedvffeluedvudefgfek necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepkhhirh hilhhlodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdduieduudeivdeiheeh qddvkeeggeegjedvkedqkhgrsheppehkvghrnhgvlhdrohhrghesshhhuhhtvghmohhvrd hnrghmvgdpnhgspghrtghpthhtohepkedpmhhouggvpehsmhhtphhouhhtpdhrtghpthht oheprghruggssehkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnh gvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopeigkeeisehkvghrnhgv lhdrohhrghdprhgtphhtthhopehhphgrseiihihtohhrrdgtohhm X-ME-Proxy: Feedback-ID: i10464835:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 4 Mar 2026 13:02:07 -0500 (EST) Date: Wed, 4 Mar 2026 18:02:05 +0000 From: Kiryl Shutsemau To: Ard Biesheuvel Cc: linux-kernel@vger.kernel.org, x86@kernel.org, "H. Peter Anvin" Subject: Re: [PATCH] x86/boot: Use 5-level paging trampoline in place if possible Message-ID: References: <20260304160549.670066-2-ardb@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260304160549.670066-2-ardb@kernel.org> On Wed, Mar 04, 2026 at 05:05:50PM +0100, Ard Biesheuvel wrote: > The traditional x86 decompressor contains a rather nasty hack in > find_trampoline_placement() to temporarily use some system RAM below 1M > for a 32-bit addressable trampoline, which it needs in order to be able > to switch from 4 levels of paging to 5 or vice versa. > > It does this even when running from 32-bit addressable memory itself, in > which case none of this is needed - the trampoline code can be fixed up > to execute correctly from anywhere below 4G, and so it can execute in > place from the decompressor's initial placement. The additional root > level page table allocation can be used directly if it resides below the > 4G mark as well. > > The traditional decompressor is no longer used by the EFI stub, and is > mostly relied upon by non-EFI bootloaders such as coreboot which run > entirely in 32-bit mode, and are therefore guaranteed to place the > decompressor in 32-bit addressable memory. In those cases, on CPUs that > support it, 5-level paging will always get enabled, by invoking this > code (unless it is explicitly disabled on the command line) but the > trampoline allocation is never needed. > > kexec also relies on the traditional decompressor and does typically > load the kernel above 4G, but in that case, the trampoline is only > needed when either the first or the second kernel explicitly disables > 5-level paging, otherwise it will just remain enabled and no trampoline > is needed. > > So avoid the trampoline hack unless it is really required. My worry is that the trampoline hack code will not get proper testing if it only runs in marginal cases. And will rot over time. I intentionally made it unconditional to avoid it. -- Kiryl Shutsemau / Kirill A. Shutemov