Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp206945pxb; Thu, 26 Aug 2021 00:48:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwO7lHNQ5RtH9OVYp9t5BBtBFtzPDchLyerUJdAHQ+hxkOr759epCCGTLWmO+Mx2ghbVY+b X-Received: by 2002:aa7:c782:: with SMTP id n2mr2853618eds.77.1629964103313; Thu, 26 Aug 2021 00:48:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629964103; cv=none; d=google.com; s=arc-20160816; b=e3bevERmPJgJtQkfHx0sMyDEf8nZDmTMD8B7F1BZGpY3vMs44V8X2wtQ5dytb3Yt6x dq8E/kbsizlMQpW0JHbGj1RhUdnZ8QVOnTL2ktLJzKspgoxh1eCks94u0JCIMw6uyV0Z PaUVDG+SzfMv4a/IAiCUK/wKDroqMNy8K0RQQqLe2memWvoqBlSWb79V0/jSYfawTH8W ircLH78qwzgnaIiBkRzmYLopPO1kOsEK6W8uq8rEnD6KR/uSO0+zgxie1GXqGrAn1VlY za1W1g9la2jC/WirtjfbQzzQ6/fzKvG8/HOulslCtN1/umWgIFoVWLQPT3nj1OUJVpZl 5+mA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=WU2Vsci3rGMkyl6zo/NT52wDf8/v9Zn9CweTBZiDTl8=; b=XbRTjiMU+yUTVJkt2/RFSyruAGxF4VfyzPE5nIt9blLhK/2UzUIf6JfK93pK5d2rP6 +XrQnhGfG/U8KxRXBPWkTtMJ0usaMC3fJBXH6BBDuwksTT2sXYDe7GJUKMJ4zxVSPUsf 1Xq/y2yPx9uBJ0Xx7P/UN0gort5uc3vOq2DECtoHyzC1FL6mZ6zlAluiqTlxIELPC9DG VYt+KE8IzSpCRiyEDE9S5J4OUpqKlJQzyeKMLH99Z9q5XBc7r6KO1kvyOQlCQDBzhqzb bdvQi3ZKWUocThjKstOW+mRI8pCfvh+AkqRowBHwlW9Onu5Fn5Ev4KWd97aZ1LPYuqN3 jEsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=KHkBgGBj; dkim=neutral (no key) header.i=@linutronix.de header.b="f/MhwU0p"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qa36si1909175ejc.337.2021.08.26.00.47.59; Thu, 26 Aug 2021 00:48:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=KHkBgGBj; dkim=neutral (no key) header.i=@linutronix.de header.b="f/MhwU0p"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240198AbhHZHqQ (ORCPT + 99 others); Thu, 26 Aug 2021 03:46:16 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:58614 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240113AbhHZHqP (ORCPT ); Thu, 26 Aug 2021 03:46:15 -0400 Date: Thu, 26 Aug 2021 07:45:26 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1629963927; 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=WU2Vsci3rGMkyl6zo/NT52wDf8/v9Zn9CweTBZiDTl8=; b=KHkBgGBjcU2HB0aibWyVLSz4x8QDnZN//OGo9+RvHQcR1g/mWTrwZkPuaKVaABzuCNiIA/ 6k+Jub/H86o9tsq8z2aHQe/pIwebncKyijRqUvjVFAB6C0GcVxOcFj1cAsXnS8hqqOnWu4 wXWj89f37m8xXF12lHD+YJD85xWTP/EubuUJsrl9h+g11Ei7wOsRd9wWibpx8zh+h5LMXv xPhjQjfbrgIhdsGESXJcHTnyE+DnlYDPyb3Kvjur5fq+IXVef3pKtbTdZrHgLuRbJxLrtL m9N7Z9OZ6elcgosYKqQEPe+aJ0mn2/R5I1zXVcLr2ZhUikDJHAGfsn+y82PQTg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1629963927; 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=WU2Vsci3rGMkyl6zo/NT52wDf8/v9Zn9CweTBZiDTl8=; b=f/MhwU0p4pkd20kNMFhd9SQqwvaDDftg+Ew9okb3/gGfGMECb+qzlaRqVXFiffHZYy4uUM CyB5Yi7T1YXqmmBQ== From: "tip-bot2 for Kim Phillips" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/urgent] perf/x86/amd/ibs: Work around erratum #1197 Cc: Kim Phillips , "Peter Zijlstra (Intel)" , Ingo Molnar , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20210817221048.88063-3-kim.phillips@amd.com> References: <20210817221048.88063-3-kim.phillips@amd.com> MIME-Version: 1.0 Message-ID: <162996392634.25758.2619063727360581093.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the perf/urgent branch of tip: Commit-ID: 26db2e0c51fe83e1dd852c1321407835b481806e Gitweb: https://git.kernel.org/tip/26db2e0c51fe83e1dd852c1321407835b481806e Author: Kim Phillips AuthorDate: Tue, 17 Aug 2021 17:10:42 -05:00 Committer: Ingo Molnar CommitterDate: Thu, 26 Aug 2021 08:58:02 +02:00 perf/x86/amd/ibs: Work around erratum #1197 Erratum #1197 "IBS (Instruction Based Sampling) Register State May be Incorrect After Restore From CC6" is published in a document: "Revision Guide for AMD Family 19h Models 00h-0Fh Processors" 56683 Rev. 1.04 July 2021 https://bugzilla.kernel.org/show_bug.cgi?id=206537 Implement the erratum's suggested workaround and ignore IBS samples if MSRC001_1031 == 0. Signed-off-by: Kim Phillips Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Ingo Molnar Link: https://lore.kernel.org/r/20210817221048.88063-3-kim.phillips@amd.com --- arch/x86/events/amd/ibs.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c index 40669ea..921f47b 100644 --- a/arch/x86/events/amd/ibs.c +++ b/arch/x86/events/amd/ibs.c @@ -90,6 +90,7 @@ struct perf_ibs { unsigned long offset_mask[1]; int offset_max; unsigned int fetch_count_reset_broken : 1; + unsigned int fetch_ignore_if_zero_rip : 1; struct cpu_perf_ibs __percpu *pcpu; struct attribute **format_attrs; @@ -672,6 +673,10 @@ fail: if (check_rip && (ibs_data.regs[2] & IBS_RIP_INVALID)) { regs.flags &= ~PERF_EFLAGS_EXACT; } else { + /* Workaround for erratum #1197 */ + if (perf_ibs->fetch_ignore_if_zero_rip && !(ibs_data.regs[1])) + goto out; + set_linear_ip(®s, ibs_data.regs[1]); regs.flags |= PERF_EFLAGS_EXACT; } @@ -769,6 +774,9 @@ static __init void perf_event_ibs_init(void) if (boot_cpu_data.x86 >= 0x16 && boot_cpu_data.x86 <= 0x18) perf_ibs_fetch.fetch_count_reset_broken = 1; + if (boot_cpu_data.x86 == 0x19 && boot_cpu_data.x86_model < 0x10) + perf_ibs_fetch.fetch_ignore_if_zero_rip = 1; + perf_ibs_pmu_init(&perf_ibs_fetch, "ibs_fetch"); if (ibs_caps & IBS_CAPS_OPCNT) {