amd64: calculate if hardware supports disabling splitlocks

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:40 +03:00
1 parent c6d7235ac1
commit d8c1abb0e3
3 files changed
+32

No files matched your search

+18
View File
@@ -440,3 +440,21 @@ amd64_cpu_init_fred(void)
printf("FRED enabled\n");
}
void
amd64_init_splitlock(void)
{
uint64_t msr;
if ((cpu_stdext_feature3 & CPUID_STDEXT3_CORE_CAP) != 0) {
if (rdmsr_safe(MSR_IA32_CORE_CAP, &msr) == 0)
ia32_splitlock = (msr & IA32_CORE_CAP_SPLITLOCK) != 0;
}
if (ia32_splitlock) {
TUNABLE_INT_FETCH("hw.splitlock_force", &ia32_splitlock_force);
if (ia32_splitlock_force != 0)
ia32_splitlock_force = 1;
} else {
ia32_splitlock_force = 0;
}
}
+11
View File
@@ -206,6 +206,15 @@ long realmem = 0;
int late_console = 1;
int lass_enabled = 0;
int ia32_splitlock = 0;
SYSCTL_INT(_hw, OID_AUTO, splitlock, CTLFLAG_RD,
&ia32_splitlock, 0,
"splitlock prevention supported");
int ia32_splitlock_force = 1;
SYSCTL_INT(_hw, OID_AUTO, splitlock_force, CTLFLAG_RDTUN | CTLFLAG_NOFETCH,
&ia32_splitlock_force, 0,
"splitlock prevention enabled by default");
int __read_frequently fred = 0;
SYSCTL_INT(_hw, OID_AUTO, fred, CTLFLAG_RDTUN | CTLFLAG_NOFETCH,
&fred, 0,
@@ -1648,6 +1657,8 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)
/* setup proc 0's pcb */
thread0.td_pcb->pcb_flags = 0;
amd64_init_splitlock();
env = kern_getenv("kernelname");
if (env != NULL)
strlcpy(kernelname, env, sizeof(kernelname));
+3
View File
@@ -46,6 +46,8 @@ extern int hw_ssb_disable;
extern int nmi_flush_l1d_sw;
extern int syscall_ret_l1d_flush_mode;
extern int lass_enabled;
extern int ia32_splitlock;
extern int ia32_splitlock_force;
extern vm_paddr_t intel_graphics_stolen_base;
extern vm_paddr_t intel_graphics_stolen_size;
@@ -67,6 +69,7 @@ struct trapframe;
void amd64_conf_fast_syscall(void);
void amd64_cpu_init_fred(void);
void amd64_db_resume_dbreg(void);
void amd64_init_splitlock(void);
vm_paddr_t amd64_loadaddr(void);
void amd64_lower_shared_page(struct sysentvec *);
void amd64_bsp_pcpu_init1(struct pcpu *pc);