From patchwork Wed Dec 20 10:04:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 181567 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2532887dyi; Wed, 20 Dec 2023 02:06:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IEdl0buErDeyvfEV+8enBb4tPp0IX/OE1qeD+m8/yepvGO426fFB7t14eap4bh/TMwbk+vN X-Received: by 2002:a05:6808:f91:b0:3b8:7f1b:df8d with SMTP id o17-20020a0568080f9100b003b87f1bdf8dmr22973447oiw.35.1703066806084; Wed, 20 Dec 2023 02:06:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703066806; cv=none; d=google.com; s=arc-20160816; b=Go6LO0FnNcHNtibmtpyWQOBJ9O8mruBYFmhAoKe8n8kOVvuS78LMIIPM7PcfThPSg1 ZJpupSAFSh8+dNsbe2rY1ZP1NI2m1c5L8laHMffTCMNBDPNzwMYwqlsfRA12J0UOUyO5 Q1bLuejWAsVeDdG9+COT40GFmuBpHP3XmIIpfQw2Y6lsd1P4Vr3vDkFkpiojiq53gXF7 rj524nLfYOqogb/TorhiPxIzrgTuFgUbI+yamcZZYug6ellUG7KrGeAdyNrVNeb31vYV 9jjvsNgzaJGBP9aBvhCNzFRU44Guu2VuskGKFi24hcASMP/H0lT0syBbSMMx/qu3Sn/i FCXQ== ARC-Message-Signature: i=1; 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=1NQst+VHifrVkSDrISNwkDvKh+Nr0RWNByBHjKD+YH4=; fh=d3rITi3gY706tNT9KFsDpD/R32FlLciJYQ0Rks1Xg5k=; b=EpTTGpzFXJjDePugPzsG7apiJ4UdDJEJq6zP7A7IooF6DP6LEJEuo8C3ElsOl8AtFV ZoTNOoIQpIvqos4zHDJBHqp644sAm2TD8jvCT9xw9PGDvy8VxwRd0MMFOcoF6woz1RsH KLcmo07ZlcwzY7lyOvassHubP/vGBEw89FN8YnqwPyAA5yTtigjQRPNoCznriJzjCjL2 XkGzBIiRYpTsKfxyv71+cbGweVnZ0Kfj+JjJY26NevTthODZ3MRU+vTp9wpPsN7D4FRs z916ME0ADrceZFgjP3z0fSFr60n8pinQhFb9uooYPT8sR9krJrqdeOmEvAwi0U1x4xtz 5JRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="Df/ktfVZ"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=qAE9+yGC; spf=pass (google.com: domain of linux-kernel+bounces-6685-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6685-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id b19-20020a0cb3d3000000b0067f3c44ed2esi7075363qvf.564.2023.12.20.02.06.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 02:06:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6685-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="Df/ktfVZ"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=qAE9+yGC; spf=pass (google.com: domain of linux-kernel+bounces-6685-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6685-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 883F21C25714 for ; Wed, 20 Dec 2023 10:06:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 33E74249EE; Wed, 20 Dec 2023 10:04:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Df/ktfVZ"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="qAE9+yGC" X-Original-To: linux-kernel@vger.kernel.org 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 CF0DB20B1D; Wed, 20 Dec 2023 10:04:02 +0000 (UTC) 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, 20 Dec 2023 10:04:00 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1703066641; 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=1NQst+VHifrVkSDrISNwkDvKh+Nr0RWNByBHjKD+YH4=; b=Df/ktfVZ+8jmmpkt0QKbp24GM2H1bSsCgLNeO3CCAArjkKmXlAq4XvDzn3ehUIjmBni3fO fcnXO5BWrd5LYgxP2TaG9nfqMUeL95qQXvpzjMG/Mgc1JZFrIHvNtJMUVZPtqBXVi4ogTl Rfikg6WHrpS/oeNk46z1Ma5Cc0uPQ1q4FVIJgm3QTpW1xbRV0zWjUQEL4Mo/p5eyZdDpWU mg8r4b7UpqVfMSEjkquO57MTgz0s3588N7q+YaoI3FCWLgUyyK26TRCs+dy2eJh7vmnM85 GF2FeH2umw/+4oNlpGzeBmEZr7bn8uq22Od1y/QuzVyjB11tlv78CFv0LuTuXA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1703066641; 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=1NQst+VHifrVkSDrISNwkDvKh+Nr0RWNByBHjKD+YH4=; b=qAE9+yGCyQFuv3vmBsOT3RSxtLOqYh+ON6I9r+VgMqfHpYNYvNLIV+owe1OhL5FQJVFMOr 5dq7LDHD6tbSRPAg== From: "tip-bot2 for Vegard Nossum" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/asm] x86/asm: Always set A (accessed) flag in GDT descriptors Cc: Vegard Nossum , Ingo Molnar , Linus Torvalds , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231219151200.2878271-5-vegard.nossum@oracle.com> References: <20231219151200.2878271-5-vegard.nossum@oracle.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <170306664044.398.8301222392360848816.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785794978918537640 X-GMAIL-MSGID: 1785794978918537640 The following commit has been merged into the x86/asm branch of tip: Commit-ID: 3b184b71dfcb156e08246f8fbe0cd088c6a6efed Gitweb: https://git.kernel.org/tip/3b184b71dfcb156e08246f8fbe0cd088c6a6efed Author: Vegard Nossum AuthorDate: Tue, 19 Dec 2023 16:11:59 +01:00 Committer: Ingo Molnar CommitterDate: Wed, 20 Dec 2023 10:57:51 +01:00 x86/asm: Always set A (accessed) flag in GDT descriptors We have no known use for having the CPU track whether GDT descriptors have been accessed or not. Simplify the code by adding the flag to the common flags and removing it everywhere else. Signed-off-by: Vegard Nossum Signed-off-by: Ingo Molnar Acked-by: Linus Torvalds Link: https://lore.kernel.org/r/20231219151200.2878271-5-vegard.nossum@oracle.com --- arch/x86/boot/pm.c | 4 ++-- arch/x86/include/asm/desc_defs.h | 4 ++-- arch/x86/kernel/cpu/common.c | 12 ++++++------ arch/x86/kernel/head64.c | 6 +++--- arch/x86/realmode/rm/reboot.S | 2 +- drivers/firmware/efi/libstub/x86-5lvl.c | 4 ++-- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/arch/x86/boot/pm.c b/arch/x86/boot/pm.c index ab35b52..5941f93 100644 --- a/arch/x86/boot/pm.c +++ b/arch/x86/boot/pm.c @@ -68,9 +68,9 @@ static void setup_gdt(void) being 8-byte unaligned. Intel recommends 16 byte alignment. */ static const u64 boot_gdt[] __attribute__((aligned(16))) = { /* CS: code, read/execute, 4 GB, base 0 */ - [GDT_ENTRY_BOOT_CS] = GDT_ENTRY(DESC_CODE32 | _DESC_ACCESSED, 0, 0xfffff), + [GDT_ENTRY_BOOT_CS] = GDT_ENTRY(DESC_CODE32, 0, 0xfffff), /* DS: data, read/write, 4 GB, base 0 */ - [GDT_ENTRY_BOOT_DS] = GDT_ENTRY(DESC_DATA32 | _DESC_ACCESSED, 0, 0xfffff), + [GDT_ENTRY_BOOT_DS] = GDT_ENTRY(DESC_DATA32, 0, 0xfffff), /* TSS: 32-bit tss, 104 bytes, base 4096 */ /* We only have a TSS here to keep Intel VT happy; we don't actually use it for anything. */ diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h index 33d229e..d440a65 100644 --- a/arch/x86/include/asm/desc_defs.h +++ b/arch/x86/include/asm/desc_defs.h @@ -37,9 +37,9 @@ * of flags */ -#define _DESC_DATA (_DESC_S | _DESC_PRESENT | \ +#define _DESC_DATA (_DESC_S | _DESC_PRESENT | _DESC_ACCESSED | \ _DESC_DATA_WRITABLE) -#define _DESC_CODE (_DESC_S | _DESC_PRESENT | \ +#define _DESC_CODE (_DESC_S | _DESC_PRESENT | _DESC_ACCESSED | \ _DESC_CODE_READABLE | _DESC_CODE_EXECUTABLE) #define DESC_DATA16 (_DESC_DATA) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 32934a0..6184488 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -188,12 +188,12 @@ DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = { * TLS descriptors are currently at a different place compared to i386. * Hopefully nobody expects them at a fixed place (Wine?) */ - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(DESC_CODE32 | _DESC_ACCESSED, 0, 0xfffff), - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(DESC_CODE64 | _DESC_ACCESSED, 0, 0xfffff), - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(DESC_DATA64 | _DESC_ACCESSED, 0, 0xfffff), - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(DESC_CODE32 | DESC_USER | _DESC_ACCESSED, 0, 0xfffff), - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(DESC_DATA64 | DESC_USER | _DESC_ACCESSED, 0, 0xfffff), - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(DESC_CODE64 | DESC_USER | _DESC_ACCESSED, 0, 0xfffff), + [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), + [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(DESC_CODE32 | DESC_USER, 0, 0xfffff), + [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(DESC_DATA64 | DESC_USER, 0, 0xfffff), + [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(DESC_CODE64 | DESC_USER, 0, 0xfffff), #else [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(DESC_CODE32, 0, 0xfffff), [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(DESC_DATA32, 0, 0xfffff), diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c index 00dbddf..dc09560 100644 --- a/arch/x86/kernel/head64.c +++ b/arch/x86/kernel/head64.c @@ -71,9 +71,9 @@ EXPORT_SYMBOL(vmemmap_base); * 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 | _DESC_ACCESSED, 0, 0xfffff), - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(DESC_CODE64 | _DESC_ACCESSED, 0, 0xfffff), - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(DESC_DATA64 | _DESC_ACCESSED, 0, 0xfffff), + [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), }; /* diff --git a/arch/x86/realmode/rm/reboot.S b/arch/x86/realmode/rm/reboot.S index 5bc068b..e714b46 100644 --- a/arch/x86/realmode/rm/reboot.S +++ b/arch/x86/realmode/rm/reboot.S @@ -154,5 +154,5 @@ SYM_DATA_START(machine_real_restart_gdt) * base value 0x100; since this is consistent with real mode * semantics we don't have to reload the segments once CR0.PE = 0. */ - .quad GDT_ENTRY(DESC_DATA16 | _DESC_ACCESSED, 0x100, 0xffff) + .quad GDT_ENTRY(DESC_DATA16, 0x100, 0xffff) SYM_DATA_END(machine_real_restart_gdt) diff --git a/drivers/firmware/efi/libstub/x86-5lvl.c b/drivers/firmware/efi/libstub/x86-5lvl.c index 005dd9b..77359e8 100644 --- a/drivers/firmware/efi/libstub/x86-5lvl.c +++ b/drivers/firmware/efi/libstub/x86-5lvl.c @@ -13,8 +13,8 @@ bool efi_no5lvl; static void (*la57_toggle)(void *cr3); static const struct desc_struct gdt[] = { - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(DESC_CODE32 | _DESC_ACCESSED, 0, 0xfffff), - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(DESC_CODE64 | _DESC_ACCESSED, 0, 0xfffff), + [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(DESC_CODE32, 0, 0xfffff), + [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(DESC_CODE64, 0, 0xfffff), }; /*