From patchwork Wed Dec 13 16:34:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Gerst X-Patchwork-Id: 178157 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp7903100dys; Wed, 13 Dec 2023 08:35:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IF5unaNtwL7EgyA/5oa8kK7aCMPn72nTgt9xGJCOQK2/SzZ3w3TZYAeB2f1CzNqSG06OJAj X-Received: by 2002:a17:902:e752:b0:1d3:45c9:534c with SMTP id p18-20020a170902e75200b001d345c9534cmr2441352plf.29.1702485301992; Wed, 13 Dec 2023 08:35:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702485301; cv=none; d=google.com; s=arc-20160816; b=p+RmZYEuXXkwKfCZi8zLVEy6JJ/U3RFMnQLVucL1+tL66QEEUmqmFp5fBm3ECaQ5lj xMx1KlrxS73LToBameHYMjJ4yir34/lMg5TF36HDM0ahxy+/RPz53lYkqPyU67YZVBL5 B2r0EWQA3MyUN/dfolTAvM9cm7bUcstrhDa9lQf7QhYTUSfqipMeMv2BoZcleXO8o4XN rC/lFXgDxGHxctK54BzggirK2WpP46n/9z02gsuylh03+29IFfQBBWN4oAcjnL6RheTJ Jx6aYv8xXMrBcHoSbSFPTOJNXChMCc4a52IPzE9oeiSYTZ+7/nQceeAU8IEkkAdg5OX+ cqwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zJ6yzzdHCK6etXayum+0eGdCGB2aFZEnSrrZblNix5w=; fh=hGVwEbR+KjbERSNTtzxXLjTmhPUyOh65sEze+4fUHLA=; b=bDH3JDz1Uh5ZWpvVNt/VK5T8GkRp7OdGitQmycTCSx0wGzoXetWzuUxu9C3niKAppQ +uS/oi64RvLglMLcN/uQEdujUo2dpXrzLCTAsm3kiFrb7396HJ0uRfQqFXASmqrYes2V 4PAixFJfphRgD0lHsJeopcQxaQkS14xCVmSwzXX1GjJH1e7yXHy/IFO5nJxTF7r1/pA0 670cxh2q0uNhV2/FAurV74s8JDp73idRCbVLamVJhCiNWkXvkHzxACKGLkrPtDrRu3EY u+AGZ/elaqvFlsu0uFr8YffVGmwRdKgRO4BOd6cpTZ5JaYqwgxeaXaD+bhLMRVgulaZ5 q/Mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=R+YhY2IB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id t6-20020a170902b20600b001cfe0284177si9554724plr.102.2023.12.13.08.35.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 08:35:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=R+YhY2IB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 5B38480A8537; Wed, 13 Dec 2023 08:34:57 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232874AbjLMQeo (ORCPT + 99 others); Wed, 13 Dec 2023 11:34:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232663AbjLMQem (ORCPT ); Wed, 13 Dec 2023 11:34:42 -0500 Received: from mail-oo1-xc2e.google.com (mail-oo1-xc2e.google.com [IPv6:2607:f8b0:4864:20::c2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38C1998 for ; Wed, 13 Dec 2023 08:34:49 -0800 (PST) Received: by mail-oo1-xc2e.google.com with SMTP id 006d021491bc7-59093f6c94aso2375406eaf.0 for ; Wed, 13 Dec 2023 08:34:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702485287; x=1703090087; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zJ6yzzdHCK6etXayum+0eGdCGB2aFZEnSrrZblNix5w=; b=R+YhY2IBlfBgXuGL1bpFveRtSQR9n0PiMGYM4wqdsvdj38EURvCi5SE2KyX7pLol1V Ux74x1K4AUNUKCgGB6WESiM+54J14rLQmvG4l0pqIEHqsSFDrf3IljRU2kfc7SKuIER3 yYIcbJp0DjUKVeFE689yIz32ESMhle7NPXbzOdiBq/oFk2DuOkmbqnk/5LfNPEK7XfAV /GWzoXGYMRD0T6psf3cZFiYarwpKR39/4X3eVd6SLVWsdKmCPB0exQQrjzL7v8zOZiTi 856ydvvV06Dh0PPi5jPsujAhasB1itWXPeIP5PNslI43KOssBndqjG2Ql49PZTExKdY+ kqxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702485287; x=1703090087; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zJ6yzzdHCK6etXayum+0eGdCGB2aFZEnSrrZblNix5w=; b=kcllg9wLL8G7GxQhWPp0tvUUIcgyHr9nctEHDonTbjtElWdnO82p2i057YGJgURvkY k9aQy6ZLv2cg2eQVclX5hL10/6qexyxAGhk/9QgqPSkKwc4PtGUpXkNSFiJr2ty75Bqf 7wcjbZkvvPUZddwv6+WqkXcfnsTIjNzrmhZZ08ED5xT8+5idqp4w+N0ITf+HJXkujWKA 6NjV97YtLfM3hcx35Q6PdIcq1p+TAg8kdfT2JNFnOe7txk0KgURkYIbMT4p0NSUHhmmN uuDCX8zq7WSwjlBblwCqaW6ncCbU3EQH/fJsQqRiVtO1jgCwReNGThuyDXSi6qhFs4z8 M6cA== X-Gm-Message-State: AOJu0Yw5WNEHboq9s01IaLhhinsCSoUOhVg/MfKOfiK8vPB8XvinrYeZ g+abiKtzkXsJOHr0THKlcGYTrDc9rQ== X-Received: by 2002:a4a:e825:0:b0:590:e78e:3e37 with SMTP id d5-20020a4ae825000000b00590e78e3e37mr2884222ood.1.1702485287640; Wed, 13 Dec 2023 08:34:47 -0800 (PST) Received: from citadel.lan ([2600:6c4a:4d3f:6d5c::1019]) by smtp.gmail.com with ESMTPSA id j11-20020a4ad2cb000000b005907ad9f302sm3104901oos.37.2023.12.13.08.34.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 08:34:47 -0800 (PST) From: Brian Gerst To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: Ingo Molnar , Thomas Gleixner , Borislav Petkov , "H . Peter Anvin" , Peter Zijlstra , Linus Torvalds , Brian Gerst Subject: [PATCH 1/3] x86: Move TSS and LDT to end of the GDT Date: Wed, 13 Dec 2023 11:34:41 -0500 Message-ID: <20231213163443.70490-2-brgerst@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231213163443.70490-1-brgerst@gmail.com> References: <20231213163443.70490-1-brgerst@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 13 Dec 2023 08:34:57 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785185228291407500 X-GMAIL-MSGID: 1785185228291407500 This will make testing for system segments easier. Signed-off-by: Brian Gerst --- arch/x86/include/asm/segment.h | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h index 9d6411c65920..a155843d0c37 100644 --- a/arch/x86/include/asm/segment.h +++ b/arch/x86/include/asm/segment.h @@ -83,8 +83,8 @@ * 13 - kernel data segment * 14 - default user CS * 15 - default user DS - * 16 - TSS <=== cacheline #5 - * 17 - LDT + * 16 - unused <=== cacheline #5 + * 17 - unused * 18 - PNPBIOS support (16->32 gate) * 19 - PNPBIOS support * 20 - PNPBIOS support <=== cacheline #6 @@ -97,8 +97,11 @@ * 26 - ESPFIX small SS * 27 - per-cpu [ offset to per-cpu data area ] * 28 - VDSO getcpu - * 29 - unused - * 30 - unused + * + * ------- start of system segments: + * + * 29 - TSS + * 30 - LDT * 31 - TSS for double fault handler */ #define GDT_ENTRY_TLS_MIN 6 @@ -108,8 +111,6 @@ #define GDT_ENTRY_KERNEL_DS 13 #define GDT_ENTRY_DEFAULT_USER_CS 14 #define GDT_ENTRY_DEFAULT_USER_DS 15 -#define GDT_ENTRY_TSS 16 -#define GDT_ENTRY_LDT 17 #define GDT_ENTRY_PNPBIOS_CS32 18 #define GDT_ENTRY_PNPBIOS_CS16 19 #define GDT_ENTRY_PNPBIOS_DS 20 @@ -121,6 +122,10 @@ #define GDT_ENTRY_PERCPU 27 #define GDT_ENTRY_CPUNODE 28 +/* Start of system segments */ + +#define GDT_ENTRY_TSS 29 +#define GDT_ENTRY_LDT 30 #define GDT_ENTRY_DOUBLEFAULT_TSS 31 /* @@ -188,20 +193,22 @@ #define GDT_ENTRY_DEFAULT_USER_DS 5 #define GDT_ENTRY_DEFAULT_USER_CS 6 -/* Needs two entries */ -#define GDT_ENTRY_TSS 8 -/* Needs two entries */ -#define GDT_ENTRY_LDT 10 - #define GDT_ENTRY_TLS_MIN 12 #define GDT_ENTRY_TLS_MAX 14 #define GDT_ENTRY_CPUNODE 15 +/* Start of system segments */ + +/* Needs two entries */ +#define GDT_ENTRY_TSS 16 +/* Needs two entries */ +#define GDT_ENTRY_LDT 18 + /* * Number of entries in the GDT table: */ -#define GDT_ENTRIES 16 +#define GDT_ENTRIES 20 /* * Segment selector values corresponding to the above entries: @@ -219,6 +226,8 @@ #endif +#define GDT_SYSTEM_START GDT_ENTRY_TSS + #define IDT_ENTRIES 256 #define NUM_EXCEPTION_VECTORS 32