From nobody Fri Dec 19 17:43:32 2025 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 48F391D89FA for ; Mon, 27 Jan 2025 21:33:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738013605; cv=none; b=F89I/Y6wsnvxu2zmKpA6WO59GRvZit/Bo4bCqRlR/5KbwvxS8OQf8ZmXPZJjiiZAUh/TcMBP1vjaOYzMsuLxRcOH9JT1zfQ+Qpkmp5ewAj7bTMeaHcUsDmg0Mozedc+KPoP7zeQRQeuzgPDPUnEtrtRZm9uMiFpHu2I0etMNVys= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738013605; c=relaxed/simple; bh=YMGY+TCeN92CwabsHBMERr0zATeblJzChZgSnquU71c=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=cAZvWGTOipBSzT7WNGXOo1SVHdb2mSZqOo4OIeM555tdzIN/TwRCsxA+s1S4/vAvfSC1F42p37zPZ76nmLOf8GEz/6RQxStn3hmZFvntVcSppFLg5VO3oXxOD647wR+fC3O8RzIPardLPMBV0nr8dLD4YTfM/pPiekEAmK5ZBAs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--wnliu.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=LsUVDCqj; arc=none smtp.client-ip=209.85.214.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--wnliu.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="LsUVDCqj" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2163dc0f689so144567585ad.1 for ; Mon, 27 Jan 2025 13:33:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1738013603; x=1738618403; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=pMhIr+En9Z5bHr+SI41rtrYzgjvtxfxDwtbSrjCCifE=; b=LsUVDCqjVA4yITRHQUBA+6G/hZwJo54QmwvOtNpExkCk52PK3Tdls+KQ/xGgnldWWa 6RwBIaxEFbS48ZAeKoo0vrdjdPlkQzi5ODJiLfFXc+YX5aYeoNjBldCeMXvl31P0eX84 42KHf5D82hJwfeitLYRjgYVkHUP44qUdIWgsVNjUysi0sJnZt13nuhSD68KnNvr2i77f WEWuC+h+sorx79bzx9yQHO5W5IFNRK1q1eaeQlbRytansIKued7sfevbwTD+L2Yj9hqa 919MJGazrlUuufA89Bw7BarJtq4wgARTedgrS2yi1FKeX2uSYTBrq9EF7UN8WCVFUkP9 kbhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738013603; x=1738618403; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pMhIr+En9Z5bHr+SI41rtrYzgjvtxfxDwtbSrjCCifE=; b=vLYcFD5jIZ96IKI/jzCu1c3cZGOYIadvwjZnPOth7QlUXRItatTkCpJZgIw0JPVWWS A3FekEKxUH1xjNZ6HM/USMIWGCOIhb6dtO7mvxHd0s4wNezz4IWnLSKwx0gUhD7PR29/ P+l7GQmqpW0K+FlOPCphYdiRYDW1Pwm2WVTW06KhvkbgjohxJeteohJyJly4F3AfDd16 M1WbJr/5F+7/lVuz2oRdVf6v5yu13UmWILpHNXT6rrSnpeaQnRKbwt4vLUeQZ1Qlh0UY ipl0Ib8uPXsWUv1g/yzmuHHLeHYRxMd4Dzj0xJXJLq96b5ThpqZH4J6d82WPNO93uRPx eUtw== X-Forwarded-Encrypted: i=1; AJvYcCXWuRJGrllYBkmGyRTvB3iWrUQk9y8N1x/cRc97BUEROrM5MqBc3nwqwJ6PNsdX8tsTr7V53sW7UzWLruQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxnV2a0eqrz5S04CG+V9Zt5ZyeYYWKdUjzHyichBArOFpnJeX1t 4jatXEakH4k3IogPPUN+84g6bJ+G7B5eq+tiM1k2A96QHVAN91ga8xZ1EHlpJANh/enzj9DRoQ= = X-Google-Smtp-Source: AGHT+IFf6J6rV9/t9kV/JQeXUvSzBEZruRhcKXoKcnyF96aSdB43mkOwhOGscpzW9zOTOb0X7BG/2BEB9g== X-Received: from pfbjc33.prod.google.com ([2002:a05:6a00:6ca1:b0:728:b3dd:ba8c]) (user=wnliu job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:430d:b0:1e1:aef4:9ce7 with SMTP id adf61e73a8af0-1eb214a08b6mr60696359637.17.1738013603568; Mon, 27 Jan 2025 13:33:23 -0800 (PST) Date: Mon, 27 Jan 2025 21:33:03 +0000 In-Reply-To: <20250127213310.2496133-1-wnliu@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250127213310.2496133-1-wnliu@google.com> X-Mailer: git-send-email 2.48.1.262.g85cc9f2d1e-goog Message-ID: <20250127213310.2496133-2-wnliu@google.com> Subject: [PATCH 1/8] unwind: build kernel with sframe info From: Weinan Liu To: Josh Poimboeuf , Steven Rostedt , Indu Bhagat , Peter Zijlstra Cc: Mark Rutland , roman.gushchin@linux.dev, Will Deacon , Ian Rogers , linux-toolchains@vger.kernel.org, linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, joe.lawrence@redhat.com, linux-arm-kernel@lists.infradead.org, Weinan Liu Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the -Wa,--gsframe flags to build the code, so GAS will generate a new .sframe section for the stack trace information. Currently, the sframe format only supports arm64 and x86_64 architectures. Add this configuration on arm64 to enable sframe unwinder in the future. Signed-off-by: Weinan Liu Reviewed-by: Prasanna Kumar T S M . --- Makefile | 6 ++++++ arch/Kconfig | 8 ++++++++ arch/arm64/Kconfig.debug | 10 ++++++++++ include/asm-generic/vmlinux.lds.h | 12 ++++++++++++ 4 files changed, 36 insertions(+) diff --git a/Makefile b/Makefile index b9464c88ac72..35200c39b98d 100644 --- a/Makefile +++ b/Makefile @@ -1064,6 +1064,12 @@ ifdef CONFIG_CC_IS_GCC KBUILD_CFLAGS +=3D -fconserve-stack endif =20 +# build with sframe table +ifdef CONFIG_SFRAME_UNWIND_TABLE +KBUILD_CFLAGS +=3D -Wa,--gsframe +KBUILD_AFLAGS +=3D -Wa,--gsframe +endif + # change __FILE__ to the relative path to the source directory ifdef building_out_of_srctree KBUILD_CPPFLAGS +=3D $(call cc-option,-fmacro-prefix-map=3D$(srcroot)/=3D) diff --git a/arch/Kconfig b/arch/Kconfig index 6682b2a53e34..ae70f7dbe326 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -1736,4 +1736,12 @@ config ARCH_WANTS_PRE_LINK_VMLINUX An architecture can select this if it provides arch//tools/Makefi= le with .arch.vmlinux.o target to be linked into vmlinux. =20 +config AS_HAS_SFRAME_SUPPORT + # Detect availability of the AS option -Wa,--gsframe for generating + # sframe unwind table. + def_bool $(cc-option,-Wa$(comma)--gsframe) + +config SFRAME_UNWIND_TABLE + bool + endmenu diff --git a/arch/arm64/Kconfig.debug b/arch/arm64/Kconfig.debug index 265c4461031f..ed619fcb18b3 100644 --- a/arch/arm64/Kconfig.debug +++ b/arch/arm64/Kconfig.debug @@ -20,4 +20,14 @@ config ARM64_RELOC_TEST depends on m tristate "Relocation testing module" =20 +config SFRAME_UNWINDER + bool "Sframe unwinder" + depends on AS_HAS_SFRAME_SUPPORT + depends on 64BIT + select SFRAME_UNWIND_TABLE + help + This option enables the sframe (Simple Frame) unwinder for unwinding + kernel stack traces. It uses unwind table that is direclty generated + by toolchain based on DWARF CFI information + source "drivers/hwtracing/coresight/Kconfig" diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinu= x.lds.h index 54504013c749..6a437bd084c7 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -469,6 +469,8 @@ defined(CONFIG_AUTOFDO_CLANG) || defined(CONFIG_PROPELL= ER_CLANG) *(.rodata1) \ } \ \ + SFRAME \ + \ /* PCI quirks */ \ .pci_fixup : AT(ADDR(.pci_fixup) - LOAD_OFFSET) { \ BOUNDED_SECTION_PRE_LABEL(.pci_fixup_early, _pci_fixups_early, __start= , __end) \ @@ -886,6 +888,16 @@ defined(CONFIG_AUTOFDO_CLANG) || defined(CONFIG_PROPEL= LER_CLANG) #define TRACEDATA #endif =20 +#ifdef CONFIG_SFRAME_UNWIND_TABLE +#define SFRAME \ + /* sframe */ \ + .sframe : AT(ADDR(.sframe) - LOAD_OFFSET) { \ + BOUNDED_SECTION_BY(.sframe, _sframe_header) \ + } +#else +#define SFRAME +#endif + #ifdef CONFIG_PRINTK_INDEX #define PRINTK_INDEX \ .printk_index : AT(ADDR(.printk_index) - LOAD_OFFSET) { \ --=20 2.48.1.262.g85cc9f2d1e-goog