Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3210469pxb; Mon, 9 Nov 2020 05:41:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJz5w5a3vheZvqKwjLjBtSGbKIPeFgU/kgquPEAlPlkjP4jcf9PvPYiADZG2V77KRS2+n2Vr X-Received: by 2002:a50:9fe6:: with SMTP id c93mr15285985edf.30.1604929266582; Mon, 09 Nov 2020 05:41:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604929266; cv=none; d=google.com; s=arc-20160816; b=tweKdKiUWXKtQbOsAKnXU2sm2Ad9rESEET1WU7A9cb3N27Y3S8STFsiK0XESls47vn oRCKJmgPflbWyrUtpd4R/JltFrtjJquupX/GIkstiF13SkrKyfRFU0c2/+HuXaBcotqY MyfXi7ddwTYcLRfG8xifl2djh0/JnceCQo6LxA1GIvyaSvbJWXeiBSNcnFwbczmqGWnY lCv2vz2sILdT1jweQr9DxHkseLFq1tPUKJm9uoUiP/27EEyTKRW+Ud+6zmO4ilTt07Ms TpDWy+3EOsaDJl2Xk7J/ucT3duTWF2t/BqtDEhiUs49qGRNxyfnAgJjbHsndcIsGg1iE higA== 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=ohC/q3eMpQGzoR7csKVANjeqfldcuPLZtiFJai2Jw4Y=; b=X0x9eraeRPNvdnwt007oBB2juISC08ldl7+GYXd0lu67iYS6VMU3VKjMGgt1+PDbFt WWG7Zi6xHlbDvmCAU6JjuXYbMNppQR965are+f8v3Z/bPP6vh57qNlGeYjuAGN9PUvxH 31occsZOpzuRxrGvs88uMJJHHtcNtN8GOXziEFILM+Wr9pcNuL6Od3gmlxYgrMhjT0dx AF3141wNUTAVQ5HIJ0H5MFRn4M4yUybXjsnWCYYz4eBE7VKKxm9DH70mnkjg9ZwQvF4p 3CCqUu+YuCgnVpbtaG0HYBTSQiTV3RycTlQgzuUXt7Cl8xegjzaMT+2MY8b5t7De5/P9 QDYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xv3hK++y; 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 w13si7272717edv.50.2020.11.09.05.40.43; Mon, 09 Nov 2020 05:41:06 -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=xv3hK++y; 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 S2387544AbgKINia (ORCPT + 99 others); Mon, 9 Nov 2020 08:38:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:56402 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730551AbgKINCr (ORCPT ); Mon, 9 Nov 2020 08:02:47 -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 C196B221FF; Mon, 9 Nov 2020 13:02:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604926965; bh=TgzlSBTYvvRTmVFdwSGJwgO8lMygGM9+F4XizitHdLU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xv3hK++yDQZOnXKZGyXZ0NlBQRfWuTEIlk1MQQESClae0F+iD+uDxF/AGiiUAI6AH aew4iKoSLKexZVCpsEa9exKk85MPQNvrKN0XFEawEyqpnSN1DhBU6BT0cwYhv+XN+e alIpTYgD/7MVcjVUL6shlAIxrr4sbpTtLAbwXmcQ= 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 4.9 047/117] perf/x86/amd/ibs: Fix raw sample data accumulation Date: Mon, 9 Nov 2020 13:54:33 +0100 Message-Id: <20201109125027.899883212@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201109125025.630721781@linuxfoundation.org> References: <20201109125025.630721781@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 @@ -646,18 +646,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 @@ -356,6 +356,7 @@ #define MSR_AMD64_IBSOP_REG_MASK ((1UL<