git: 0c3b3c7482db - stable/15 - amd64 cpufunc.h: add rcs(), to read code selector

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Sun, 28 Sep 2025 00:47:13 UTC
The branch stable/15 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=0c3b3c7482dbdf854e96268d2afbda91928a648c

commit 0c3b3c7482dbdf854e96268d2afbda91928a648c
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2025-09-19 02:37:14 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2025-09-28 00:43:50 +0000

    amd64 cpufunc.h: add rcs(), to read code selector
    
    (cherry picked from commit 50ee990e1874d6d40b8e3dc359c37e2ef2ebf477)
---
 sys/amd64/include/cpufunc.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/sys/amd64/include/cpufunc.h b/sys/amd64/include/cpufunc.h
index e6c9f47ea261..9a4c82275a99 100644
--- a/sys/amd64/include/cpufunc.h
+++ b/sys/amd64/include/cpufunc.h
@@ -572,6 +572,15 @@ rss(void)
 	return (sel);
 }
 
+static __inline u_short
+rcs(void)
+{
+	u_short sel;
+
+	__asm __volatile("movw %%cs,%0" : "=rm" (sel));
+	return (sel);
+}
+
 static __inline void
 load_ds(u_short sel)
 {