From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F6D1C433DF for ; Wed, 27 May 2020 15:04:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2C1C62088E for ; Wed, 27 May 2020 15:04:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389523AbgE0PEE (ORCPT ); Wed, 27 May 2020 11:04:04 -0400 Received: from foss.arm.com ([217.140.110.172]:39754 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388922AbgE0PED (ORCPT ); Wed, 27 May 2020 11:04:03 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5650D30E; Wed, 27 May 2020 08:04:02 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [10.57.7.129]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F37C13F52E; Wed, 27 May 2020 08:03:59 -0700 (PDT) Date: Wed, 27 May 2020 16:03:57 +0100 From: Mark Rutland To: Will Deacon Cc: Jiping Ma , zhe.he@windriver.com, bruce.ashfield@gmail.com, yue.tao@windriver.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, paul.gortmaker@windriver.com, catalin.marinas@arm.com, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH][V3] arm64: perf: Get the wrong PC value in REGS_ABI_32 mode Message-ID: <20200527150357.GB59947@C02TD0UTHF1T.local> References: <1589165527-188401-1-git-send-email-jiping.ma2@windriver.com> <20200526102611.GA1363@C02TD0UTHF1T.local> <20200526195419.GB2206@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200526195419.GB2206@willie-the-truck> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 26, 2020 at 08:54:19PM +0100, Will Deacon wrote: > On Tue, May 26, 2020 at 11:26:11AM +0100, Mark Rutland wrote: > > On Mon, May 11, 2020 at 10:52:07AM +0800, Jiping Ma wrote: > > > Modified the patch subject and the change description. > > > > > > PC value is get from regs[15] in REGS_ABI_32 mode, but correct PC > > > is regs->pc(regs[PERF_REG_ARM64_PC]) in arm64 kernel, which caused > > > that perf can not parser the backtrace of app with dwarf mode in the > > > 32bit system and 64bit kernel. > > > > > > Signed-off-by: Jiping Ma > > > > Thanks for this. > > > > > > > --- > > > arch/arm64/kernel/perf_regs.c | 4 ++++ > > > 1 file changed, 4 insertions(+) > > > > > > diff --git a/arch/arm64/kernel/perf_regs.c b/arch/arm64/kernel/perf_regs.c > > > index 0bbac61..0ef2880 100644 > > > --- a/arch/arm64/kernel/perf_regs.c > > > +++ b/arch/arm64/kernel/perf_regs.c > > > @@ -32,6 +32,10 @@ u64 perf_reg_value(struct pt_regs *regs, int idx) > > > if ((u32)idx == PERF_REG_ARM64_PC) > > > return regs->pc; > > > > > > + if (perf_reg_abi(current) == PERF_SAMPLE_REGS_ABI_32 > > > + && idx == 15) > > > + return regs->pc; > > > > I think there are some more issues here, and we may need a more > > substantial rework. For a compat thread, we always expose > > PERF_SAMPLE_REGS_ABI_32 via per_reg_abi(), but for some reason > > perf_reg_value() also munges the compat SP/LR into their ARM64 > > equivalents, which don't exist in the 32-bit sample ABI. We also don't > > zero the regs that don't exist in 32-bit (including the aliasing PC). > > I think this was for the case where you have a 64-bit perf profiling a > 32-bit task, and it was passing the registers off to libunwind. Won't that > break if we follow your suggestion? Oh yuck; have we messed up the ABI here, or have I misunderstood? Is arm64's PERF_SAMPLE_REGS_ABI_32 supposed to be the same as the 32-bit arm's PERF_SAMPLE_REGS_ABI_32? If yes, and the differences are being relied upon by 64-bit consumers, that's a nasty ABI issue we've introduced for compat tasks, and I don't think this patch alone is quite right. If no, then I don't see that any change is necessary, as we already expose the information, and it's a userspace bug to expect the PC in a place where the kernel has never exposed it. Thanks, Mark.