Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6549543ybx; Mon, 11 Nov 2019 10:47:07 -0800 (PST) X-Google-Smtp-Source: APXvYqwSPPGwQ7tkPOCAZDf8zy2QFbJuEwl9I5L2ivbJRVoLlTGNomclv6SxLAM0GsPwdU4bOHsX X-Received: by 2002:a50:959a:: with SMTP id w26mr28109911eda.214.1573498027834; Mon, 11 Nov 2019 10:47:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573498027; cv=none; d=google.com; s=arc-20160816; b=DdrOuBXSvvVR25Lc/f1vJrHpboyNEHgDnrju4U9BclSejcg/tRzAsiiUvNP9PQY9Na ou1XxKH/mjSlp2F9vZ6Uv6C+pP1L9OEqPZA9DLNQhOPksWljM2oQ94/Q7Z57Tz+L9lyL gHQEtzUMrvs8m0zyyZU9VeNDxp7DUS+TPqMuGtvXbkCFIvD//i+lbOZjiZrmR2EnmT+L oTgUJ8rvj76y0wy8wb6vFtD8sH/6O5kI8rOHsV/lkd9JrhYLW/s/r4EbzAOyv+w1L98J 5718cNsggLVGHtzuEfe/uRl4RIydKZbCADTp40xadlhOXKAjGPdUiapElicvGOeuoFfN OGCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LDpvuF4ItUJ+d92mBdFYoApC0B5CcWf5pu0sa5kUwuo=; b=CVpEblRkAi9gco+B0+d2OFzI3KAgapy9lTFk3dw9zyMZ5+YugCrkMel28CaEx8LVGu dgHXY6UjVNews1qP1+rlH1IIuyjc2+evhROkrFv2m3p6Ws92AY5Vx6+7l+gqDbTL/k45 bcTHQuPMny01GI7Fwk9VtpsMSZcsudXp7DghrjhJguh1QQ/x0Zyxo7rMIpAIIjtwgDpa vWnyTwA71R/Ym/d/kUf3HM9nI5sx8ePaNTiJnI7zeKZV+jMIUew2qFIhotTHk+wcH1qo TAwCLa4Tr8GotoPNBKlvohZwbha03PMIWaBqWPxhO+4vSY4SN6TlSdmxFLG/frkK9R4A HO1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GibbU1+B; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e11si9769858ejr.303.2019.11.11.10.46.43; Mon, 11 Nov 2019 10:47:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GibbU1+B; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728821AbfKKSpU (ORCPT + 99 others); Mon, 11 Nov 2019 13:45:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:37330 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729835AbfKKSpS (ORCPT ); Mon, 11 Nov 2019 13:45:18 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 7C52521783; Mon, 11 Nov 2019 18:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573497917; bh=s8LjOJRbFWTjFJU8PunCvZmgxtsSf2yjWOf9YJFE/nI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GibbU1+Bv4hZfyxnOUdEWQvJ076saXI6TQtYu7xSPf0hLoMkceUINh1Rm4ktw8FB/ Odx9liHsq3oBCglicvVM8kHKGRUmVX1gKjK0J76af97iwJiOXMF+HWfWvQPg7XmyyB rRGGkKkMwElvPkthMlIMdugGLor36QHzazjKFaPU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kim Phillips , "Peter Zijlstra (Intel)" , Alexander Shishkin , Arnaldo Carvalho de Melo , Arnaldo Carvalho de Melo , Borislav Petkov , "H. Peter Anvin" , Jiri Olsa , Linus Torvalds , Mark Rutland , Namhyung Kim , Stephane Eranian , Thomas Gleixner , Vince Weaver , Ingo Molnar , Sasha Levin Subject: [PATCH 4.19 096/125] perf/x86/amd/ibs: Handle erratum #420 only on the affected CPU family (10h) Date: Mon, 11 Nov 2019 19:28:55 +0100 Message-Id: <20191111181452.639310015@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191111181438.945353076@linuxfoundation.org> References: <20191111181438.945353076@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kim Phillips [ Upstream commit e431e79b60603079d269e0c2a5177943b95fa4b6 ] This saves us writing the IBS control MSR twice when disabling the event. I searched revision guides for all families since 10h, and did not find occurrence of erratum #420, nor anything remotely similar: so we isolate the secondary MSR write to family 10h only. Also unconditionally update the count mask for IBS Op implementations that have read & writeable current count (CurCnt) fields in addition to the MaxCnt field. These bits were reserved on prior implementations, and therefore shouldn't have negative impact. Signed-off-by: Kim Phillips Signed-off-by: Peter Zijlstra (Intel) Cc: Alexander Shishkin Cc: Arnaldo Carvalho de Melo Cc: Arnaldo Carvalho de Melo Cc: Borislav Petkov Cc: H. Peter Anvin Cc: Jiri Olsa Cc: Linus Torvalds Cc: Mark Rutland Cc: Namhyung Kim Cc: Stephane Eranian Cc: Thomas Gleixner Cc: Vince Weaver Fixes: c9574fe0bdb9 ("perf/x86-ibs: Implement workaround for IBS erratum #420") Link: https://lkml.kernel.org/r/20191023150955.30292-2-kim.phillips@amd.com Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin --- arch/x86/events/amd/ibs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c index fac0867907d4d..07bf5517d9d8b 100644 --- a/arch/x86/events/amd/ibs.c +++ b/arch/x86/events/amd/ibs.c @@ -389,7 +389,8 @@ static inline void perf_ibs_disable_event(struct perf_ibs *perf_ibs, struct hw_perf_event *hwc, u64 config) { config &= ~perf_ibs->cnt_mask; - wrmsrl(hwc->config_base, config); + if (boot_cpu_data.x86 == 0x10) + wrmsrl(hwc->config_base, config); config &= ~perf_ibs->enable_mask; wrmsrl(hwc->config_base, config); } @@ -564,7 +565,8 @@ static struct perf_ibs perf_ibs_op = { }, .msr = MSR_AMD64_IBSOPCTL, .config_mask = IBS_OP_CONFIG_MASK, - .cnt_mask = IBS_OP_MAX_CNT, + .cnt_mask = IBS_OP_MAX_CNT | IBS_OP_CUR_CNT | + IBS_OP_CUR_CNT_RAND, .enable_mask = IBS_OP_ENABLE, .valid_mask = IBS_OP_VAL, .max_period = IBS_OP_MAX_CNT << 4, -- 2.20.1