Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp836490pxb; Tue, 3 Nov 2020 13:59:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJyXskSmyh28/pCV7D2G8mYtAky8mALbygtbm2yP/pEvzkxnlT/fR4QtUXvMTauLrL77VEoH X-Received: by 2002:a05:6402:1684:: with SMTP id a4mr23399226edv.79.1604440743236; Tue, 03 Nov 2020 13:59:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604440743; cv=none; d=google.com; s=arc-20160816; b=FxHNEgfd6ounoo2F2X2JLKDlcJxog4pTNwwhWsv9a2a0yvrJNZzU8KVMC1nZ9C5vJ2 Mvfxaq3tGo/bIZSDTJ7cuv1upnFYVJXld2T1XlcupOy2dn10CO95APS/2HEhViFajYOl TRDV2pwYLIAhpHvINBIX7PNH/ZydDfVCrM18yKOkxGi6IpTF0x66C9hffWlb3t55+DTo ujKQjgLBF8+abVJIoaTqi2tiO7m55fFM/Ga/I44XJOKq2cU26J7bs2DhVrb45DIx2TbR YiBXcETdWbUKqj+gzgp9SjMO4DM43DqLxRxaaW+kpoQE+0Ysi9cr1ozslVkmqvwr1ugo M14Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zHf3Y13kEVrtqROal3yr1TGdY6NV5vKW+Rtx/6Qgju0=; b=taakeedS/Cr9+eSEdAmK1WSDwlxOfEDYYvzcOzpqBtbN+MswQpX4gRgyedzTiZeaYg Jrcu8EorlcVp5GMbZu4Y009J8PEsVXQ9DP99LmBfh8MTw55+VN48ENntuN0ohbTTOr5A 2M6IzFS4bYth4WDFdkPWxTcf14tUcgCbKLqid9lH5WqPnUQ9hjHSoby8pji3t+XB6Ssj xfs2aZyneL4Z7CYI/WlLsnbPJ5x11izlgdz0PhuB0tzzFSlimf0i+f3wfoB6t0qsMCXe 6XkvuzKubWOUmfC9ojgaQIAH0JVrqHN308R7xIVCvqOiyE9CSNbsarDWvs/aC5RDE3bu UAEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OSA5HYrM; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k2si80315ejs.236.2020.11.03.13.58.40; Tue, 03 Nov 2020 13:59:03 -0800 (PST) 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=@kernel.org header.s=default header.b=OSA5HYrM; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732151AbgKCVzN (ORCPT + 99 others); Tue, 3 Nov 2020 16:55:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:33080 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730375AbgKCUpK (ORCPT ); Tue, 3 Nov 2020 15:45:10 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A7E392242C; Tue, 3 Nov 2020 20:45:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604436310; bh=On5W1dDIo6cAxusfp+TdHfsn0qFt324j24HN2eB1T6k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OSA5HYrMPX9jIL4MaU+nD0nPrpR6vrSOmWKcUao8loNjysFWUxBqquxABQLwITYSK l6rLgEuJwVnR9uzH2x+1CcBdBIahthIWgdl4LZ9Hm2sVZMgLWYsqkeZRUAxeVbNQAJ rJ935uojaRL+7F8zCGxS0j+mOcwCoSZS9Fr13fwg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stephane Eranian , Kim Phillips , "Peter Zijlstra (Intel)" Subject: [PATCH 5.9 195/391] perf/x86/amd/ibs: Fix raw sample data accumulation Date: Tue, 3 Nov 2020 21:34:06 +0100 Message-Id: <20201103203400.050412382@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203348.153465465@linuxfoundation.org> References: <20201103203348.153465465@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kim Phillips commit 36e1be8ada994d509538b3b1d0af8b63c351e729 upstream. Neither IbsBrTarget nor OPDATA4 are populated in IBS Fetch mode. Don't accumulate them into raw sample user data in that case. Also, in Fetch mode, add saving the IBS Fetch Control Extended MSR. Technically, there is an ABI change here with respect to the IBS raw sample data format, but I don't see any perf driver version information being included in perf.data file headers, but, existing users can detect whether the size of the sample record has reduced by 8 bytes to determine whether the IBS driver has this fix. Fixes: 904cb3677f3a ("perf/x86/amd/ibs: Update IBS MSRs and feature definitions") Reported-by: Stephane Eranian Signed-off-by: Kim Phillips Signed-off-by: Peter Zijlstra (Intel) Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/20200908214740.18097-6-kim.phillips@amd.com Signed-off-by: Greg Kroah-Hartman --- arch/x86/events/amd/ibs.c | 26 ++++++++++++++++---------- arch/x86/include/asm/msr-index.h | 1 + 2 files changed, 17 insertions(+), 10 deletions(-) --- a/arch/x86/events/amd/ibs.c +++ b/arch/x86/events/amd/ibs.c @@ -636,18 +636,24 @@ fail: perf_ibs->offset_max, offset + 1); } while (offset < offset_max); + /* + * Read IbsBrTarget, IbsOpData4, and IbsExtdCtl separately + * depending on their availability. + * Can't add to offset_max as they are staggered + */ if (event->attr.sample_type & PERF_SAMPLE_RAW) { - /* - * Read IbsBrTarget and IbsOpData4 separately - * depending on their availability. - * Can't add to offset_max as they are staggered - */ - if (ibs_caps & IBS_CAPS_BRNTRGT) { - rdmsrl(MSR_AMD64_IBSBRTARGET, *buf++); - size++; + if (perf_ibs == &perf_ibs_op) { + if (ibs_caps & IBS_CAPS_BRNTRGT) { + rdmsrl(MSR_AMD64_IBSBRTARGET, *buf++); + size++; + } + if (ibs_caps & IBS_CAPS_OPDATA4) { + rdmsrl(MSR_AMD64_IBSOPDATA4, *buf++); + size++; + } } - if (ibs_caps & IBS_CAPS_OPDATA4) { - rdmsrl(MSR_AMD64_IBSOPDATA4, *buf++); + if (perf_ibs == &perf_ibs_fetch && (ibs_caps & IBS_CAPS_FETCHCTLEXTD)) { + rdmsrl(MSR_AMD64_ICIBSEXTDCTL, *buf++); size++; } } --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -464,6 +464,7 @@ #define MSR_AMD64_IBSOP_REG_MASK ((1UL<