From: Brian Gerst <brgerst@gmail.com>
To: linux-kernel@vger.kernel.org, x86@kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Borislav Petkov <bp@alien8.de>, "H . Peter Anvin" <hpa@zytor.com>,
Peter Zijlstra <peterz@infradead.org>,
Linus Torvalds <torvalds@linuxfoundation.org>,
Brian Gerst <brgerst@gmail.com>
Subject: [PATCH 1/3] x86: Move TSS and LDT to end of the GDT
Date: Wed, 13 Dec 2023 11:34:41 -0500 [thread overview]
Message-ID: <20231213163443.70490-2-brgerst@gmail.com> (raw)
In-Reply-To: <20231213163443.70490-1-brgerst@gmail.com>
This will make testing for system segments easier.
Signed-off-by: Brian Gerst <brgerst@gmail.com>
---
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
--
2.43.0
next prev parent reply other threads:[~2023-12-13 16:34 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-13 16:34 [PATCH 0/3] Reject setting system segments from userspace Brian Gerst
2023-12-13 16:34 ` Brian Gerst [this message]
2023-12-13 18:51 ` [PATCH 1/3] x86: Move TSS and LDT to end of the GDT Linus Torvalds
2023-12-13 19:08 ` Linus Torvalds
2023-12-16 18:24 ` Vegard Nossum
2023-12-16 18:40 ` Linus Torvalds
2023-12-17 21:09 ` H. Peter Anvin
2023-12-13 16:34 ` [PATCH 2/3] x86/ptrace: Reject system segements Brian Gerst
2023-12-13 16:34 ` [PATCH 3/3] x86/sigreturn: " Brian Gerst
2023-12-13 18:54 ` Linus Torvalds
2023-12-17 21:07 ` H. Peter Anvin
2023-12-17 21:40 ` Linus Torvalds
2023-12-17 21:45 ` H. Peter Anvin
2023-12-18 8:31 ` Li, Xin3
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231213163443.70490-2-brgerst@gmail.com \
--to=brgerst@gmail.com \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linuxfoundation.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.