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
This commit is contained in:
Konstantin Belousov committed 2026-09-22 18:40:41 +03:00
1 parent e318f24c0f
commit 51cea5416a
2 files changed
+28 -1

No files matched your search

+26 -1
View File
@@ -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;
+2
View File
@@ -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