Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2418lqz; Fri, 29 Mar 2024 06:56:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW6YqTQ2VEnR1e/PmNxWyvAM3JdAhoJhzfv6lAugG3/5JA7YfX3vlomIw01RX1XrKM61ccnJI/1pyUNGNGE7yyDk06GabRa8aertZo1Xw== X-Google-Smtp-Source: AGHT+IGqsij8qCh/98lgT+k//myZ573I0XpGPSu4kLCjc4J/kq3SoGqxf3cqhYTOSVEeAuK5pg/u X-Received: by 2002:a05:6870:e99a:b0:222:6497:60e1 with SMTP id r26-20020a056870e99a00b00222649760e1mr2349487oao.29.1711720574047; Fri, 29 Mar 2024 06:56:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711720574; cv=pass; d=google.com; s=arc-20160816; b=I5/ptxk81Sfk4SnJSbGHAELfCygTlCEAFIMAbXsm0o85+P1aZuxA5sUf1Nmr+JwfBQ tbEjVqNQxempP4AOpKtZvPL9YoXt4K9853PhyqPHZf0nm8Ig1KO6p2SkjbYp3UknGu71 d1jIQFDeMZF66DQGnFPUBxNGm6WjVx0YMmXJ7OAbpqPSWwj4oy1T1pPBH2jeO4NlxNVv s1xN8ufNFtUmFD2MWbTaMpFh/XE0W4QmOAWxRT4yyXYXJ8NKGz0nvlhnpdDWfGsDQmNZ P5wEi1OgNF2BpY+Z7upRPwKh8Ikv7PqxFs+izUcQ2mrVOp+maj4F5spOI5yfYee1NABR qrzA== 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=EtxiejyK4PuyjvHA1bAkuxAHeJ3AsPD4cQ3nhHB7ClY=; fh=7sIHofzH/3mBM/GXIqnOilbpUlkv5ySZNfeBysYWZFM=; b=PnVCD3tUrEJ4cviViJ0tHIm1yoDP+adTfCeQ+kZHd2Ah0MeBWfk4a1CvjXSwOyj7Za lEFPbgOzCGax3t8GBxIuBeEmYpQqXgT7eqCOmU1SiDncSZy/r31RMX0f9HZbWGLTy+Oc sivCaoOQrqggloa5blJNf6iL/aNEP6fRqK6F1ouAiSj1Zt985j/mksZYGR8Z2VpaBwCs GthqyYUEG8MJlndVCqdFWlaWrloAiS6t17pZUctFLDizdJydpsyudb1eSmpha1x2ojl0 HWM4nPwi7ye9UdWqYS9qRjp9ZnUj340FSrV7JlOL6o0dW00ogsCWt8zkR05lds9IBgjn frMg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DfrMEVeY; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-124805-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124805-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id u31-20020a05622a199f00b004313b42c1e8si3882336qtc.283.2024.03.29.06.56.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 06:56:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-124805-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DfrMEVeY; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-124805-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124805-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id BED941C270D8 for ; Fri, 29 Mar 2024 13:56:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B240A194C88; Fri, 29 Mar 2024 12:42:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DfrMEVeY" 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 D975B19067E; Fri, 29 Mar 2024 12:42:44 +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=1711716165; cv=none; b=VPkUdJkf7jBKEkTHqDjiS6P/Lw2CNBDmsCfDDAa/utKKbLZ2K5BpNLnTmduVWax9ODA5+SsoGjCW0YjSU0STx8GjVjWBNigdyB8Q0RajpETVpJSvmdiX967mr1oy4jNpT1I1qQIPDO8CpzdkedJ99ZbZg2zA6T2a1FE3buIBkl0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711716165; c=relaxed/simple; bh=NVK4O8B5BrAcw48L7NZu7ZI5jWxrvoi1ZutcB4pKe/w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h4XafSp/i7i/sSIJpeHKgHZklLQBhAgEoqJlnugTO+L+W495OiWxXd0hI6/CH5V2QMu8IJ7aobMmVkMHtHXmXgfb4mYrxYVrQlVPoP7I5QDEV0I8LEAue/LmxuaQ1XyzklgSM1iUmtMEBuEkwv9dcSW30eVUywimY71kYrjlTxE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DfrMEVeY; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id F02AFC433C7; Fri, 29 Mar 2024 12:42:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711716164; bh=NVK4O8B5BrAcw48L7NZu7ZI5jWxrvoi1ZutcB4pKe/w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DfrMEVeYEkFWRZ8z4HnwFfw5y3OrZSVFIpyx1xDZtgNc4H9OXe3Q/lonzYmY8TCUx CFK6NOgNvHi3zYelZF2qHhWgv/PpZoNdUAkGN8mGgut8TfTvIy8s5A+JocGrFrH2EN AuVgZkescv75RaKx2jVLlNKNIfF2UHwHwxGDqzUhuBx4Fo2c7GJgcIX3FRfgW2tJ7F I0ArXf5q1it3Lg6dwRKys3jae8YV5VoArZhJDgNkVG7nihI1NUvArDR7Ho0XF3dZuD sKxPWclMBj+wrJ3GkC40V54HXFr1U4DVFJNTRT/VlNTwv1py3BZazZZeQgz2+N4VC8 9U16ivlumDP8g== 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.8 94/98] perf/x86/amd/lbr: Discard erroneous branch entries Date: Fri, 29 Mar 2024 08:38:05 -0400 Message-ID: <20240329123919.3087149-94-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240329123919.3087149-1-sashal@kernel.org> References: <20240329123919.3087149-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.8.2 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 eb31f850841a8..4a1e600314d5d 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