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 21FD1C77B73 for ; Tue, 2 May 2023 08:48:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230004AbjEBIsn (ORCPT ); Tue, 2 May 2023 04:48:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233548AbjEBIsK (ORCPT ); Tue, 2 May 2023 04:48:10 -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 081B54C07 for ; Tue, 2 May 2023 01:46:54 -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=aCoiroyzf8A0N9VclO0xAKz26lhC3J9r2EyYMDpT9Ns=; b=QFVdikJprX0pIRmoDj+Ij6c5hi PPin1/scWtR1qKd2GQreqqwSwGN8O1P8QrGahfD0WOqU0pB7OAcfgqi56+tOVUIMjMuCBrn8qyeA1 II0MebLN81M+3neHYHrO2rL6WLIdQwlMLLOZhD5RlpGfhU0Wd3v6Y8iSZkTMYqJpnPLXyk0/Rj+sd G9AoEbSK1lGc4ha6VoBOnbchcwX9IUTpHHbc+MF63Ey6fhmNmE7R9/Cilv41b7085M6wS/z+JDBxh 7O3f4dLGhtg0JhyxRevxIsgfwC7qwEKenu2/hmOKeQ/9DCNAFMT+RoBBjwqceUNmJJvgdgwEkhRo6 UNCwTXbQ==; 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 1ptlel-00GGTr-0r; Tue, 02 May 2023 08:46:43 +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 78524300165; Tue, 2 May 2023 10:46:40 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id D562223C5C347; Tue, 2 May 2023 10:46:40 +0200 (CEST) Date: Tue, 2 May 2023 10:46:40 +0200 From: Peter Zijlstra To: Steven Rostedt Cc: Indu Bhagat , linux-toolchains@vger.kernel.org, daandemeyer@meta.com, andrii@kernel.org, kris.van.hees@oracle.com, elena.zannoni@oracle.com, nick.alcock@oracle.com Subject: Re: [POC 3/5] sframe: add new SFrame library Message-ID: <20230502084640.GF1597476@hirez.programming.kicks-ass.net> References: <20230501200410.3973453-1-indu.bhagat@oracle.com> <20230501200410.3973453-4-indu.bhagat@oracle.com> <20230501184008.319fdd6f@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230501184008.319fdd6f@gandalf.local.home> Precedence: bulk List-ID: X-Mailing-List: linux-toolchains@vger.kernel.org On Mon, May 01, 2023 at 06:40:08PM -0400, Steven Rostedt wrote: > > --- /dev/null > > +++ b/lib/sframe/sframe.h > > @@ -0,0 +1,263 @@ > > +/* SPDX-License-Identifier: GPL-2.0-or-later */ > > +/* > > + * Copyright (C) 2023, Oracle and/or its affiliates. > > + */ > > + > > +#ifndef SFRAME_H > > +#define SFRAME_H > > + > > +#include > > + > > +/* This file contains definitions for the SFrame stack tracing format, which is > > + * documented at https://sourceware.org/binutils/docs */ More CodingStyle nits, this also isn't a valid multi line comment style for the kernel. > > + > > +#define SFRAME_VERSION_1 1 > > +#define SFRAME_MAGIC 0xdee2 > > +#define SFRAME_VERSION SFRAME_VERSION_1 > > + > > +/* Function Descriptor Entries are sorted on PC. */ > > +#define SFRAME_F_FDE_SORTED 0x1 > > +/* Frame-pointer based stack tracing. Defined, but not set. */ > > +#define SFRAME_F_FRAME_POINTER 0x2 > > + > > +#define SFRAME_CFA_FIXED_FP_INVALID 0 > > +#define SFRAME_CFA_FIXED_RA_INVALID 0 > > + > > +/* Supported ABIs/Arch. */ > > +#define SFRAME_ABI_AARCH64_ENDIAN_BIG 1 /* AARCH64 big endian. */ > > +#define SFRAME_ABI_AARCH64_ENDIAN_LITTLE 2 /* AARCH64 little endian. */ > > +#define SFRAME_ABI_AMD64_ENDIAN_LITTLE 3 /* AMD64 little endian. */ > > + > > +/* SFrame FRE types. */ > > +#define SFRAME_FRE_TYPE_ADDR1 0 > > +#define SFRAME_FRE_TYPE_ADDR2 1 > > +#define SFRAME_FRE_TYPE_ADDR4 2 > > + > > +/* > > + * SFrame Function Descriptor Entry types. > > + * > > + * The SFrame format has two possible representations for functions. The > > + * choice of which type to use is made according to the instruction patterns > > + * in the relevant program stub. > > + */ This is. > > +/* Unwinders perform a (PC >= FRE_START_ADDR) to look up a matching FRE. */ > > +#define SFRAME_FDE_TYPE_PCINC 0 > > +/* > > + * Unwinders perform a (PC & FRE_START_ADDR_AS_MASK >= FRE_START_ADDR_AS_MASK) > > + * to look up a matching FRE. Typical usecases are pltN entries, trampolines > > + * etc. > > + */ > > +#define SFRAME_FDE_TYPE_PCMASK 1 > > + > > +static bool sframe_header_sanity_check_p(struct sframe_header *hp) > > +{ > > + unsigned char all_flags = SFRAME_F_FDE_SORTED | SFRAME_F_FRAME_POINTER; > > Add a space here. > > > + /* Check that the preamble is valid. */ > > + if ((hp->preamble.magic != SFRAME_MAGIC) > > + || (hp->preamble.version != SFRAME_VERSION) > > + || ((hp->preamble.flags | all_flags) != all_flags)) > > + return false; In kernel we prefer the operators at the end of a line in case of linebreak. > > + > > + /* Check that the offsets are valid. */ > > + if (hp->fdeoff > hp->freoff) > > + return false; > > + > > + return true; > > +} > > + > > +static bool sframe_fre_sanity_check_p(struct sframe_fre *frep) > > +{ > > + unsigned int offset_size, offset_cnt; > > + > > + if (frep == NULL) > > + return false; > > + > > + offset_size = sframe_fre_get_offset_size(frep->fre_info); > > + > > + if (offset_size != SFRAME_FRE_OFFSET_1B > > + && offset_size != SFRAME_FRE_OFFSET_2B > > + && offset_size != SFRAME_FRE_OFFSET_4B) > > + return false; idem. > > + > > + offset_cnt = sframe_fre_get_offset_count(frep->fre_info); > > + if (offset_cnt > MAX_NUM_STACK_OFFSETS) > > + return false; > > + > > + return true; > > +}