From nobody Mon Apr 6 15:52:17 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 279B12C15A5; Wed, 18 Mar 2026 22:07:53 +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=1773871675; cv=none; b=rT/NYcfCcncvbeTcqt/79XHrC0kkkrHyZVEzlFDE+JRVt9C0GCBVwbsvPa+elGKCGuV/T2Dxd8rvmruIOjkPNRT+qxG+bB1vBo4Hiywvc8wZuP0E9vuWaHuwJUognc0jexDIcM75saL1m/9yt5uLWsb2YfosEbfAryp4alZMTLo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773871675; c=relaxed/simple; bh=/zzCuY+0qLjS6Fxb9elpOY4PySYKXdLoAVYhG5Etcas=; h=Date:From:To:Subject:Cc:MIME-Version:Message-ID:Content-Type; b=qmEdlO1qgfhJJ+mnyXQDaBDfpMiYWkJIGCByLzwlmPzSlFw3WmHrmA3jACwDLk/ldnFxHBOZyoytWMShyTt1Ajy0r+xKnIilDyjvbp95GZ6AoqVB7gLXm8DhyitERWHcOo7PLf8wSk4DuLtM3++HgNUaLgjDQuVZrruMR09wv68= 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=vt56S+/6; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=MEr/P9k2; 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="vt56S+/6"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="MEr/P9k2" Date: Wed, 18 Mar 2026 22:07:50 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1773871672; 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; bh=jZJKKTqO8P+jCyrnqWR8f46OGPkcylJr+E7KJRpOifY=; b=vt56S+/6VP8N3ZOUYHTcupYbWYjKA3vnXmBWjoyCDYtioBa/CvZgDjOCpBS2jthZGQt3Pe EmJDDqV9PCKuLtabur6I9BsbxatCtG7b4I+m+WMskJnI6+HRGIXuClkYfvPGlTiI/jw4CD hWfcBEz7dGUsvddBN3VVS+zxdeebqVecpvOFJGChQiubsyS98hXvhgPs9xKBK/scLPtWJO Xy861T/BjUyH4n+NRgCs/nAbWxA7CneyjLO3o5C4mOR8Q/yKgT0LR8oOYLLc43fuIQ8gVd cjtmxw0YqIgH3VY2olsOh0yVIe2TneNqM5UEO302zCv6C6Y+ztO1ili+GpumFQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1773871672; 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; bh=jZJKKTqO8P+jCyrnqWR8f46OGPkcylJr+E7KJRpOifY=; b=MEr/P9k27tprlR/esktg5JgK8QAmlqBcKfdwvtg4weuw15h/j/WCpauZs2MrhKGI55FHxW gxtZp0O9ZimgcdAQ== From: "tip-bot2 for William Roche" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/urgent] x86/mce/amd: Check SMCA feature bit before accessing SMCA MSRs Cc: William Roche , "Borislav Petkov (AMD)" , Yazen Ghannam , stable@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177387167044.1647592.7936336301829220582.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/urgent branch of tip: Commit-ID: 201bc182ad6333468013f1af0719ffe125826b6a Gitweb: https://git.kernel.org/tip/201bc182ad6333468013f1af0719ffe12= 5826b6a Author: William Roche AuthorDate: Tue, 17 Mar 2026 10:38:10=20 Committer: Borislav Petkov (AMD) CommitterDate: Wed, 18 Mar 2026 23:02:16 +01:00 x86/mce/amd: Check SMCA feature bit before accessing SMCA MSRs People do effort to inject MCEs into guests in order to simulate/test handling of hardware errors. The real use case behind it is testing the handling of SIGBUS which the memory failure code sends to the process. If that process is QEMU, instead of killing the whole guest, the MCE can be injected into the guest kernel so that latter can attempt proper handling and kill the user *process* in the guest, instead, which caused the MCE. The assumption being here that the whole injection flow can supply enough information that the guest kernel can pinpoint the right process. But that's a different topic... Regardless of virtualization or not, access to SMCA-specific registers like MCA_DESTAT should only be done after having checked the smca feature bit. And there are AMD machines like Bulldozer (the one before Zen1) which do support deferred errors but are not SMCA machines. Therefore, properly check the feature bit before accessing related MSRs. [ bp: Rewrite commit message. ] Fixes: 7cb735d7c0cb ("x86/mce: Unify AMD DFR handler with MCA Polling") Signed-off-by: William Roche Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Yazen Ghannam Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20260218163025.1316501-1-william.roche@orac= le.com --- arch/x86/kernel/cpu/mce/amd.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index da13c1e..a030ee4 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -875,13 +875,18 @@ void amd_clear_bank(struct mce *m) { amd_reset_thr_limit(m->bank); =20 - /* Clear MCA_DESTAT for all deferred errors even those logged in MCA_STAT= US. */ - if (m->status & MCI_STATUS_DEFERRED) - mce_wrmsrq(MSR_AMD64_SMCA_MCx_DESTAT(m->bank), 0); + if (mce_flags.smca) { + /* + * Clear MCA_DESTAT for all deferred errors even those + * logged in MCA_STATUS. + */ + if (m->status & MCI_STATUS_DEFERRED) + mce_wrmsrq(MSR_AMD64_SMCA_MCx_DESTAT(m->bank), 0); =20 - /* Don't clear MCA_STATUS if MCA_DESTAT was used exclusively. */ - if (m->kflags & MCE_CHECK_DFR_REGS) - return; + /* Don't clear MCA_STATUS if MCA_DESTAT was used exclusively. */ + if (m->kflags & MCE_CHECK_DFR_REGS) + return; + } =20 mce_wrmsrq(mca_msr_reg(m->bank, MCA_STATUS), 0); }