The branch stable/15 has been updated by kib:

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

commit d95433ec84b973c7e6ab819bbf4fb5bbcb829d2a
Author:     Konstantin Belousov <[email protected]>
AuthorDate: 2026-09-18 14:33:54 +0000
Commit:     Konstantin Belousov <[email protected]>
CommitDate: 2026-09-29 00:27:15 +0000

    amd64: add userspace control for disabling splitlocks
    
    (cherry picked from commit 51cea5416a2421f29d22100bc71ab6486b1dc54a)
---
 sys/amd64/amd64/sys_machdep.c | 27 ++++++++++++++++++++++++++-
 sys/x86/include/sysarch.h     |  2 ++
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/sys/amd64/amd64/sys_machdep.c b/sys/amd64/amd64/sys_machdep.c
index 1df73a25c05e..02b2567dd8e9 100644
--- a/sys/amd64/amd64/sys_machdep.c
+++ b/sys/amd64/amd64/sys_machdep.c
@@ -179,7 +179,7 @@ sysarch(struct thread *td, struct sysarch_args *uap)
        struct i386_set_pkru i386pkru;
        struct amd64_get_xfpustate a64xfpu;
        struct amd64_set_pkru a64pkru;
-       int error;
+       int error, val;
 
 #ifdef CAPABILITY_MODE
        /*
@@ -198,6 +198,8 @@ sysarch(struct thread *td, struct sysarch_args *uap)
        case I386_GET_XFPUSTATE:
        case I386_SET_PKRU:
        case I386_CLEAR_PKRU:
+       case I386_SET_SPLITLOCK:
+       case I386_GET_SPLITLOCK:
        case AMD64_GET_FSBASE:
        case AMD64_SET_FSBASE:
        case AMD64_GET_GSBASE:
@@ -266,6 +268,10 @@ sysarch(struct thread *td, struct sysarch_args *uap)
                    sizeof(struct amd64_set_pkru))) != 0)
                        return (error);
                break;
+       case I386_SET_SPLITLOCK:
+               if ((error = copyin(uap->parms, &val, sizeof(val))) != 0)
+                       return (error);
+               break;
        default:
                break;
        }
@@ -426,6 +432,25 @@ sysarch(struct thread *td, struct sysarch_args *uap)
                update_pcb_bases(pcb);
                break;
 
+       case I386_SET_SPLITLOCK:
+               if (!ia32_splitlock) {
+                       if (val != 0)
+                               error = ENOTSUP;
+                       break;
+               }
+               if (val == 0)
+                       disable_splitlock(td);
+               else if (val == 1)
+                       enable_splitlock(td);
+               else
+                       error = EINVAL;
+               break;
+
+       case I386_GET_SPLITLOCK:
+               val = (td->td_md.md_td_flags & TDF_MD_SPLITLOCK_AC) != 0;
+               error = copyout(&val, uap->parms, sizeof(val));
+               break;
+
        default:
                error = EINVAL;
                break;
diff --git a/sys/x86/include/sysarch.h b/sys/x86/include/sysarch.h
index cf7ee9ee5518..8fda776a3b08 100644
--- a/sys/x86/include/sysarch.h
+++ b/sys/x86/include/sysarch.h
@@ -52,6 +52,8 @@
 #define        I386_GET_XFPUSTATE      11
 #define        I386_SET_PKRU           12
 #define        I386_CLEAR_PKRU         13
+#define        I386_SET_SPLITLOCK      14
+#define        I386_GET_SPLITLOCK      15
 
 /* Leave space for 0-127 for to avoid translating syscalls */
 #define        AMD64_GET_FSBASE        128

Reply via email to