From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 EB1E6624; Thu, 11 Apr 2024 10:47:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712832455; cv=none; b=l+rQju8epy3SQ7n/0LhSz00Y97H8q45T8QNK6KBCEyHeCQ7f45ToXQ0zPVKGPFhvy0naCAWciEyPua6mgcp2mCytd/NVUCNkJ3Ird07L9hEYOKGdwCnRLBBR9b5KBJHcPDTKBGPLMS/IeuywELRAbzBw+W2V8TDJqzOJwKGQvJk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712832455; c=relaxed/simple; bh=u8s+Rtk07HRutefpfNpS1f8c2No21HKMYRJjFc7dD2E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JTObbM3h9mX9uU8C7VoGUn1EAe4P6LOrFMLjwH4+NzaQ83j+sUxpBeDhi7t0AAhsSa46SNhJkjm7Ipuy/xG1UOcykjZg4lQ48kvpfBR+729qxFwjD9qhEssvT6U3wJdZH6mSoETUeCGJUe/yyl6SOvb+Q2SEeoOqh1Y9+HHXN3A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=mozFUzwR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="mozFUzwR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70D6BC433C7; Thu, 11 Apr 2024 10:47:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1712832454; bh=u8s+Rtk07HRutefpfNpS1f8c2No21HKMYRJjFc7dD2E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mozFUzwRnMxlf6iAwXMPGg6U5hVOiLco3CLaTP5DlGCjkxCZjHk7PPGnYxnfmErhV YTcgYy9sxDZqFnlUZ8O53iPnR9M+bJRkWs7451eQjjvAtTHHFPhrDw+T+ZJuxQknek aJoHR4lE/nKF1ttH3v2anjU2vQflu0t8T5FP46sU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Sandipan Das , Ingo Molnar , Peter Zijlstra , Sasha Levin Subject: [PATCH 6.1 54/83] perf/x86/amd/lbr: Discard erroneous branch entries Date: Thu, 11 Apr 2024 11:57:26 +0200 Message-ID: <20240411095414.309106512@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240411095412.671665933@linuxfoundation.org> References: <20240411095412.671665933@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sandipan Das [ Upstream commit 29297ffffb0bf388778bd4b581a43cee6929ae65 ] The Revision Guide for AMD Family 19h Model 10-1Fh processors declares Erratum 1452 which states that non-branch entries may erroneously be recorded in the Last Branch Record (LBR) stack with the valid and spec bits set. Such entries can be recognized by inspecting bit 61 of the corresponding LastBranchStackToIp register. This bit is currently reserved but if found to be set, the associated branch entry should be discarded. Signed-off-by: Sandipan Das Signed-off-by: Ingo Molnar Cc: Peter Zijlstra Link: https://bugzilla.kernel.org/attachment.cgi?id=305518 Link: https://lore.kernel.org/r/3ad2aa305f7396d41a40e3f054f740d464b16b7f.1706526029.git.sandipan.das@amd.com Signed-off-by: Sasha Levin --- arch/x86/events/amd/lbr.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/x86/events/amd/lbr.c b/arch/x86/events/amd/lbr.c index b8fe74e8e0a60..48f4095f500d4 100644 --- a/arch/x86/events/amd/lbr.c +++ b/arch/x86/events/amd/lbr.c @@ -173,9 +173,11 @@ void amd_pmu_lbr_read(void) /* * Check if a branch has been logged; if valid = 0, spec = 0 - * then no branch was recorded + * then no branch was recorded; if reserved = 1 then an + * erroneous branch was recorded (see Erratum 1452) */ - if (!entry.to.split.valid && !entry.to.split.spec) + if ((!entry.to.split.valid && !entry.to.split.spec) || + entry.to.split.reserved) continue; perf_clear_branch_entry_bitfields(br + out); -- 2.43.0