Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3795554imm; Mon, 18 Jun 2018 04:19:25 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLr559G+5WF0XtLtnCCAZq9Q4aCUTAxKlMQDYXYJ8kRZoKJZ8gbBp5VheHUWj8SfL0WJXYv X-Received: by 2002:a65:5d4a:: with SMTP id e10-v6mr7544485pgt.25.1529320765044; Mon, 18 Jun 2018 04:19:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529320765; cv=none; d=google.com; s=arc-20160816; b=Gjj7iYkfKryBPVYQ7q3OlPah//HFzLvXbKsFpneTDu9IcroQ1RIumP28ZZS4sGTwIf bEbygYzabmmG46ecPSU4mVlXXIrP6tjDdnDxM77y2CHSoyuXqIorWVMEkTT1dbSZHeAM uPVXAIoxrPtMUUxZdUZAiguTdGj2ZWyiNineXAmGD8RfGxyzf/EgMdWX/np9J32D8N0k T1SfIOwzjqtj+ZDjPWIpCUIckv5ihe97gW6gOZJns72vTq+oswcdyjERg98+rtY/JyjU o7H5HxqKiw+3rIDtTNL/gpCBM4lE/iYatGAuKAVNrfxrnWtJQm8FiyIh/WCf+vZvq4rf cIIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Kg9Rf91OoFAbIdK1bP421kXaWnXtH4DOepZyeVHH6Ik=; b=gMcMraz9gyiWzgbPA3kr3YQAw7Ipkrbvso8DgkFypeKYxIcDB/UBB07hUIUcJyPrrT ewZURS6uPPqzqEfr8gEwQF2h/+U/UmqwtsIqgWDtWGbHbrHqqGm6k/WzSLVzUlc9jQv+ b8SHKWsQy/6ypZzylZQWuZinQO4Cmu7HgzVxSv5I5Hg9YCbx6jUsw5wI6f2IZcYaBf1U bHN87iGukTNgqawQjZ9GRpeFuBy4TbYDFz4C44h3fx1b3/rOdbB4WCrQbDHJeNbE7IUd 85hy8DXsqSazbaNxxGNrYUh+SVL6LpYY6zG0u4vhNdi4FWKbAc0cDM61xVlQdHR116kO kQgw== ARC-Authentication-Results: i=1; mx.google.com; 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 m20-v6si13947778pff.301.2018.06.18.04.19.10; Mon, 18 Jun 2018 04:19:25 -0700 (PDT) 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; 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 S935829AbeFRIVd (ORCPT + 99 others); Mon, 18 Jun 2018 04:21:33 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:55324 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935726AbeFRIVa (ORCPT ); Mon, 18 Jun 2018 04:21:30 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id EEFFBC7F; Mon, 18 Jun 2018 08:21:29 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kan Liang , Thomas Gleixner , "Peter Zijlstra (Intel)" , ak@linux.intel.com, eranian@google.com, acme@redhat.com, Sasha Levin Subject: [PATCH 4.16 101/279] perf/x86/intel: Dont enable freeze-on-smi for PerfMon V1 Date: Mon, 18 Jun 2018 10:11:26 +0200 Message-Id: <20180618080612.978030095@linuxfoundation.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618080608.851973560@linuxfoundation.org> References: <20180618080608.851973560@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kan Liang [ Upstream commit 4e949e9b9d1e3edcdab3b54656c5851bd9e49c67 ] The SMM freeze feature was introduced since PerfMon V2. But the current code unconditionally enables the feature for all platforms. It can generate #GP exception, if the related FREEZE_WHILE_SMM bit is set for the machine with PerfMon V1. To disable the feature for PerfMon V1, perf needs to - Remove the freeze_on_smi sysfs entry by moving intel_pmu_attrs to intel_pmu, which is only applied to PerfMon V2 and later. - Check the PerfMon version before flipping the SMM bit when starting CPU Fixes: 6089327f5424 ("perf/x86: Add sysfs entry to freeze counters on SMI") Signed-off-by: Kan Liang Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) Cc: ak@linux.intel.com Cc: eranian@google.com Cc: acme@redhat.com Link: https://lkml.kernel.org/r/1524682637-63219-1-git-send-email-kan.liang@linux.intel.com Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- arch/x86/events/intel/core.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -3331,7 +3331,8 @@ static void intel_pmu_cpu_starting(int c cpuc->lbr_sel = NULL; - flip_smm_bit(&x86_pmu.attr_freeze_on_smi); + if (x86_pmu.version > 1) + flip_smm_bit(&x86_pmu.attr_freeze_on_smi); if (!cpuc->shared_regs) return; @@ -3494,6 +3495,8 @@ static __initconst const struct x86_pmu .cpu_dying = intel_pmu_cpu_dying, }; +static struct attribute *intel_pmu_attrs[]; + static __initconst const struct x86_pmu intel_pmu = { .name = "Intel", .handle_irq = intel_pmu_handle_irq, @@ -3524,6 +3527,8 @@ static __initconst const struct x86_pmu .format_attrs = intel_arch3_formats_attr, .events_sysfs_show = intel_event_sysfs_show, + .attrs = intel_pmu_attrs, + .cpu_prepare = intel_pmu_cpu_prepare, .cpu_starting = intel_pmu_cpu_starting, .cpu_dying = intel_pmu_cpu_dying, @@ -3902,8 +3907,6 @@ __init int intel_pmu_init(void) x86_pmu.max_pebs_events = min_t(unsigned, MAX_PEBS_EVENTS, x86_pmu.num_counters); - - x86_pmu.attrs = intel_pmu_attrs; /* * Quirk: v2 perfmon does not report fixed-purpose events, so * assume at least 3 events, when not running in a hypervisor: