git: 49e940dbc6ce - stable/14 - amd64: Add AMD64_DISABLE_TLSBASE

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Thu, 12 Jun 2025 18:03:11 UTC
The branch stable/14 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=49e940dbc6ce2e9a97798b0662af49a7705cb79a

commit 49e940dbc6ce2e9a97798b0662af49a7705cb79a
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2025-05-30 21:58:33 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2025-06-12 18:02:51 +0000

    amd64: Add AMD64_DISABLE_TLSBASE
    
    (cherry picked from commit 3a94bbfdcd09c655031e2a1ae343af6292d97d5d)
---
 sys/amd64/amd64/sys_machdep.c | 6 ++++++
 sys/x86/include/sysarch.h     | 1 +
 2 files changed, 7 insertions(+)

diff --git a/sys/amd64/amd64/sys_machdep.c b/sys/amd64/amd64/sys_machdep.c
index 2acf410b9b1b..a7ee1f49887c 100644
--- a/sys/amd64/amd64/sys_machdep.c
+++ b/sys/amd64/amd64/sys_machdep.c
@@ -210,6 +210,7 @@ sysarch(struct thread *td, struct sysarch_args *uap)
 	case AMD64_CLEAR_PKRU:
 	case AMD64_GET_TLSBASE:
 	case AMD64_SET_TLSBASE:
+	case AMD64_DISABLE_TLSBASE:
 		break;
 
 	case I386_SET_IOPERM:
@@ -397,6 +398,11 @@ sysarch(struct thread *td, struct sysarch_args *uap)
 		vm_map_unlock_read(map);
 		break;
 
+	case AMD64_DISABLE_TLSBASE:
+		clear_pcb_flags(pcb, PCB_TLSBASE);
+		update_pcb_bases(pcb);
+		break;
+
 	default:
 		error = EINVAL;
 		break;
diff --git a/sys/x86/include/sysarch.h b/sys/x86/include/sysarch.h
index a67e5c2265a3..cf7ee9ee5518 100644
--- a/sys/x86/include/sysarch.h
+++ b/sys/x86/include/sysarch.h
@@ -63,6 +63,7 @@
 #define	AMD64_CLEAR_PKRU	134
 #define	AMD64_GET_TLSBASE	135
 #define	AMD64_SET_TLSBASE	136
+#define	AMD64_DISABLE_TLSBASE	137
 
 /* Flags for AMD64_SET_PKRU */
 #define	AMD64_PKRU_EXCL		0x0001