diff options
| author | Konstantin Belousov <kib@FreeBSD.org> | 2026-09-18 14:33:54 +0000 |
|---|---|---|
| committer | Konstantin Belousov <kib@FreeBSD.org> | 2026-09-22 15:40:41 +0000 |
| commit | 51cea5416a2421f29d22100bc71ab6486b1dc54a (patch) | |
| tree | 2803246a7d2b4bba9f4d6cc1189caea9a57d87d1 | |
| parent | e318f24c0f53b52bd280b827509ad752db0497bf (diff) | |
amd64: add userspace control for disabling splitlocks
Thread can control it with sysarch(I386_SET_SPLITLOCK). The global
default is set with hw.splitlock_force.
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D59815
| -rw-r--r-- | sys/amd64/amd64/sys_machdep.c | 27 | ||||
| -rw-r--r-- | sys/x86/include/sysarch.h | 2 |
2 files changed, 28 insertions, 1 deletions
diff --git a/sys/amd64/amd64/sys_machdep.c b/sys/amd64/amd64/sys_machdep.c index 2c6387d2a0d2..0942ed22c8a8 100644 --- a/sys/amd64/amd64/sys_machdep.c +++ b/sys/amd64/amd64/sys_machdep.c @@ -212,7 +212,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 /* @@ -231,6 +231,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: @@ -299,6 +301,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; } @@ -421,6 +427,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 9a8c95d9ae75..094995239043 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 |
