Received: by 2002:a05:6622:f08:0:0:0:0 with SMTP id l8csp4489801ivc; Tue, 3 Nov 2020 13:24:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJzTKZMC1lRCare9KOI/xNh/kcNzO1jNMVVjDujGTGfqf3Ju8AxrugLXDWjgnP53QzaCu7ws X-Received: by 2002:aa7:cc84:: with SMTP id p4mr23224407edt.97.1604438689686; Tue, 03 Nov 2020 13:24:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604438689; cv=none; d=google.com; s=arc-20160816; b=0ERORlLJJDexE3BLVyu1/g3SZRM18/Wq630QLtYD1h5bMwFzIDRl6SxLmYKHIVFqNY T+srRiI/xBgeG04i5nvE73VFooJOJ5SmFTZ1Ay7QCi/GKw5ONB9g77lHBkfIMdej0jzL 3+Q4Q453esiESglACPJ6lnpi6BwO8FOjT88wWf/rxWPxp30ltVUGg+tYv/HAQWjI/a3+ ttAKC/csnv8g1zmJVCpI6tSguGsr3JpEzwLI9tCgIy7AIgsZ5Yb9qwWFSW5eg7+fjs89 Optm9Z0TO4xIOqhCaxXVZkzTHdRQ3opcpVNwjk9sstsZs8ez3RX0+ABD7YQr3Pq0q/V7 yqvw== 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=icrK9pXRjC/7CaCzq0I+iUXKXxH/ZitXfTAcbCOb0PU=; b=o07m0Jag8W6EWsX5Qe9BumFB96aHYB/UeECfNV34xBfv83cMmJ3BpK2ApWeLAeuHU0 8TRD5A+ZZr8uZLHASUSzoKgJFO6R0wsNeYaX0jk3aTj7pIuNWwImSvXZo9M7Pxrd5yO1 QfAf7OLyybRs72Fv0lOG4HmlVCyeNZGPbNG2ShFtgLyJ5Fc6Rg+ZVXOk9rNFNVcRBqlQ Vq9f0Nw6vs9uGR2VdsaFQuwThPdB/k7gmPJuc6BruLqeC1ubcrDoe+w3jcRg5Ql1P9aK cOlZXehqmkwZxjnopgoOWuJbCWTAeDQ+aPsbyiTUa4DqCLrTW8Jo3smw1XuvtkstNe7C d/UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=v1+MvUXM; 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 sd17si44539ejb.395.2020.11.03.13.24.26; Tue, 03 Nov 2020 13:24:49 -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=v1+MvUXM; 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 S2388503AbgKCVWM (ORCPT + 99 others); Tue, 3 Nov 2020 16:22:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:44034 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387826AbgKCVFb (ORCPT ); Tue, 3 Nov 2020 16:05:31 -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 58458205ED; Tue, 3 Nov 2020 21:05:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437530; bh=oQaS4BJXKvPjXKJDG5T2rDEBCgBnxurtGHA8n36kbDc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v1+MvUXMf3pi0jtlBXP0FSRNNbK+UrlCUcgZBYAfcRA7dRd6bv4VZIfgBAf/YtpeS DmdwFo7YCYyKWkprOI6N85b+W9yoDArQhXwU8dCgN/as9LTvJAXEbSEZmdyTBUFuGz JG2da95YYHXwXSdKG3zvKeaaOjRw9QU74x2ZAR0c= 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.19 115/191] perf/x86/amd/ibs: Fix raw sample data accumulation Date: Tue, 3 Nov 2020 21:36:47 +0100 Message-Id: <20201103203244.148999634@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203232.656475008@linuxfoundation.org> References: <20201103203232.656475008@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 @@ -647,18 +647,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 @@ -377,6 +377,7 @@ #define MSR_AMD64_IBSOP_REG_MASK ((1UL<