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=-12.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 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 84F42C4338F for ; Tue, 24 Aug 2021 17:39:55 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 57FA561163 for ; Tue, 24 Aug 2021 17:39:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 57FA561163 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:References:Cc:To:From:Subject:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=xetkJRMbrNfWx1pkleSpnmjeKrmN+tKXl1s0qBk8iuM=; b=OZgFD8dKnZGnlETMJtmakMWHpM oHTQ1DWdiVwaCiF8D7QXT20W0agy0DL+8mfnX1XmtNeTD7a1SjIjBQ6/53lb4hxJi1wljtKqwkrtx eZH0eiXnVd9y5SSfmG6669QS+sV93PUI6UYL5AG4ySZvBwHTJxYajgZiqMSVCpomgmrLDj6ShkB4b iIoNz4bf9jpmgqvABpE3ZrSMmVk4CUOtqcjmlHmMMdedAska9r+YfR3Tn6LNXQtO0lDAod44856l5 Ko5Mcc4MzYEZhG0o45Py8DyeKzLSx+uOv0DcwrY19E3KQnKne3y3jUKE5Q60SgZi/UYFbR1iTPpI5 b9tvxUsQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIaNe-004Cwo-GJ; Tue, 24 Aug 2021 17:38:34 +0000 Received: from linux.microsoft.com ([13.77.154.182]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIaNY-004CvV-Is for linux-arm-kernel@lists.infradead.org; Tue, 24 Aug 2021 17:38:29 +0000 Received: from [192.168.254.32] (unknown [47.187.212.181]) by linux.microsoft.com (Postfix) with ESMTPSA id EC1F720B85E8; Tue, 24 Aug 2021 10:38:26 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com EC1F720B85E8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1629826707; bh=R6YgY1J4gD2s66MsoljAfldZ8VnigpmKriT610HRPkU=; h=Subject:From:To:Cc:References:Date:In-Reply-To:From; b=D8lpOYe/w8+XekYIkMuGN2ml0DXIA/rRNfpe25N549BSWSVkYpTaqKMxVniIa/IdI PeQdYBq1e27VHs5DsxVy62nrlNWX0FRFLQ9EbbwhlraKxJ1EB+1z/xPpSaQMdJ0Xfg 9pNJMx7tdilmCXyFIoXwoCE17pO1aBz93QBxtNEc= Subject: Re: [RFC PATCH v8 1/4] arm64: Make all stack walking functions use arch_stack_walk() From: "Madhavan T. Venkataraman" To: Mark Rutland Cc: broonie@kernel.org, jpoimboe@redhat.com, ardb@kernel.org, nobuta.keiya@fujitsu.com, sjitindarsingh@gmail.com, catalin.marinas@arm.com, will@kernel.org, jmorris@namei.org, pasha.tatashin@soleen.com, jthierry@redhat.com, linux-arm-kernel@lists.infradead.org, live-patching@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210812190603.25326-1-madvenka@linux.microsoft.com> <20210812190603.25326-2-madvenka@linux.microsoft.com> <20210824131344.GE96738@C02TD0UTHF1T.local> Message-ID: <66d0ff83-bf67-5576-4c74-10f825855091@linux.microsoft.com> Date: Tue, 24 Aug 2021 12:38:25 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210824_103828_726294_ABE78D9A X-CRM114-Status: GOOD ( 14.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org >>> diff --git a/arch/arm64/kernel/return_address.c b/arch/arm64/kernel/return_address.c >>> index a6d18755652f..92a0f4d434e4 100644 >>> --- a/arch/arm64/kernel/return_address.c >>> +++ b/arch/arm64/kernel/return_address.c >>> @@ -35,15 +35,11 @@ NOKPROBE_SYMBOL(save_return_addr); >>> void *return_address(unsigned int level) >>> { >>> struct return_address_data data; >>> - struct stackframe frame; >>> >>> data.level = level + 2; >>> data.addr = NULL; >>> >>> - start_backtrace(&frame, >>> - (unsigned long)__builtin_frame_address(0), >>> - (unsigned long)return_address); >>> - walk_stackframe(current, &frame, save_return_addr, &data); >>> + arch_stack_walk(save_return_addr, &data, current, NULL); >>> >>> if (!data.level) >>> return data.addr; >> >> Nor that arch_stack_walk() will start with it's caller, so >> return_address() will be included in the trace where it wasn't >> previously, which implies we need to skip an additional level. >> > > You are correct. I will fix this. Thanks for catching this. > >> That said, I'm not entirely sure why we need to skip 2 levels today; it >> might be worth checking that's correct. >> > > AFAICT, return_address() acts like builtin_return_address(). That is, it > returns the address of the caller. If func() calls return_address(), > func() wants its caller's address. So, return_address() and func() need to > be skipped. > > I will change it to skip 3 levels instead of 2. > Actually, I take that back. I remember now. return_address() used to start with PC=return_address(). That is, it used to start with itself. arch_stack_walk() starts with its caller which, in this case, is return_address(). So, I don't need to change anything. Do you agree? Madhavan _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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=-21.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1, USER_IN_DEF_DKIM_WL autolearn=unavailable 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 0ECF4C4338F for ; Tue, 24 Aug 2021 17:41:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E4BCA610FD for ; Tue, 24 Aug 2021 17:41:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241068AbhHXRmg (ORCPT ); Tue, 24 Aug 2021 13:42:36 -0400 Received: from linux.microsoft.com ([13.77.154.182]:38164 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242156AbhHXRjM (ORCPT ); Tue, 24 Aug 2021 13:39:12 -0400 Received: from [192.168.254.32] (unknown [47.187.212.181]) by linux.microsoft.com (Postfix) with ESMTPSA id EC1F720B85E8; Tue, 24 Aug 2021 10:38:26 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com EC1F720B85E8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1629826707; bh=R6YgY1J4gD2s66MsoljAfldZ8VnigpmKriT610HRPkU=; h=Subject:From:To:Cc:References:Date:In-Reply-To:From; b=D8lpOYe/w8+XekYIkMuGN2ml0DXIA/rRNfpe25N549BSWSVkYpTaqKMxVniIa/IdI PeQdYBq1e27VHs5DsxVy62nrlNWX0FRFLQ9EbbwhlraKxJ1EB+1z/xPpSaQMdJ0Xfg 9pNJMx7tdilmCXyFIoXwoCE17pO1aBz93QBxtNEc= Subject: Re: [RFC PATCH v8 1/4] arm64: Make all stack walking functions use arch_stack_walk() From: "Madhavan T. Venkataraman" To: Mark Rutland Cc: broonie@kernel.org, jpoimboe@redhat.com, ardb@kernel.org, nobuta.keiya@fujitsu.com, sjitindarsingh@gmail.com, catalin.marinas@arm.com, will@kernel.org, jmorris@namei.org, pasha.tatashin@soleen.com, jthierry@redhat.com, linux-arm-kernel@lists.infradead.org, live-patching@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210812190603.25326-1-madvenka@linux.microsoft.com> <20210812190603.25326-2-madvenka@linux.microsoft.com> <20210824131344.GE96738@C02TD0UTHF1T.local> Message-ID: <66d0ff83-bf67-5576-4c74-10f825855091@linux.microsoft.com> Date: Tue, 24 Aug 2021 12:38:25 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >>> diff --git a/arch/arm64/kernel/return_address.c b/arch/arm64/kernel/return_address.c >>> index a6d18755652f..92a0f4d434e4 100644 >>> --- a/arch/arm64/kernel/return_address.c >>> +++ b/arch/arm64/kernel/return_address.c >>> @@ -35,15 +35,11 @@ NOKPROBE_SYMBOL(save_return_addr); >>> void *return_address(unsigned int level) >>> { >>> struct return_address_data data; >>> - struct stackframe frame; >>> >>> data.level = level + 2; >>> data.addr = NULL; >>> >>> - start_backtrace(&frame, >>> - (unsigned long)__builtin_frame_address(0), >>> - (unsigned long)return_address); >>> - walk_stackframe(current, &frame, save_return_addr, &data); >>> + arch_stack_walk(save_return_addr, &data, current, NULL); >>> >>> if (!data.level) >>> return data.addr; >> >> Nor that arch_stack_walk() will start with it's caller, so >> return_address() will be included in the trace where it wasn't >> previously, which implies we need to skip an additional level. >> > > You are correct. I will fix this. Thanks for catching this. > >> That said, I'm not entirely sure why we need to skip 2 levels today; it >> might be worth checking that's correct. >> > > AFAICT, return_address() acts like builtin_return_address(). That is, it > returns the address of the caller. If func() calls return_address(), > func() wants its caller's address. So, return_address() and func() need to > be skipped. > > I will change it to skip 3 levels instead of 2. > Actually, I take that back. I remember now. return_address() used to start with PC=return_address(). That is, it used to start with itself. arch_stack_walk() starts with its caller which, in this case, is return_address(). So, I don't need to change anything. Do you agree? Madhavan