Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2453333rbb; Wed, 28 Feb 2024 02:12:08 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUBS+6qMdtmUUQfaWoAdQ9lx+NuoHvm/Mfdsq+OPNNyjgwRDWsRqhRRp57TafXMwenWZwAd2kHNo/pM0vBI+7tQjxZmIczMGQ0Eujh4yQ== X-Google-Smtp-Source: AGHT+IFN1oiE+pkm4oobMtf+YQoYLGiKhcI3fHX+BIcvwSk371RIwJC1SnSK/K98eYOs1Z31/JbK X-Received: by 2002:a05:6a20:e605:b0:1a1:e83:8eb4 with SMTP id my5-20020a056a20e60500b001a10e838eb4mr4036832pzb.9.1709115128323; Wed, 28 Feb 2024 02:12:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709115128; cv=pass; d=google.com; s=arc-20160816; b=kB7uShwo9BSZ7jMaZvZF01zNVhN6nvb/MNvM1uQXIVjkvryhzJ0/ThkvGLrkubOo+o GuwJAUXoN1T5F9rlp2xKK/UW0pftCK4LN6XSjioqLi2rfnHCt0s7+MvofWYyZ55Hke+Z JK8M0kPW8IixOxV4ZS9ErgRqb2hYxY8n5N3iTPTcZrWLAE6McQ4OXqFzwYGpBu8elhGH U0JTQVJ8q3YH+Yo81FGQq36z4jZfeYoG6e/wm85nc4Ds7QzkTqEj+HmmEW7wR1YEEp0g McQsSaXEQVbI1lVPszal0wLa+zKxnadnQdE2eUwI/5YAd0zbuhxwyo42tPGU4cQrPTMx 7SyA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=LrnkpejSqhcF9JYa98EHYfWHPhb164YL0Ul7jes8SbM=; fh=zqmxroAcWyumCCZXuyzFrFV0OkymEHVN0qHBlD/X0XE=; b=u0RHYuPwKT1QkUg45UTmIZCNo0ny8pJuSHRwqfVr/FbfXLlKwHHCI7wqwZAG9IgS2Q nECblYnGBOzpKUQfcqzFqZm15Ps6NENU4rfzVyDt4e/esf4SEGDmB3vmGQPmVJokhW5l V6IPL7nlzdlH30zWn5pkOUT6s8bc1AbVMjBgVsC27ooE3tc7lV15yX3BrBz9jJQb+3LD 8tQ8/BdwdboPF/uN1ZMKmEeSB1Z3x+rxmhLBGhGp/6DUgeamVPktPrqx1XesHeyZagdw eLTzk2dXq58MLC3Pcp9J5nLz4TnbWi3Rr4f8RIALrkbbf7xi0IAybj/jvZ8ZpI/FT30x zdAg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="K/Uz8Rwr"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=t6X1lfYr; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-84815-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84815-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id x17-20020a1709027c1100b001dcb4a30697si2960494pll.108.2024.02.28.02.12.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 02:12:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84815-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="K/Uz8Rwr"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=t6X1lfYr; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-84815-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84815-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6D594282D94 for ; Wed, 28 Feb 2024 10:11:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 440AD3770D; Wed, 28 Feb 2024 10:11:32 +0000 (UTC) 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" 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 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: 7bit The following commit has been merged into the x86/boot branch of tip: Commit-ID: 11e36b0f7c2150a6453872b79555767b43c846d0 Gitweb: https://git.kernel.org/tip/11e36b0f7c2150a6453872b79555767b43c846d0 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 startup_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))); DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page); +DECLARE_INIT_PER_CPU(gdt_page); /* 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 = __VMEMMAP_BASE_L4; EXPORT_SYMBOL(vmemmap_base); #endif -/* - * GDT used on the boot CPU before switching to virtual addresses. - */ -static struct desc_struct startup_gdt[GDT_ENTRIES] __initdata = { - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(DESC_CODE32, 0, 0xfffff), - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(DESC_CODE64, 0, 0xfffff), - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(DESC_DATA64, 0, 0xfffff), -}; - #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 = NULL; struct desc_ptr startup_gdt_descr = { - .address = (unsigned long)&RIP_REL_REF(startup_gdt), - .size = sizeof(startup_gdt) - 1, + .address = (unsigned long)&RIP_REL_REF(init_per_cpu_var(gdt_page.gdt)), + .size = GDT_SIZE - 1, }; /* Load GDT */