Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1488738rdg; Sat, 14 Oct 2023 04:39:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEdY1R5yvgKXHwjkfG5GWJqN2QxmoqtGKf5N1xo4m00tjMsxRkmqKl82ntB6DDTgAWhnlgT X-Received: by 2002:a17:903:1c4:b0:1b9:de75:d5bb with SMTP id e4-20020a17090301c400b001b9de75d5bbmr40805894plh.7.1697283546843; Sat, 14 Oct 2023 04:39:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697283546; cv=none; d=google.com; s=arc-20160816; b=BvnlOPsD0v7h3Pvt7/bdr4ysRTnWXPqb8lYXO7H5ERFeFcb4tWv7c9TKp0NuoqwAcc 0lpz0FT17ikaKD266F/72gsKOemmP42stHQxKk51/u6j1v3p3aNhIegSSyBsJu78/aYv CtufsLt6JMaUb7ha0oUcoLzH/za0+3b+tjh1HsYsbaAcrox9/odAbFb62ZtTjxfSmQMQ ESdb7uh+m7KxM63pRex0Y5V6MF9fxR9t3TorL6prd3qXqYwmsGw9vUuAjixTh3msrLhJ /2jrSs68urheVgktU19B97RGM2cMfiGBDkT3C+xDGCUiSTpvnyy4h65+s+SGmC/iXquR JUnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=rJ1g7zfi+XFRbX3BfDWN/5GCqmj865cz69F44Ap+jw4=; fh=RxjCNf1iL0ROleLVXKL6sGV66GbXQKzrkuw8OauOGHs=; b=H1h0nZ0Nk1HpCzqklRDXplsfrKJVJ29lICo3UEb0rgdyBLyPhNVF3hGJJmP7WuoPFH g8zp6GEyekWU9THjV3sSGvTCIVyPh/13wF4nY38RbjbZeB1g6qW72iljq2CR5asQKGHn NMiey6uAAwMZVmvP9HDS7+8g//F+JO+Ba23i3TrcGbCFdPa1QVjrT8uHkkGE/J1jKSB1 vfF9bYHeftydsophrevQL4525fveazXJJNhk9M3yPwBZUyi0/Phoh8cIoNJ2+b00Sfid KPV012rDr0XGBrX/6Wr0vMerUYstTZAPNFteD+H21zk6QVMkD90QlMxP70X8nrj6S4ZC KYmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dA29uXc2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id jn20-20020a170903051400b001c62b659f98si6185275plb.79.2023.10.14.04.39.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Oct 2023 04:39:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dA29uXc2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id CA57E80398F3; Sat, 14 Oct 2023 04:39:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233153AbjJNLhX (ORCPT + 99 others); Sat, 14 Oct 2023 07:37:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233143AbjJNLhW (ORCPT ); Sat, 14 Oct 2023 07:37:22 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8363D6 for ; Sat, 14 Oct 2023 04:37:19 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B295C433C8 for ; Sat, 14 Oct 2023 11:37:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697283439; bh=CzqO/xhRHZDmhKrPv654VKtLA/I6VeNB3r9WQ2mlVe4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=dA29uXc2WOIJy5BPBXvucMo95PzBPdwWc7bmVJF6b+mSN3M88lmgXLNld3NKNlhAp QEs2F+BkgbZWEM2wdonqq71QpnK+Ub+ABZqhZSK7Pbeemyf96WWj9dK+1RaoRAWgaB EXlOH3lW8lypjLrMWm9B9N3AebP0NXq5R3kzuayu/RMw3utTFst/JftjqBFbPvq4ut 6dRWDFy7NBYbaNllxlvADPN3yFqSQNvmRLSuYYblnnL7KfyBRBFQJMlSEJoFJzY6Hs gCAmXrX2LVsTzXpBtwf+vL55mfobvHMqrfWT9nyeUQ+CUc0jvlIGWzOJwx48Ktqdb+ e3zNCG1Z7I12Q== Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-9a6190af24aso483395666b.0 for ; Sat, 14 Oct 2023 04:37:19 -0700 (PDT) X-Gm-Message-State: AOJu0Yyl+CxONQ0bBTKoyISYbR0iod0zFmgb7mseMJV3RgUwtsMq1QRh jLfP7YKgDl/wNRnlxaIUTZbMIgsbwAbKGPy9AJA= X-Received: by 2002:a17:907:1b15:b0:9bd:dfaa:3f2 with SMTP id mp21-20020a1709071b1500b009bddfaa03f2mr3494430ejc.6.1697283437976; Sat, 14 Oct 2023 04:37:17 -0700 (PDT) MIME-Version: 1.0 References: <1696856590-30298-1-git-send-email-yangtiezhu@loongson.cn> <1696856590-30298-9-git-send-email-yangtiezhu@loongson.cn> In-Reply-To: From: Huacai Chen Date: Sat, 14 Oct 2023 19:37:08 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 8/8] LoongArch: Add ORC unwinder support To: Tiezhu Yang Cc: Josh Poimboeuf , Peter Zijlstra , loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Sat, 14 Oct 2023 04:39:04 -0700 (PDT) +CC Jinyang On Sat, Oct 14, 2023 at 5:21=E2=80=AFPM Tiezhu Yang wrote: > > > > On 10/11/2023 12:37 PM, Huacai Chen wrote: > > Hi, Tiezhu, > > > > Maybe "LoongArch: Add ORC stack unwinder support" is better. > > OK, will modify it. > > > > > On Mon, Oct 9, 2023 at 9:03=E2=80=AFPM Tiezhu Yang wrote: > >> > >> The kernel CONFIG_UNWINDER_ORC option enables the ORC unwinder, which = is > >> similar in concept to a DWARF unwinder. The difference is that the for= mat > >> of the ORC data is much simpler than DWARF, which in turn allows the O= RC > >> unwinder to be much simpler and faster. > > ... > > >> +ifdef CONFIG_OBJTOOL > >> +# https://sourceware.org/git/?p=3Dbinutils-gdb.git;a=3Dcommit;h=3Decb= 802d02eeb > >> +# https://sourceware.org/git/?p=3Dbinutils-gdb.git;a=3Dcommit;h=3D816= 029e06768 > >> +ifeq ($(shell as --help 2>&1 | grep -e '-mthin-add-sub'),) > >> + $(error Sorry, you need a newer gas version with -mthin-add-sub opt= ion) > > I prefer no error out here, because without this option we can still > > built a runnable kernel. > > I agree with you that it is better to not error out to stop compilation, > but there are many objtool warnings during the compile process with old > binutils, so it is necessary to give a warning so that the users know > what happened and how to fix the lots of objtool warnings. > > That is to say, I would prefer to replace "error" with "warning". > > >> +endif > >> +KBUILD_AFLAGS +=3D $(call cc-option,-mthin-add-sub) $(call cc-option= ,-Wa$(comma)-mthin-add-sub) > >> +KBUILD_CFLAGS +=3D $(call cc-option,-mthin-add-sub) $(call cc-option= ,-Wa$(comma)-mthin-add-sub) > >> +KBUILD_CFLAGS +=3D -fno-optimize-sibling-calls -fno-jump-tables -fal= ign-functions=3D4 > >> +endif > > ... > > >> +#define ORC_REG_BP 3 > > Use FP instead of BP in this patch, too. > > OK, will do it. > > > > >> +#define ORC_REG_MAX 4 > > ... > > >> +.macro UNWIND_HINT_UNDEFINED > > > >> + UNWIND_HINT type=3DUNWIND_HINT_TYPE_UNDEFINED > >> +.endm > > We don't need to set sp_reg=3DORC_REG_UNDEFINED for UNWIND_HINT_UNDEFIN= ED? > > Yes, no need to set sp_reg, the instructions marked with UNDEFINED > are blind spots in ORC coverage, it is no related with stack trace, > this is similar with x86. > > > > >> + > >> +.macro UNWIND_HINT_EMPTY > >> + UNWIND_HINT sp_reg=3DORC_REG_UNDEFINED type=3DUNWIND_HINT_TYPE= _CALL > >> +.endm > > We don't need to define UNWIND_HINT_END_OF_STACK? > > Yes, it is useless now. > > > > >> + > >> +.macro UNWIND_HINT_REGS > >> + UNWIND_HINT sp_reg=3DORC_REG_SP type=3DUNWIND_HINT_TYPE_REGS > >> +.endm > >> + > >> +.macro UNWIND_HINT_FUNC > >> + UNWIND_HINT sp_reg=3DORC_REG_SP type=3DUNWIND_HINT_TYPE_CALL > >> +.endm > > We don't need to set sp_offset for UNWIND_HINT_REGS and UNWIND_HINT_FUN= C? > > sp_offset is 0 by default, no need to set it unless you need to change > its value, see include/linux/objtool.h > .macro UNWIND_HINT type:req sp_reg=3D0 sp_offset=3D0 signal=3D0 > > > > >> + > >> +#endif /* __ASSEMBLY__ */ > > ... > > >> diff --git a/arch/loongarch/kernel/entry.S b/arch/loongarch/kernel/ent= ry.S > >> index 65518bb..e43115f 100644 > >> --- a/arch/loongarch/kernel/entry.S > >> +++ b/arch/loongarch/kernel/entry.S > >> @@ -14,11 +14,13 @@ > >> #include > >> #include > >> #include > >> +#include > >> > >> .text > >> .cfi_sections .debug_frame > >> .align 5 > >> -SYM_FUNC_START(handle_syscall) > >> +SYM_CODE_START(handle_syscall) > > Why? > > > > see include/linux/linkage.h > FUNC -- C-like functions (proper stack frame etc.) > CODE -- non-C code (e.g. irq handlers with different, special stack etc.) Hi, Jinyang, What do you think about it? In our internal repo, most asm functions changed in this patch are still marked with FUNC, not CODE. > > >> + UNWIND_HINT_UNDEFINED > >> csrrd t0, PERCPU_BASE_KS > > ... > > >> diff --git a/arch/loongarch/kernel/head.S b/arch/loongarch/kernel/head= .S > >> index 53b883d..5664390 100644 > >> --- a/arch/loongarch/kernel/head.S > >> +++ b/arch/loongarch/kernel/head.S > >> @@ -43,6 +43,7 @@ SYM_DATA(kernel_offset, .long _kernel_offset); > >> .align 12 > >> > >> SYM_CODE_START(kernel_entry) # kernel entry point > >> + UNWIND_HINT_EMPTY > > I'm not sure but I think this isn't needed, because > > "OBJECT_FILES_NON_STANDARD_head.o :=3Dy" > > Yes, you are right, will remove it. > > > > >> > >> /* Config direct window and set PG */ > > ... > > >> void __init setup_arch(char **cmdline_p) > >> { > >> + unwind_init(); > > I think this line should be after cpu_probe(). > > I am OK to do this change, but if so, there are no stack trace before > cpu_probe() for the early code. As I said before, stack trace needs printk, but printk cannot work before cpu_probe(). > > > > >> cpu_probe(); > >> > >> init_environ(); > > ... > > >> diff --git a/arch/loongarch/power/Makefile b/arch/loongarch/power/Make= file > >> index 58151d0..bbd1d47 100644 > >> --- a/arch/loongarch/power/Makefile > >> +++ b/arch/loongarch/power/Makefile > >> @@ -1,3 +1,5 @@ > >> +OBJECT_FILES_NON_STANDARD_suspend_asm.o :=3D y > > hibernate_asm.o has no problem? > > Yes, only suspend_asm.o has one warning, just ignore it. What kind of warning? When I submitted the suspend patch, Jinyang told me that with his changes loongarch_suspend_enter() can be a regular function. Huacai > > Thanks, > Tiezhu > >