From nobody Thu Apr 16 17:38:43 2026 Received: from mail.alien8.de (mail.alien8.de [65.109.113.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40C763D7D63 for ; Thu, 26 Feb 2026 14:51:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=65.109.113.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772117466; cv=none; b=pNmaMbzwZjVXlAsrwL/Uo9EF/TedC0379MDCzqXXzXchdnz9PE70rNG7pgRrqr7CFP6sI1SCyj6cH3SokukdFdfadyKON0qAWLZ6/kqueMXxcZqFihCZx9bRZaOu8u+QPZhcLsBMzgGhelSKq42sBQyPdmrp19k2E6ChfEVMkL0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772117466; c=relaxed/simple; bh=mZA8j7zTeYOpp0RE4hMqig7rib0zf8raqHGayc6Qgrc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=sL2XCwLGDn7C32ya3xqH2dygHYw40ib+NC02Yi6XG2kffMDGb3KFODlPHx3Sqs4EcPCDSXFyaRqdT1o7sdoklZKDxSQfexmSG7yMRH+IDwiShrDXktYuj8IYKnZ3osW59X14pPTI9gmpaDt7omer49i9fIldsJTJ636m+cDRy8U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=alien8.de; spf=pass smtp.mailfrom=alien8.de; dkim=pass (4096-bit key) header.d=alien8.de header.i=@alien8.de header.b=JeFkg7YI; arc=none smtp.client-ip=65.109.113.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=alien8.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=alien8.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (4096-bit key) header.d=alien8.de header.i=@alien8.de header.b="JeFkg7YI" Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTP id AF81240E0169; Thu, 26 Feb 2026 14:50:59 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at mail.alien8.de Authentication-Results: mail.alien8.de (amavisd-new); dkim=pass (4096-bit key) header.d=alien8.de Received: from mail.alien8.de ([127.0.0.1]) by localhost (mail.alien8.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id zO6bcDB_XhGn; Thu, 26 Feb 2026 14:50:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=alien8; t=1772117452; bh=7gyudwtLp/CazyHdoCzVPmwXehlgpTi9DMzxDq4EctI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JeFkg7YI+uVZLjnXXfU1mldwsVtqquQsm4UsvK40pKXqp6e//2lDmjQ6OWKnXeWAp 65CX3Bi1DCdFv3KhsBQNnjP2aXh78fc7dALfN2HCmlfJ6inOs9XYN7naTVsxXocvIq cK2V/5O8Sj1BCM9neKK7h9gTTcGRGyNgLV9kYZKZDvucdnfIvPe3nb4fma0C1fk4Pe p2JA/M3HwntdrilBZ/l402wY0qhZgPyidzRmaz3tjTKtaNMwSmWLpZWd73lMw5HuWo U5Kz39yA22MYIQVMlU1nXRYH4FvIJsL5qGgbTanAljpR7KoWfnPnolUzHdTaBObgZy brFfTFSEhJyyhRWKOwI/9tQ1Iw9Orq2/ILju5LJbr9rIUI0geUNl3wWEU4DV8zAMSh FbtKNNFbTMDaU+4/CUK9TdSjuSR0l+lwJodaYblpBQty6XcLuXgtyMsXhjOnMMtHHF JmTn1FvCFcPnPBH2fR65zVG1rse0ThS2Tan7QAT0FAUQA0Mhwwni42LkGk28Vh7we1 geL3s9KHGC5dnOiPbhKrgyj/DIl3lKckDC4RLa7933spkeLmzjTQ7vomIe9drVzc1a JDX+qTpS9d0r1JQasI/SqQb/A6EpxDidg802OU3bkpozBEAuX4D/WCZB0jcMxw1GuX 2dsHyqMLbbB9p0vRrYQ5v/ac= Received: from zn.tnic (pd9530374.dip0.t-ipconnect.de [217.83.3.116]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with UTF8SMTPSA id 84EFA40E00DE; Thu, 26 Feb 2026 14:50:42 +0000 (UTC) Date: Thu, 26 Feb 2026 15:50:33 +0100 From: Borislav Petkov To: "Luck, Tony" Cc: "Li, Xiaoyao" , Rong Zhang , Thomas Gleixner , Ingo Molnar , Dave Hansen , "x86@kernel.org" , "H. Peter Anvin" , Fenghua Yu , "linux-kernel@vger.kernel.org" Subject: [PATCH -v2] x86/split_lock: Restructure the unwieldy switch-case in sld_state_show() Message-ID: <20260226145033.GAaaBduQ0rWXydOkAm@fat_crate.local> References: <20251215182907.152881-1-i@rong.moe> <20260104191726.GEaVq8xqi0OhsIs284@fat_crate.local> <20260107112835.GBaV5DY1sc3HeLKINb@fat_crate.local> <20260108103850.GAaV-JOgVZNHuZIkBh@fat_crate.local> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20260108103850.GAaV-JOgVZNHuZIkBh@fat_crate.local> Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" A bit better version: Reviewed-by: Xiaoyao Li --- From: "Borislav Petkov (AMD)" Date: Sun, 4 Jan 2026 14:40:23 +0100 Split the handling in two parts: 1. handle the sld_state option first 2. handle X86_FEATURE flag-based printing afterwards This splits the function nicely into two, separate logical things which are easier to parse and understand. Also, zap the printing in the disabled case. Signed-off-by: Borislav Petkov (AMD) --- arch/x86/kernel/cpu/bus_lock.c | 49 +++++++++++++++++----------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/arch/x86/kernel/cpu/bus_lock.c b/arch/x86/kernel/cpu/bus_lock.c index fb166662bc0d..153cfeb99dca 100644 --- a/arch/x86/kernel/cpu/bus_lock.c +++ b/arch/x86/kernel/cpu/bus_lock.c @@ -391,34 +391,35 @@ static void __init split_lock_setup(struct cpuinfo_x8= 6 *c) =20 static void sld_state_show(void) { - if (!boot_cpu_has(X86_FEATURE_BUS_LOCK_DETECT) && - !boot_cpu_has(X86_FEATURE_SPLIT_LOCK_DETECT)) + const char *action =3D "warning"; + + if ((!boot_cpu_has(X86_FEATURE_BUS_LOCK_DETECT) && + !boot_cpu_has(X86_FEATURE_SPLIT_LOCK_DETECT)) || + (sld_state =3D=3D sld_off)) return; =20 - switch (sld_state) { - case sld_off: - pr_info("disabled\n"); - break; - case sld_warn: - if (boot_cpu_has(X86_FEATURE_SPLIT_LOCK_DETECT)) { - pr_info("#AC: crashing the kernel on kernel split_locks and warning on = user-space split_locks\n"); - if (cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, - "x86/splitlock", NULL, splitlock_cpu_offline) < 0) - pr_warn("No splitlock CPU offline handler\n"); - } else if (boot_cpu_has(X86_FEATURE_BUS_LOCK_DETECT)) { - pr_info("#DB: warning on user-space bus_locks\n"); - } - break; - case sld_fatal: - if (boot_cpu_has(X86_FEATURE_SPLIT_LOCK_DETECT)) - pr_info("#AC: crashing the kernel on kernel split_locks and sending SIG= BUS on user-space split_locks\n"); - else if (boot_cpu_has(X86_FEATURE_BUS_LOCK_DETECT)) - pr_info("#DB: sending SIGBUS on user-space bus_locks\n"); - break; - case sld_ratelimit: + if (sld_state =3D=3D sld_ratelimit) { if (boot_cpu_has(X86_FEATURE_BUS_LOCK_DETECT)) pr_info("#DB: setting system wide bus lock rate limit to %u/sec\n", bld= _ratelimit.burst); - break; + return; + } else if (sld_state =3D=3D sld_fatal) { + action =3D "sending SIGBUS"; + } + + if (boot_cpu_has(X86_FEATURE_SPLIT_LOCK_DETECT)) { + pr_info("#AC: crashing the kernel on kernel split_locks and %s on user-s= pace split_locks\n", action); + + /* + * This is handling the case where a CPU goes offline at the + * moment where split lock detection is disabled in the warn + * setting, see split_lock_warn(). It doesn't have any effect + * in the fatal case. + */ + if (cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "x86/splitlock", NULL, splitl= ock_cpu_offline) < 0) + pr_warn("No splitlock CPU offline handler\n"); + + } else if (boot_cpu_has(X86_FEATURE_BUS_LOCK_DETECT)) { + pr_info("#DB: %s on user-space bus_locks\n", action); } } =20 --=20 2.51.0 --=20 Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette