Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp24936lqz; Fri, 29 Mar 2024 07:30:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXVoERiNI7wmdTGwdOHzPGI73zOWSjEuGTBTDZ7R4n+uJroHMOr5CaslalpRDZi04sPphYAhbpTy9zP+LmJGc8alA6yXCIHmQNCKNnWUA== X-Google-Smtp-Source: AGHT+IFirwqE1SPNvGIUvWv/6p5g2VRkwhDRadSPBrOE8LJcsJzFUqH4nDopmtGenuYhQ5KTn7m6 X-Received: by 2002:a05:6a21:150d:b0:1a3:6940:82ea with SMTP id nq13-20020a056a21150d00b001a3694082eamr2217414pzb.31.1711722639650; Fri, 29 Mar 2024 07:30:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711722639; cv=pass; d=google.com; s=arc-20160816; b=INaqIUFNHAkJVHJR51QtLGzqYuzi7soWW4dwMyYLcGmYM0KC/eNcu7yS/dFdFnvEa2 CavSR1F0FDrq3mriczIdVEQbo687vzJLyUs7RUQhwceZ4ZSApV+f3MO39mvosHWdwFrs NfZ+PUutcg43ZtGhgAJd+0CBSYlyRyvs0TZL8LsJjaJ8g5BfwGuvHmRXvU3c8QTqQW5Y oRjFESQVuwOP6RKQbvKnjRiPAk7OER+D7wFLFyz7t+f4YAyjtX7zZVz+cTJK86rSy63r dBvKweiO0EfAk0Rb11+d3GYBQNL4Kf74NIkLUPlJ9ucwniU3mF9z02ZII6J8QTS9JBYW tDpw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=4Aq77eeKIdi78gY0xApvKMP20iTmkaujt0pk6WR59TE=; fh=7sIHofzH/3mBM/GXIqnOilbpUlkv5ySZNfeBysYWZFM=; b=rjV4FmNGDJGFUEfXTA2WEe6ZfdHQ3cPHD+F4il69E/OJY7p9yjsloNzxhLdfxJZCmf K41l+lZamdrbDJWztZVQOzX+JlpoTp+22fvxqexigI1C74lu9PicOYIlCFgAsVJZ/zaz D6g24M8XdlopaZSSKsunypszzfHNp5lfgCAl0MexZ2tcz5bqyxKBZehrmHNQk53TeIVb h1V1dj++q5afzC+MueYG0FwsxMAC9F+84Ssfrqq88KPP9QEmBo26O+9ds8jNv/kfF8XE QH8W1hgWk1WFjCQjLbN87WMsZBACCzjzHf5nsiOcPuWYEOpFuRMhv9bYue3b5doGehjI FBEw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QynAd3GQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-124934-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124934-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id bg27-20020a056a02011b00b005dc10248136si4127033pgb.314.2024.03.29.07.30.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 07:30:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-124934-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QynAd3GQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-124934-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124934-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 50BF5284CF3 for ; Fri, 29 Mar 2024 14:30:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 727E616C614; Fri, 29 Mar 2024 12:47:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QynAd3GQ" 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 937FA1A5698; Fri, 29 Mar 2024 12:47:31 +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=1711716451; cv=none; b=L7w4qXOUdQ9OBOrFBNlapJFdO6TBgUYj0P5x2p6VFWLUgWxmbA66F+ZZdIs4FSx8BcyfiFr3cBIKNMG94U5z+wGNUuCJnRuuGXD8EqOUTVDq6gLP5vNpIVs4y+KlGr8Z6z+/YF63JeJ0auJsYgxMyz8ob+ufmE3mQ+7L3v130kc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711716451; c=relaxed/simple; bh=nwj+Golkv2V9iD1q874DlQZnbaaJjC8jpQDnuTb3mME=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mS3yktrws8KDSlMWR2jiLpb23h0knLfYKSn7wep1kwUkmnR4AXCBwCJsKfcuzWKu2jCGGIkCsUvXizr0d4oKnZiut1VvsMysWA77ceDt7kxtxTB24LaTFlRy+oQ9EyQhgGVuxQCcJhEa81qqZ+EPnarX2rP7n0N9c4dF9vAIED8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QynAd3GQ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5BBAC433C7; Fri, 29 Mar 2024 12:47:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711716451; bh=nwj+Golkv2V9iD1q874DlQZnbaaJjC8jpQDnuTb3mME=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QynAd3GQ+u/78d9XFVcP5sqvMx0ldHK73Bgpw4Y1y7EABj/xYq+VaYcO1CWJCwsa/ j6poBh3XyqgBNJO040vg2pormo3RvDKuMxxrKhmVqYE0mM3PGMXpvkY0aylTQRLqTr nnE77mCtH7OAejxxRiv/63MXcNS2jLSauOxxaQjOayOddJMAXblZVcf4EVK9H0zJcM iALjm1HEAUJ6B4GhV7IQbeIz/ABhXA9nA71t8HU9IJqsSGwbl/4WkvXHGk29+7+1nT Rsi03YT2mA/3NRre7QspeodybfrM/wkPsgGcZn6s2uBf+/g9RRApGViv1YkJP8zYLQ e1ExAoFYDvwTQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sandipan Das , Ingo Molnar , Peter Zijlstra , Sasha Levin , mingo@redhat.com, acme@kernel.org, namhyung@kernel.org, tglx@linutronix.de, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, linux-perf-users@vger.kernel.org Subject: [PATCH AUTOSEL 6.1 50/52] perf/x86/amd/lbr: Discard erroneous branch entries Date: Fri, 29 Mar 2024 08:45:44 -0400 Message-ID: <20240329124605.3091273-50-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240329124605.3091273-1-sashal@kernel.org> References: <20240329124605.3091273-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.83 Content-Transfer-Encoding: 8bit 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 38a75216c12cf..7b65bb890ba38 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