From nobody Tue Apr 7 09:22:14 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 CCB74363C52; Fri, 13 Mar 2026 20:23:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773433385; cv=none; b=jF5KWCCGcTAehCTdawya6Um7rvtWQ7f72ED3UAnSvIyREXxC9AbX4DYZb6I5Ha06i2DR93JXFutRp9w2jQKTw6S2MONInHyiwUDlElpY/EHLkrYJDhZMOigjJcyv1tSjwocveyQkmdkvHVxL1+zEpZzYtZnjoUcCko1ByJTCKS4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773433385; c=relaxed/simple; bh=tBiFBSnsci1DhygAgg1IQhwnkKkB8MXoZjUC+YwDa64=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=o8Eiypa7NBMWN3AFZsegt7tykNwOMAoUp+pAP5KNRJLxkVxbP6Wds5PjnjuOcLQSjyH+ztEkU7ZTWvpchGZtL5xSND56gZbGoLCTmIVX/mCVECuMJfBQkRUUMteLYe4Y1cJwQeV3HAJ07IzflxdU+P7vzPxhgFX0vKf50GKvUOs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=RFZAdq4h; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=QdCT2tlo; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="RFZAdq4h"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="QdCT2tlo" Date: Fri, 13 Mar 2026 20:22:59 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1773433381; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kg8SBcY3uuTF9hhD+KEByRJvNQcDNalT6k73QH8qgjE=; b=RFZAdq4hx5rVu3b7khq2MiP1uJSdcvxKWL2GJb+qI48j0wr1XS+iff1WLZn6WooeFQQgTR FbOS4K+kUYYJnw8SzmTlt+hzwOy+J7l391ngZj32s4rOCdYD0rYOkBU3FMO1JfwLjkC5QK EaW+BxsAknKfrM7GEh6S+WJ5qzHDoDmM0tOkg9cFZ4GBW9Zw3zV8ec26zTn/sOkRU5gueA LAtRgKzFPx/EptUKU1lv6ZFjCaMAXn2V1k14tUMy+iaDga2Zp3TDbth8jrYpcK2NgEKF3S tyy1nTsrhvj0PDRptMPuXrRmF0nb5vJWdj3MHmGtmNilbfTLhxdDt4d4t6LUSw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1773433381; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kg8SBcY3uuTF9hhD+KEByRJvNQcDNalT6k73QH8qgjE=; b=QdCT2tlopb7T2UYoS3Eu3I4LxhTKSNPt/sSgNaD84CL3A2Ae5bN2bJULVbVs5++e54bx52 H4QI/lgu4fAPE/Ag== From: "tip-bot2 for Borislav Petkov" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/cleanups] x86/split_lock: Restructure the unwieldy switch-case in sld_state_show() Cc: "Borislav Petkov (AMD)" , Xiaoyao Li , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260226145033.GAaaBduQ0rWXydOkAm@fat_crate.local> References: <20260226145033.GAaaBduQ0rWXydOkAm@fat_crate.local> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177343337971.1647592.14416500890329113032.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the x86/cleanups branch of tip: Commit-ID: 04e43ec9f002ed1041b41a6df4c645ef3148da9f Gitweb: https://git.kernel.org/tip/04e43ec9f002ed1041b41a6df4c645ef3= 148da9f Author: Borislav Petkov AuthorDate: Thu, 26 Feb 2026 15:50:33 +01:00 Committer: Borislav Petkov (AMD) CommitterDate: Fri, 13 Mar 2026 16:57:02 +01:00 x86/split_lock: Restructure the unwieldy switch-case in sld_state_show() 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) Reviewed-by: Xiaoyao Li Link: https://patch.msgid.link/20260226145033.GAaaBduQ0rWXydOkAm@fat_crate.= local --- 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 fb16666..660aa9a 100644 --- a/arch/x86/kernel/cpu/bus_lock.c +++ b/arch/x86/kernel/cpu/bus_lock.c @@ -391,34 +391,35 @@ supported: =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