Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2996476imm; Sun, 1 Jul 2018 09:59:11 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI7ULnbn3tIaQpasWo+QIgtMo0veqt+trbpoBiEATerPeq2F/eegO9bEz2FzhmW2O2ifLJU X-Received: by 2002:a17:902:aa01:: with SMTP id be1-v6mr22697993plb.296.1530464351735; Sun, 01 Jul 2018 09:59:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530464351; cv=none; d=google.com; s=arc-20160816; b=AzE9Wzd0VbAREUNwbs4FHzlMw+v+t/Wlm7HmogePkNQU6QqZQqpz9kfinzQjWh7MQm ONU14ZZ3h0FD7RUst87tMvQXSUw1cu08uKPcKM6FzLosUBup4h+h1y5iUHcmGG8854jJ C6FKemR2kP35XhaA6nmpFrw2QFYEvmaMcGinO+8wMt+Yj2HP2Lxncy+2BF8NpuWL8aeB hogOeo/vx6y0ZszUij/KwSYc/trx6+FroUGIA1wGGGelzxcfTnqFOhvaSSbLzqHuekoL azY2Fe27X71i5saJ8osy6Zv8UOovNw3FTLhl6Ta/vC0+eYmos+2SzJt4jcA6IGp8LqH6 iUhw== 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=uZ+NQXZjFTWZd9CbkzkzACNhiJaJKViFUuFvj7KMsfs=; b=kZVoTMbvLDby8BkXbAv1PDFPOxP8X/uban/EPDkk+lKxXKDNUqxMSjmNkLqqKNu1wT 5Ro5K5AehkoxXug+LiUI/D6ttCDxfMQHNQVe2MpEH33RtACgYCtOB4lPCho+iSHm0gsB 7i/p91mdOhg3DVf4WSouUjgD5Zc82CBfS/aOwulPPQsrQC8Jjwgn1Y5ogFPl26d66RSP N9RS4WcGVH3c86dL0KlKRMYl9hc0rt6YBjub9lJgaBctt2WI8eNqcwU8MICNbe2jkqmy bNP1NZ45xVIAfw8eutXShUML0opWHDM2WbRmoUlG0biDyn3juUjyPKd86xQUr84dbjJ7 gzdQ== 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 p18-v6si14139960pfe.150.2018.07.01.09.58.57; Sun, 01 Jul 2018 09:59:11 -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 S1753635AbeGAQo3 (ORCPT + 99 others); Sun, 1 Jul 2018 12:44:29 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:38032 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032485AbeGAQoY (ORCPT ); Sun, 1 Jul 2018 12:44:24 -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 4327292B; Sun, 1 Jul 2018 16:44:24 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Adrian Hunter , Arnaldo Carvalho de Melo Subject: [PATCH 4.17 171/220] perf intel-pt: Fix "Unexpected indirect branch" error Date: Sun, 1 Jul 2018 18:23:15 +0200 Message-Id: <20180701160915.395581145@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160908.272447118@linuxfoundation.org> References: <20180701160908.272447118@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.17-stable review patch. If anyone has any objections, please let me know. ------------------ From: Adrian Hunter commit 9fb523363f6e3984457fee95bb7019395384ffa7 upstream. Some Atom CPUs can produce FUP packets that contain NLIP (next linear instruction pointer) instead of CLIP (current linear instruction pointer). That will result in "Unexpected indirect branch" errors. Fix by comparing IP to NLIP in that case. Signed-off-by: Adrian Hunter Cc: stable@vger.kernel.org Link: http://lkml.kernel.org/r/1527762225-26024-5-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Greg Kroah-Hartman --- tools/perf/util/intel-pt-decoder/intel-pt-decoder.c | 17 +++++++++++++++-- tools/perf/util/intel-pt-decoder/intel-pt-decoder.h | 9 +++++++++ tools/perf/util/intel-pt.c | 4 ++++ 3 files changed, 28 insertions(+), 2 deletions(-) --- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c +++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c @@ -113,6 +113,7 @@ struct intel_pt_decoder { bool have_cyc; bool fixup_last_mtc; bool have_last_ip; + enum intel_pt_param_flags flags; uint64_t pos; uint64_t last_ip; uint64_t ip; @@ -226,6 +227,8 @@ struct intel_pt_decoder *intel_pt_decode decoder->return_compression = params->return_compression; decoder->branch_enable = params->branch_enable; + decoder->flags = params->flags; + decoder->period = params->period; decoder->period_type = params->period_type; @@ -1097,6 +1100,15 @@ static bool intel_pt_fup_event(struct in return ret; } +static inline bool intel_pt_fup_with_nlip(struct intel_pt_decoder *decoder, + struct intel_pt_insn *intel_pt_insn, + uint64_t ip, int err) +{ + return decoder->flags & INTEL_PT_FUP_WITH_NLIP && !err && + intel_pt_insn->branch == INTEL_PT_BR_INDIRECT && + ip == decoder->ip + intel_pt_insn->length; +} + static int intel_pt_walk_fup(struct intel_pt_decoder *decoder) { struct intel_pt_insn intel_pt_insn; @@ -1109,10 +1121,11 @@ static int intel_pt_walk_fup(struct inte err = intel_pt_walk_insn(decoder, &intel_pt_insn, ip); if (err == INTEL_PT_RETURN) return 0; - if (err == -EAGAIN) { + if (err == -EAGAIN || + intel_pt_fup_with_nlip(decoder, &intel_pt_insn, ip, err)) { if (intel_pt_fup_event(decoder)) return 0; - return err; + return -EAGAIN; } decoder->set_fup_tx_flags = false; if (err) --- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.h +++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.h @@ -60,6 +60,14 @@ enum { INTEL_PT_ERR_MAX, }; +enum intel_pt_param_flags { + /* + * FUP packet can contain next linear instruction pointer instead of + * current linear instruction pointer. + */ + INTEL_PT_FUP_WITH_NLIP = 1 << 0, +}; + struct intel_pt_state { enum intel_pt_sample_type type; int err; @@ -106,6 +114,7 @@ struct intel_pt_params { unsigned int mtc_period; uint32_t tsc_ctc_ratio_n; uint32_t tsc_ctc_ratio_d; + enum intel_pt_param_flags flags; }; struct intel_pt_decoder; --- a/tools/perf/util/intel-pt.c +++ b/tools/perf/util/intel-pt.c @@ -751,6 +751,7 @@ static struct intel_pt_queue *intel_pt_a unsigned int queue_nr) { struct intel_pt_params params = { .get_trace = 0, }; + struct perf_env *env = pt->machine->env; struct intel_pt_queue *ptq; ptq = zalloc(sizeof(struct intel_pt_queue)); @@ -832,6 +833,9 @@ static struct intel_pt_queue *intel_pt_a } } + if (env->cpuid && !strncmp(env->cpuid, "GenuineIntel,6,92,", 18)) + params.flags |= INTEL_PT_FUP_WITH_NLIP; + ptq->decoder = intel_pt_decoder_new(¶ms); if (!ptq->decoder) goto out_free;