Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2011723pxb; Fri, 22 Oct 2021 11:58:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8b8HmYKb9z3dq914ILHX3pkLJPh2IYvOsaVlcqtxHTl0CX/Z4y3gSNaCdQiS+Zh5kILyU X-Received: by 2002:a17:906:c041:: with SMTP id bm1mr1648461ejb.280.1634929132730; Fri, 22 Oct 2021 11:58:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634929132; cv=none; d=google.com; s=arc-20160816; b=dtiqu0K48VpiIXY2+9jrWMW1qrbcclw9nkAvEQsHgEV87imAAEdxaHwa8fHCph1N/C OkwyJlCATmKnRxkFGEXW+rqtK4d9xyJ8Gux94Di9xTQjkLE8NWfnWzbsR26mSEOewKp8 jL6uEthymhz9fqaFxzkbIUeBSSFMS4lpAFbJAQ35JeCIY/COyM4ltldK/aBzF/DJLyin SJ+kjOVG/hsd0XWAtqU6UZ4fQmtuKqaPPXsuI57eEEWEUohRTaLMvyUysh5oGbX/NNUU dEOirYwELGXhH81S61RoD6k7wm0Y5j6IjumU7iSa/AX8rGbr9wrkBrkVMDhTsZrY/BJJ VrVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=Bxz7b5OtxaDJHoVtMf11y2MpnG4luAlPF9DTXTcjM7E=; b=YiY5PziC3966MhzkNNY/nGa8aOfcMtwqBubxKcoU8UBDq+4c6Qju80lp32d+cn3I+m K9AqGL+pX1pFXAZumwumtzLkj+h+caM8Iwm4K+T6IUkTcQY8yaMrsrRc1dYhyritfkbi SaaAclt4eYmwa37zESKSzOa+pE5zIfTTAHOc6iFx1UUKgPE2XrVCvGnUDAIruJZhbge8 wkZ8i3WhfETGc6HqOWVK/8L/lG1mbvXmX7ml9oIG6TyPKHUtOr7MBZmr31mMMmQNvcbq +OtBKICWbxmsCu/jmwAasUS/kcMR9TLNC0nR15o+jWWOPuF8Y0e5xiwML50+0ctywhup N/1g== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hp24si18219439ejc.400.2021.10.22.11.58.14; Fri, 22 Oct 2021 11:58:52 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231883AbhJVSyR (ORCPT + 99 others); Fri, 22 Oct 2021 14:54:17 -0400 Received: from foss.arm.com ([217.140.110.172]:57856 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbhJVSyQ (ORCPT ); Fri, 22 Oct 2021 14:54:16 -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 A9AE61063; Fri, 22 Oct 2021 11:51:58 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [10.57.73.6]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3D4D83F73D; Fri, 22 Oct 2021 11:51:56 -0700 (PDT) Date: Fri, 22 Oct 2021 19:51:48 +0100 From: Mark Rutland To: madvenka@linux.microsoft.com 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, linux-arm-kernel@lists.infradead.org, live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v10 04/11] arm64: Make return_address() use arch_stack_walk() Message-ID: <20211022185148.GA91654@C02TD0UTHF1T.local> References: <20211015025847.17694-1-madvenka@linux.microsoft.com> <20211015025847.17694-5-madvenka@linux.microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211015025847.17694-5-madvenka@linux.microsoft.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 14, 2021 at 09:58:40PM -0500, madvenka@linux.microsoft.com wrote: > From: "Madhavan T. Venkataraman" > > Currently, return_address() in ARM64 code walks the stack using > start_backtrace() and walk_stackframe(). Make it use arch_stack_walk() > instead. This makes maintenance easier. > > Signed-off-by: Madhavan T. Venkataraman > --- > arch/arm64/kernel/return_address.c | 6 +----- > 1 file changed, 1 insertion(+), 5 deletions(-) > > 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); This looks equivalent to me. Previously the arguments to start_backtrace() meant that walk_stackframe would report return_address(), then the caller of return_address(), and so on. As arch_stack_walk() starts from its immediate caller (i.e. return_address()), that should result in the same trace. It would be nice if we could note something to that effect in the commit message. I had a play with ftrace, which uses return_address(), and that all looks sound. > > if (!data.level) > return data.addr; The end of this function currently does: if (!data.level) return data.addr; else return NULL; ... but since we initialize data.addr to NULL, and save_return_addr() only writes to data.addr when called at the correct level, we can simplify that to: return data.addr; Regardles of that cleanup: Reviewed-by: Mark Rutland Tested-by: Mark Rutland I'll continue reviewing the series next week. Thanks, Mark.