bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 4/4] x86_64: set user segments as 64-bit if ! USER32


From: Luca Dariz
Subject: [PATCH 4/4] x86_64: set user segments as 64-bit if ! USER32
Date: Thu, 16 Feb 2023 22:33:18 +0100

* i386/i386/ldt.c: set the L bit if user-space is 64-bit
---
 i386/i386/ldt.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/i386/i386/ldt.c b/i386/i386/ldt.c
index 70fa24e2..b86a0e3c 100644
--- a/i386/i386/ldt.c
+++ b/i386/i386/ldt.c
@@ -45,6 +45,12 @@ extern
 #endif /* MACH_PV_DESCRIPTORS */
 struct real_descriptor ldt[LDTSZ];
 
+#if defined(__x86_64__) && ! defined(USER32)
+#define USER_SEGMENT_SIZEBITS SZ_64
+#else
+#define USER_SEGMENT_SIZEBITS SZ_32
+#endif
+
 void
 ldt_fill(struct real_descriptor *myldt, struct real_descriptor *mygdt)
 {
@@ -67,11 +73,11 @@ ldt_fill(struct real_descriptor *myldt, struct 
real_descriptor *mygdt)
                            VM_MIN_USER_ADDRESS,
                            VM_MAX_USER_ADDRESS-VM_MIN_USER_ADDRESS-4096,
                            /* XXX LINEAR_... */
-                           ACC_PL_U|ACC_CODE_R, SZ_32);
+                           ACC_PL_U|ACC_CODE_R, USER_SEGMENT_SIZEBITS);
        fill_ldt_descriptor(myldt, USER_DS,
                            VM_MIN_USER_ADDRESS,
                            VM_MAX_USER_ADDRESS-VM_MIN_USER_ADDRESS-4096,
-                           ACC_PL_U|ACC_DATA_W, SZ_32);
+                           ACC_PL_U|ACC_DATA_W, USER_SEGMENT_SIZEBITS);
 
        /* Activate the LDT.  */
 #ifdef MACH_PV_DESCRIPTORS
-- 
2.30.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]