From nobody Tue Sep 22 15:41:49 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4hq48Y5fdSz6sNdL for ; Tue, 22 Sep 2026 15:41:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hq48Y4vxKz4vW9 for ; Tue, 22 Sep 2026 15:41:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1790091709; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=2AN8BCBapbpDkbUnJdpKlo/lCqGvtE4uF8wq4mC2yu0=; b=W/UJ57uHH/OBYqqg62CbuPqcDtlfYnJ1yY861fdBxJa9CfcGH07HLnavrkYp+gesBck/o0 tGxX5AHLqYWIjFStpDQhPX02BI+b/881qKjr31iFp6rCPxniF4d/r3oElrbidU/L0+sPf1 mG7MTyeOlUyLqfgxx9psqLJZnKPEnm6G4PIT/mdQgyFSVDBWL2KTDvtyElD2sRgOIyui0x QblmvNdthFw0mc2115RM72VUJ57h9E0cBc5aYzell/e1wFvYtVlq845ncWkwdJI9O+O6wP 5lkOOERPAEpgltggAJgyoWp3goczyC1AYj8kWqBxlot2CQK4eCbF+5zZgvo9rA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1790091709; b=IV63A8Fa9OjNjYVLPigBdTIF8tKL+RmUd+bo/o9wobr/xQz4LehhVinq0CCEAsd4TCDl20 VfcVg42EFTo5ilxVo0oHbGR4z3iiYmeuE/ETprRY1RfCP6c4YAdT2LQWfNbo4s4a8j18SG 9S7NgQ0Hma3Wx9DQrN9kjQLj1TzEg/bnWW7RYvcwtFxww5NqFzMlatxt9w3NiR8Vtv4Rw8 8nqztWEMU39gOiIcc0EgqMXmhruqcnSnKBiWPVkOnp9K/JjQhF1CALITZxmA7/r5JDHYtP YAZl53Yt3nNJcIqzMVL4a40Kv6wuW7a3gF7nfmGAuVoXjtSNauPhtEpn9lq4EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1790091709; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=2AN8BCBapbpDkbUnJdpKlo/lCqGvtE4uF8wq4mC2yu0=; b=Vu8g04tbuc0Qxj8QYDygKZszBpagZAp+DnJgshPFqhatrXH/H613zaqz5WYv+KhKrMBUpL DWfYgcR9JahWOJGbt1NNSK3wwgCcpgVwLZM9Zf0+TnHGsFCGDRuT4e2RUtBsUleYGNNKxi Ljm/qboWMs5zbLq0chZzUBikXszpGbWd0m8T0gUPLV7DOmzkcRohmxoXmdwjcliedDx7DV j3p3rqgBWQZMHVfUnl3sw1nbwr0lVmhymx4ElL1QyrAoWPT9nojeWz/PkptA6cgdf+4jpF mD7y7uM/7l3rwrAdjJlrSfxm8Wdkfe0owB6uRYO/g3XS4PXDyljRyTDiC5ngJg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hq48Y3W0Hz1CCk for ; Tue, 22 Sep 2026 15:41:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3636f by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 22 Sep 2026 15:41:49 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: d8c1abb0e340 - main - amd64: calculate if hardware supports disabling splitlocks List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d8c1abb0e3409314fb89400bc85b5051649e91ab Auto-Submitted: auto-generated Date: Tue, 22 Sep 2026 15:41:49 +0000 Message-Id: <6ab2a1bd.3636f.30ae05f@gitrepo.freebsd.org> The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=d8c1abb0e3409314fb89400bc85b5051649e91ab commit d8c1abb0e3409314fb89400bc85b5051649e91ab Author: Konstantin Belousov AuthorDate: 2026-09-18 14:33:54 +0000 Commit: Konstantin Belousov CommitDate: 2026-09-22 15:40:40 +0000 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 --- sys/amd64/amd64/initcpu.c | 18 ++++++++++++++++++ sys/amd64/amd64/machdep.c | 11 +++++++++++ sys/amd64/include/md_var.h | 3 +++ 3 files changed, 32 insertions(+) diff --git a/sys/amd64/amd64/initcpu.c b/sys/amd64/amd64/initcpu.c index 5b615be4b8dc..4ae79693addf 100644 --- a/sys/amd64/amd64/initcpu.c +++ b/sys/amd64/amd64/initcpu.c @@ -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; + } +} diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index c6a77c5ef852..c34dd7818b8c 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -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)); diff --git a/sys/amd64/include/md_var.h b/sys/amd64/include/md_var.h index d51cfae510e7..a46ae8dfe794 100644 --- a/sys/amd64/include/md_var.h +++ b/sys/amd64/include/md_var.h @@ -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);