Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1911201pxb; Thu, 16 Sep 2021 20:01:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrgYIfz4jcTEZsTmol1MHdCCEm+iwIYATsmlrrCox4/fp2BhNQE3zbVKgZEJyiLBm/PDg7 X-Received: by 2002:a92:c247:: with SMTP id k7mr6222932ilo.258.1631847663876; Thu, 16 Sep 2021 20:01:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631847663; cv=none; d=google.com; s=arc-20160816; b=EXk8ExeaF4CfThpxTr1v6YRK/mXJoXy1VhKsxdR96vT8DOXirjUG+ggtUzKaP09lWv lsx5DMNPiljfVJAB4szdxt5cm5JhH0xbM9L3y4NKVM+HtIVwNOGevoaEgrlF9K01h/QE UHF13BJmlbcc7SRhlax7gIyw096mx3NACHNT4RJQkQc8592JMrCq0yZ1Gy28XKow7+nl tgklVceVrItidaxAbj6d25kGsFvAF6hs6h26Y9tG+u4uV2GemsHInU1qUXeLCxEyZt2h ks9iAn3SI4Ye8QIYiqadbp0FCL8MCBFwtmTc0/584znNKzzEU1LYOJVAX80zPQCUfYL8 dDuA== 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=o/5TguwiqabGmWUhxg6CLiN/Bu3T9mVHoBLupjBV+RI=; b=hkHbcZ7p3rBmRg14k8KI++JMoG5zC+ItJgixoVYTPD5ObxCSH5DYISS8wWzT/i+B8N nyMdDSAKZ0pPYqBaOnGN8Bd/1OII6nd967okNJz+LbwxNT6c/cEe53E5JhTp94xueiAc bR9J2bO4U8AwnB30zf6hsOc4EnWzFAp3qhSayfMVsHpXFNDnnrADMAKZHEQayZyFRXxS L655wqRrlRBRNo/D+xcm9jjZ9kKl54mxdjJRID//8lx/AZVMw3C4yVGRhdtGqAoEMajU vxmTr7gk5haKr064nY3cmkAVH0AorWC2BuGCqnTcz+p6PFrcp7R8SWMpXws3IAY+knaF Vryw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=doAqHOfQ; 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=pass (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 18si4137292jak.85.2021.09.16.20.00.51; Thu, 16 Sep 2021 20:01:03 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=doAqHOfQ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236571AbhIPR3C (ORCPT + 99 others); Thu, 16 Sep 2021 13:29:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:43516 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351938AbhIPRUA (ORCPT ); Thu, 16 Sep 2021 13:20:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F344360EE5; Thu, 16 Sep 2021 16:41:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631810507; bh=4hE52cXqdxjES0qafaKTL/fZ6kRAsV34oJ66ygiGwJ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=doAqHOfQzwJNSVtAujX+kZ65fimAsPSpuMHto0/GKn/DtrTsw2LgbltzWP/SI5l9y 2j6Mbss4vCotUy9PM5ErnJtDs+6UtauhwdWoCDCma61+vWq6uz3gdEDkBkjGBbcXFL 9RBU0q+B9uATI/746O1I1ZVdkc0eU2NUZypx5NMY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kajol Jain , Michael Ellerman , Sasha Levin Subject: [PATCH 5.14 134/432] powerpc/perf: Fix the check for SIAR value Date: Thu, 16 Sep 2021 17:58:03 +0200 Message-Id: <20210916155815.300420072@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155810.813340753@linuxfoundation.org> References: <20210916155810.813340753@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: Kajol Jain [ Upstream commit 3c69a5f22223fa3e312689ec218b5059784d49d7 ] Incase of random sampling, there can be scenarios where Sample Instruction Address Register(SIAR) may not latch to the sampled instruction and could result in the value of 0. In these scenarios it is preferred to return regs->nip. These corner cases are seen in the previous generation (p9) also. Patch adds the check for SIAR value along with regs_use_siar and siar_valid checks so that the function will return regs->nip incase SIAR is zero. Patch drops the code under PPMU_P10_DD1 flag check which handles SIAR 0 case only for Power10 DD1. Fixes: 2ca13a4cc56c9 ("powerpc/perf: Use regs->nip when SIAR is zero") Signed-off-by: Kajol Jain Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20210818171556.36912-3-kjain@linux.ibm.com Signed-off-by: Sasha Levin --- arch/powerpc/perf/core-book3s.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c index bb0ee716de91..b0a589409039 100644 --- a/arch/powerpc/perf/core-book3s.c +++ b/arch/powerpc/perf/core-book3s.c @@ -2251,18 +2251,10 @@ unsigned long perf_misc_flags(struct pt_regs *regs) */ unsigned long perf_instruction_pointer(struct pt_regs *regs) { - bool use_siar = regs_use_siar(regs); unsigned long siar = mfspr(SPRN_SIAR); - if (ppmu && (ppmu->flags & PPMU_P10_DD1)) { - if (siar) - return siar; - else - return regs->nip; - } else if (use_siar && siar_valid(regs)) - return mfspr(SPRN_SIAR) + perf_ip_adjust(regs); - else if (use_siar) - return 0; // no valid instruction pointer + if (regs_use_siar(regs) && siar_valid(regs) && siar) + return siar + perf_ip_adjust(regs); else return regs->nip; } -- 2.30.2