From nobody Sun Feb 8 12:43:13 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 B3AF8376EC; Wed, 28 Feb 2024 10:11:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709115091; cv=none; b=KMRRBqQ2cmU9nZ/uhq95UiE/iA8wo9/4jTaST/V2eoJvi7F66rswAZSBEKxnkPqAXy+AJ7eDnL9b+72U7yQmmFZ+ktZF4xqa54twRb7WTygqBq5gbM/QVCMM97ZK3sHavdRCWpsilLf8+jwjcUFx0wKTGXuonmo97VQdf2ha6V8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709115091; c=relaxed/simple; bh=d0/GW9Hlrkhgj4xitNTIzREyL/IrPHq2WBsSG7+jrKw=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=uKNktQoTHCB+x9GQtA5t+H4bqeJdI9dfbvDZjHKfLPRJQqtgA9+jZrtIEXJt3gJo46NOLw76n3Z0pZVQUvQTTSj8TApVhSkqr/ZY5I2rprqN5YEcGD1ESjqbCTnl8wk0dpdq5KsM7WyqNFSELEDGvosGhiyNiFxDkTTvHoV8VbI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=K/Uz8Rwr; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=t6X1lfYr; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="K/Uz8Rwr"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="t6X1lfYr" Date: Wed, 28 Feb 2024 10:11:26 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1709115087; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LrnkpejSqhcF9JYa98EHYfWHPhb164YL0Ul7jes8SbM=; b=K/Uz8Rwr/Esb6voUMNiHQ6suEIiffe4TiDxZLjHEKaqA0q7cDLFg9acVB2U74aBI7c3uLi W7b2qgqUOBb92MVJUJnqo9MbuVmZJOX5cYw7rf3L19vI+aqJSzK9QpjBu4KMo///DKvLF0 UnKWBK4v83qaeeHe1AskZSIKhUp/DzGTgFeRgRFGF47Mw4YCEewCPddtb57nZlubAEn3et JEx5PCWwgw4yR2T3Mfu6J7LJYK32p6VrkOK5/oU22ktYXP/pLisctL79vwc5SGeH75/ZuY qK6oNgL+t/DPTqHAEuilocT8N0G6c2DQRjvNkF1T9krS+ypdNoyoArkoQzbonQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1709115087; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LrnkpejSqhcF9JYa98EHYfWHPhb164YL0Ul7jes8SbM=; b=t6X1lfYr1CyDvUik5ZfFl2tSAkXtSxPtNC3mD1vxl9OfSnVZ+BwtGiItI87WhXTzz8iC0p spcMcMqnNU4FbVCg== From: "tip-bot2 for Brian Gerst" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/boot] x86/boot/64: Load the final kernel GDT during early boot directly, remove startup_gdt[] Cc: Brian Gerst , Ingo Molnar , Ard Biesheuvel , Kees Cook , Andy Lutomirski , Linus Torvalds , "H. Peter Anvin" , Josh Poimboeuf , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240226220544.70769-1-brgerst@gmail.com> References: <20240226220544.70769-1-brgerst@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <170911508625.398.12452118843438429976.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the x86/boot branch of tip: Commit-ID: 11e36b0f7c2150a6453872b79555767b43c846d0 Gitweb: https://git.kernel.org/tip/11e36b0f7c2150a6453872b79555767b4= 3c846d0 Author: Brian Gerst AuthorDate: Mon, 26 Feb 2024 17:05:44 -05:00 Committer: Ingo Molnar CommitterDate: Wed, 28 Feb 2024 11:02:16 +01:00 x86/boot/64: Load the final kernel GDT during early boot directly, remove s= tartup_gdt[] Instead of loading a duplicate GDT just for early boot, load the kernel GDT from its physical address. Signed-off-by: Brian Gerst Signed-off-by: Ingo Molnar Acked-by: Ard Biesheuvel Cc: Kees Cook Cc: Andy Lutomirski Cc: Linus Torvalds Cc: "H. Peter Anvin" Cc: Josh Poimboeuf Link: https://lore.kernel.org/r/20240226220544.70769-1-brgerst@gmail.com --- arch/x86/include/asm/desc.h | 1 + arch/x86/kernel/head64.c | 13 ++----------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h index ab97b22..52c0150 100644 --- a/arch/x86/include/asm/desc.h +++ b/arch/x86/include/asm/desc.h @@ -46,6 +46,7 @@ struct gdt_page { } __attribute__((aligned(PAGE_SIZE))); =20 DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page); +DECLARE_INIT_PER_CPU(gdt_page); =20 /* Provide the original GDT */ static inline struct desc_struct *get_cpu_gdt_rw(unsigned int cpu) diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c index 72351c3..fd77a26 100644 --- a/arch/x86/kernel/head64.c +++ b/arch/x86/kernel/head64.c @@ -68,15 +68,6 @@ unsigned long vmemmap_base __ro_after_init =3D __VMEMMAP= _BASE_L4; EXPORT_SYMBOL(vmemmap_base); #endif =20 -/* - * GDT used on the boot CPU before switching to virtual addresses. - */ -static struct desc_struct startup_gdt[GDT_ENTRIES] __initdata =3D { - [GDT_ENTRY_KERNEL32_CS] =3D GDT_ENTRY_INIT(DESC_CODE32, 0, 0xffff= f), - [GDT_ENTRY_KERNEL_CS] =3D GDT_ENTRY_INIT(DESC_CODE64, 0, 0xffff= f), - [GDT_ENTRY_KERNEL_DS] =3D GDT_ENTRY_INIT(DESC_DATA64, 0, 0xffff= f), -}; - #ifdef CONFIG_X86_5LEVEL static void __head *fixup_pointer(void *ptr, unsigned long physaddr) { @@ -589,8 +580,8 @@ void __head startup_64_setup_gdt_idt(void) void *handler =3D NULL; =20 struct desc_ptr startup_gdt_descr =3D { - .address =3D (unsigned long)&RIP_REL_REF(startup_gdt), - .size =3D sizeof(startup_gdt) - 1, + .address =3D (unsigned long)&RIP_REL_REF(init_per_cpu_var(gdt_page.gdt)), + .size =3D GDT_SIZE - 1, }; =20 /* Load GDT */