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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7AB8C77B73 for ; Tue, 2 May 2023 08:53:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233443AbjEBIxg (ORCPT ); Tue, 2 May 2023 04:53:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230004AbjEBIxg (ORCPT ); Tue, 2 May 2023 04:53:36 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECFEB1980 for ; Tue, 2 May 2023 01:53:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=NJjdWxEfNACcW4EZRFYOMwFUpLuIN5tanaRFskyuX6o=; b=J1aBBn8f8V7evgeHDIRw8SV1gi i92wcJB5SFQCPXFUtBv7QffNofEOwOTkawN+vSeWqCpODERXWpbuIjyC8hBg3SP4DrLxFGOj6xIXf cF/Y//yULjneZL5oZB8PBjWOiMirJjsw4hDFen6OXMsY1vpfuCtNcpP6CoXKVePacYti4WlOmeze7 nopvUp5iB3qZorE4shs8J1cvk6h2ZksLGbkwiS5Ob/hWRzICWXvgomPsJZMVV/LDbDE9SkYCM1cOE fS2rdDKgjJPXZOCb7DGma53BVjJ94+5h4kcTIfYu6EfP6GkhE8QSdVqRDo0qUUljXBjmuCzHUMFxY 4lcnFPew==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1ptllF-00GGXb-2z; Tue, 02 May 2023 08:53:26 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 6A95D300165; Tue, 2 May 2023 10:53:25 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 53C2923C5C34C; Tue, 2 May 2023 10:53:25 +0200 (CEST) Date: Tue, 2 May 2023 10:53:25 +0200 From: Peter Zijlstra To: Indu Bhagat Cc: linux-toolchains@vger.kernel.org, daandemeyer@meta.com, andrii@kernel.org, rostedt@goodmis.org, kris.van.hees@oracle.com, elena.zannoni@oracle.com, nick.alcock@oracle.com Subject: Re: [POC 4/5] sframe: add an SFrame format stack tracer Message-ID: <20230502085325.GG1597476@hirez.programming.kicks-ass.net> References: <20230501200410.3973453-1-indu.bhagat@oracle.com> <20230501200410.3973453-5-indu.bhagat@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230501200410.3973453-5-indu.bhagat@oracle.com> Precedence: bulk List-ID: X-Mailing-List: linux-toolchains@vger.kernel.org On Mon, May 01, 2023 at 01:04:09PM -0700, Indu Bhagat wrote: > diff --git a/arch/arm64/include/asm/sframe_regs.h b/arch/arm64/include/asm/sframe_regs.h > new file mode 100644 > index 000000000000..ae9ab9d5d3c1 > --- /dev/null > +++ b/arch/arm64/include/asm/sframe_regs.h > @@ -0,0 +1,37 @@ > +/* SPDX-License-Identifier: GPL-2.0-or-later */ > +/* > + * Copyright (C) 2023, Oracle and/or its affiliates. > + */ > + > +#ifdef ASM_ARM64_SFRAME_REGS_H > +#define ASM_ARM64_SFRAME_REGS_H > + > +#define STACK_ACCESS_LEN 8 > + > +static inline uint64_t > +get_ptregs_ip(struct pt_regs *regs) > +{ > + return regs->pc; > +} > + > +static inline uint64_t > +get_ptregs_sp(struct pt_regs *regs) > +{ > + return regs->sp; > +} > + > +static inline uint64_t > +get_ptregs_fp(struct pt_regs *regs) > +{ > +#define UNWIND_AARCH64_X29 29 /* 64-bit frame pointer. */ > + return (uint64_t)regs->regs[UNWIND_AARCH64_X29]; > +} > + > +static inline uint64_t > +get_ptregs_ra(struct pt_regs *regs) > +{ > +#define UNWIND_AARCH64_X30 30 /* 64-bit link pointer. */ > + return (uint64_t)regs->regs[UNWIND_AARCH64_X30]; > +} > + > +#endif /* ASM_ARM64_SFRAME_REGS_H */ > diff --git a/arch/x86/include/asm/sframe_regs.h b/arch/x86/include/asm/sframe_regs.h > new file mode 100644 > index 000000000000..99f84955854a > --- /dev/null > +++ b/arch/x86/include/asm/sframe_regs.h > @@ -0,0 +1,34 @@ > +/* SPDX-License-Identifier: GPL-2.0-or-later */ > +/* > + * Copyright (C) 2023, Oracle and/or its affiliates. > + */ > + > +#ifndef ASM_X86_SFRAME_REGS_H > +#define ASM_X86_SFRAME_REGS_H > + > +#define STACK_ACCESS_LEN 8 > + > +static inline uint64_t > +get_ptregs_ip(struct pt_regs *regs) > +{ > + return (uint64_t)regs->ip; > +} > + > +static inline uint64_t > +get_ptregs_sp(struct pt_regs *regs) > +{ > + return (uint64_t)regs->sp; > +} > + > +static inline uint64_t > +get_ptregs_fp(struct pt_regs *regs) > +{ > + return (uint64_t)regs->bp; > +} > + > +static inline uint64_t > +get_ptregs_ra(struct pt_regs *regs) > +{ > + return 0; /* SFRAME_CFA_FIXED_RA_INVALID */ > +} > +#endif /* ASM_X86_SFRAME_REGS_H */ arch/*/include/ptrace.h already provides: instruction_pointer(regs) kernel_stack_pointer(regs) frame_pointer(regs) and on arm64: procedure_link_pointer(regs) That do all this, I would suggest you use those instead of creating yet another set of wrappers.