Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp825134pxb; Tue, 3 Nov 2020 13:36:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJyt4kTV6KGBCRiyLJP/AXY/87Yn0zQp5V2LO56e3GDb2BQ9e3Oucc6UyAYkus0JkXeg/wEV X-Received: by 2002:a50:bb66:: with SMTP id y93mr3993106ede.244.1604439399748; Tue, 03 Nov 2020 13:36:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604439399; cv=none; d=google.com; s=arc-20160816; b=Q5D3mGWgN6jHQJf2QSCTN83BsLmcxKfjzPMZ5hRNwWoTYf+nIF6qvljzfdpm1RJPTh CCsFdRh4MR3OJLTVlBIDgxdyY58orpfqpafQkpCL+363MVpV7px3N0L1HWmp1mRFAR9k 7xAqtuceWoMS8RBt5WwR6l7Y9HxGoQgwhFVk+nD0I2f+NmXR+Ao1dKA/XSfAc92D/sZ6 9g5OIASMUB/Uhy4AyWPNISEIp6hGEOv6c94hABDYjeKi5BkXlFsZzZrIWjg8r+6E4Eo/ sqQ0devIiTZPTqX63gqr+ti2YV7xXR9CX/8hMMH/UcER+u9dIna8lMvx7Vd2BprGvuzA O5HA== 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=Uy5W8zEAaY9xGJSkMdCMix2FM5oELkPYjV2TJGXrRJM=; b=E0x206wPgfCMr3xjapSvd34TP1uo/DmagzW3wMQThzniER8t27Qe6c75R5YknJQRlY QOKmNkn2zYcqXYxnoXxj9WJanyw/35dexbBbTHg9VmI4k+7FzcJvD8FTOo+0PZGE0ocO Hy8NhLAZ6zRceZRcVNytEk1zyCS1HdkiY9MdM8gKkK3Dtj9D7A+6VhoWEUlc1puR0NuK TYBaVVuEBZ/96Pje2meoLdMGoFgb+sziGvDGmA2VK+iwg1XdfX3mnaqxBRi4hkkLYk8w 7aA4WVS5iDYW40drViqzuzOMbuauL5DTRWXGVShw7h/YyQtCc2aBfsnOP/a1vch6jQVc z9Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=z4WYvmxI; 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 o6si19548870edi.560.2020.11.03.13.36.16; Tue, 03 Nov 2020 13:36:39 -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=z4WYvmxI; 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 S1732531AbgKCVeL (ORCPT + 99 others); Tue, 3 Nov 2020 16:34:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:58682 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732169AbgKCU4n (ORCPT ); Tue, 3 Nov 2020 15:56:43 -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 121B92080D; Tue, 3 Nov 2020 20:56:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437002; bh=kcskiwX7bdMvjhRCV6N6pCuJXa2NDRQFDRAqPYhFQD4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z4WYvmxIRpbqQWfA++8cmtmVhKBk7HJfeOZNukzjZhtYcJsDL7WczLR0RtFsfJtVb iKRAr+97Lrh1OqGUfXQlfcasiugmYQr/aAfGCCeXplX4IJKxLf9rXK6/GkjX9rBhZe iSuESm+QfxNmhd/ttuBJG/Zfjw+Vxi+/7NOMGTfo= 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.4 103/214] perf/x86/amd/ibs: Fix raw sample data accumulation Date: Tue, 3 Nov 2020 21:35:51 +0100 Message-Id: <20201103203300.397882535@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203249.448706377@linuxfoundation.org> References: <20201103203249.448706377@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 @@ -432,6 +432,7 @@ #define MSR_AMD64_IBSOP_REG_MASK ((1UL<