Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1236636imm; Sun, 15 Jul 2018 02:44:56 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfGzqUAG2vIpkKPSTlTMDuqe9a7x8sel41QMy5+YGoKyC4DDmfdwG78jKlro4Wx46U6XIW6 X-Received: by 2002:a17:902:5381:: with SMTP id c1-v6mr12566202pli.137.1531647896174; Sun, 15 Jul 2018 02:44:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531647896; cv=none; d=google.com; s=arc-20160816; b=cHJUglNoqJ5OfymDGR0wbcfEjg0TLZuenaWXFaCOs23/6ZC63Gymiy7tltBshH4eeb PkXZRf7qR1bABW4drcsBV/tNlx2FMapTcYgFfVaMj01uu4vzpUK68KldRvwCeea659Yw oUkiXb+/8wmG2jbY8cz2o2pVP6F2QACZ3Vz6p2v1gWy5qFpKUa8e/ulNtJSNFdlEVRVN 1J1j2rI3wyRW4kKsHLH3YrfYB/5nPhCrKQIJmaDF93LqTkey+Gz6CAKMVH3vxQg/UpRk +83ZGiSaHZcEeK+0Zx4UU9AF5bz0rfAoDGWAgDPcXwexQuyuXFRPmjHAYsghH7phEXSy Ewpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=AVYMVh7ryAGXDGDKYVBCWLBjV94k/gLeAKpilJMRnHQ=; b=u+8Rb1ulmqJ0Lyz+U+rIlFh6+e1NjYR0LtPAdZZek2VbYTAbrlVtWVoJ3ExUi/jS21 ly9ylDDosjUuMt4ro/feaGcpsJkZPoCof/XOT7UdbxqFc/SCNWwi4dnFz1rzeagzUmx+ 6Rz5C2YUYyFhuCHwbCrlG8jl3NGoj/cfQOxBTOno6+oNDEqD4dImxgP5+gqO1dfRQUCg 4Hp//09OMyMX8ZQbqvMjYO+zhgqZNeA67MvN0ZKX+OnsWn7hXh6n0coVVVZ9XhnUErZq 6ay3U0zkXSN39u5ZZm5MIY3iOmAp+Jq125JOtc2dg3X73KWlagy4gJburRblq3CqVubM UTrg== 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 w27-v6si27230388pgc.232.2018.07.15.02.44.27; Sun, 15 Jul 2018 02:44:56 -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 S1726184AbeGOKFx (ORCPT + 99 others); Sun, 15 Jul 2018 06:05:53 -0400 Received: from terminus.zytor.com ([198.137.202.136]:51067 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726099AbeGOKFx (ORCPT ); Sun, 15 Jul 2018 06:05:53 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w6F9h2AU729841 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 15 Jul 2018 02:43:02 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w6F9gxM6729838; Sun, 15 Jul 2018 02:42:59 -0700 Date: Sun, 15 Jul 2018 02:42:59 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Hugh Dickins Message-ID: Cc: mingo@kernel.org, hpa@zytor.com, markus.t.metzger@intel.com, dave.hansen@intel.com, linux-kernel@vger.kernel.org, acme@kernel.org, eranian@google.com, alexander.shishkin@intel.com, andi.kleen@intel.com, hughd@google.com, tglx@linutronix.de, peterz@infradead.org Reply-To: tglx@linutronix.de, andi.kleen@intel.com, hughd@google.com, peterz@infradead.org, eranian@google.com, alexander.shishkin@intel.com, markus.t.metzger@intel.com, acme@kernel.org, linux-kernel@vger.kernel.org, dave.hansen@intel.com, hpa@zytor.com, mingo@kernel.org In-Reply-To: References: To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/pti] x86/events/intel/ds: Fix bts_interrupt_threshold alignment Git-Commit-ID: 2c991e408df6a407476dbc453d725e1e975479e7 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 2c991e408df6a407476dbc453d725e1e975479e7 Gitweb: https://git.kernel.org/tip/2c991e408df6a407476dbc453d725e1e975479e7 Author: Hugh Dickins AuthorDate: Sat, 14 Jul 2018 12:58:07 -0700 Committer: Thomas Gleixner CommitDate: Sun, 15 Jul 2018 11:38:44 +0200 x86/events/intel/ds: Fix bts_interrupt_threshold alignment Markus reported that BTS is sporadically missing the tail of the trace in the perf_event data buffer: [decode error (1): instruction overflow] shown in GDB; and bisected it to the conversion of debug_store to PTI. A little "optimization" crept into alloc_bts_buffer(), which mistakenly placed bts_interrupt_threshold away from the 24-byte record boundary. Intel SDM Vol 3B 17.4.9 says "This address must point to an offset from the BTS buffer base that is a multiple of the BTS record size." Revert "max" from a byte count to a record count, to calculate the bts_interrupt_threshold correctly: which turns out to fix problem seen. Fixes: c1961a4631da ("x86/events/intel/ds: Map debug buffers in cpu_entry_area") Reported-and-tested-by: Markus T Metzger Signed-off-by: Hugh Dickins Signed-off-by: Thomas Gleixner Cc: Peter Zijlstra Cc: Arnaldo Carvalho de Melo Cc: Alexander Shishkin Cc: Andi Kleen Cc: Dave Hansen Cc: Stephane Eranian Cc: stable@vger.kernel.org # v4.14+ Link: https://lkml.kernel.org/r/alpine.LSU.2.11.1807141248290.1614@eggly.anvils --- arch/x86/events/intel/ds.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c index 8a10a045b57b..8cf03f101938 100644 --- a/arch/x86/events/intel/ds.c +++ b/arch/x86/events/intel/ds.c @@ -408,9 +408,11 @@ static int alloc_bts_buffer(int cpu) ds->bts_buffer_base = (unsigned long) cea; ds_update_cea(cea, buffer, BTS_BUFFER_SIZE, PAGE_KERNEL); ds->bts_index = ds->bts_buffer_base; - max = BTS_RECORD_SIZE * (BTS_BUFFER_SIZE / BTS_RECORD_SIZE); - ds->bts_absolute_maximum = ds->bts_buffer_base + max; - ds->bts_interrupt_threshold = ds->bts_absolute_maximum - (max / 16); + max = BTS_BUFFER_SIZE / BTS_RECORD_SIZE; + ds->bts_absolute_maximum = ds->bts_buffer_base + + max * BTS_RECORD_SIZE; + ds->bts_interrupt_threshold = ds->bts_absolute_maximum - + (max / 16) * BTS_RECORD_SIZE; return 0; }