From nobody Fri Dec 19 16:08:36 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 From nobody Fri Dec 19 16:08:36 2025 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 8B21F1DA2E5 for ; Mon, 27 Jan 2025 21:33:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738013610; cv=none; b=UAZ6um8rC+SMahVX0uELcf1NG975xP06tAV10xPEtF9JpvR67KarFiM5d8NrSzJsrvf7mNqSNEiRpCQpZQTwy4S3TfYsdNZLE9doo8lW/zcRBFN4Fc3znlBrGc1QUQUrh4GTbEbCjkPgpcSkKVJ0S7gXE+03XEVFNlxeuvPuco8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738013610; c=relaxed/simple; bh=DX6VfTUkhmdwfT2T+n2rZJh1HOTw0vszP61D/bfXh1s=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=V5osRkh/ABzBtKblvm/42SPdHGUXwrDo1+FsSkukNmDveCHY3FFS6hkLXKJbhTf5iaP2WzvxENUZybZvQOYqi9u983bgo27uqQHFZb2zmq7Zx5Vx8l9SQd9V9Oia1Ln3RIhogTW1NRtlHUpX/623myL9oTWj4dIqeinJ1IYmi5U= 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=pS88lsUR; arc=none smtp.client-ip=209.85.216.74 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="pS88lsUR" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2ef9204f898so9422899a91.2 for ; Mon, 27 Jan 2025 13:33:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1738013608; x=1738618408; 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=jWq1XbSkyOkuYcVulfJjVxpq/eHKTQbF0thAv0NyIGs=; b=pS88lsURchmPTsYeFFtLfp/TSvv2isJAirB0RxDD+uMJeM8QfQ9TFiZQYS4nDyWXI9 zqE4qRShEoMi9ftj9oB5ds+ruJu3MLE+VIJcH3lPpLVHAQd2AW0bB0+qOVFKbgSFTups wfF/JXbBzt6iB0B0msq89fOZMjX6BBNJhoGKWq93WJpov/s2doVtQQAs9frjU+c5icGn qu1mBIeWFLmeYnKbOkfkI4QaSmQyC7X+ed3T9r7HGRbgEVWAs916lTgIlkQ9bJRaNblN jJXiexMK8viYNIDFmQIyLotf33WP3wCHkIFTLd+rb1kRiBehu1boBGtUBMoGtR2XSow0 TzBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738013608; x=1738618408; 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=jWq1XbSkyOkuYcVulfJjVxpq/eHKTQbF0thAv0NyIGs=; b=fQw0u9QnjJtz1V9bB83V7zsk7UiuFZJcWRpq3OLO30HZoUZZ3yBITs4Zqcutfy85Yq ELeWWOr0g4O2lioic7uS1wcs0KFARwrPLPvzyRNFiwON4q6OSW3oP6Kd+Nby7386ahsZ 2GCjbH6pQ1r1/dqAUtPfYR5pkLru42w4y0XbAnbX2acUA0VNgv1ll3GaRgYIuo4zmqhS AQH1BJEiBZG6UpQZorlg/0kYWNVTFmcPWNVmlg2AtI9RCezvtwIj8bNph2Tq5FZufNjQ DvGmbkcM6O9O0LQ5m4z4KXXcgzJoPeTvNuJoxvFOVm3DuvoGh0iMo3YLMUbQuStQtrOy krCQ== X-Forwarded-Encrypted: i=1; AJvYcCWlGV3EpiiXwSxt52sT2g265xH9CXUuj6xM7Glt60RWL5q9zKuDQ3cl3tX/3csi3iQ4PrxueXNExDRipfI=@vger.kernel.org X-Gm-Message-State: AOJu0YxNs20wY1ctx7t5VZQ7eU9q2qDY7Hsz3LpewEwkm6OP2xb4Hw6j oSal2ghpo4h9k5Mk9OINxeAHb6byauXphtV0iZLzGTH94Gw6Ccw8fsbDH2tS3MAe1wIx4tXncQ= = X-Google-Smtp-Source: AGHT+IGsA2oXsBLBU6n+vsGTmoyiK5KDPDDibU+y8Mvqe4ndlxlznHpYDael7KmNjQ8dikt+jPZ/Btay/Q== X-Received: from pjbse3.prod.google.com ([2002:a17:90b:5183:b0:2ea:4139:e72d]) (user=wnliu job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:6c6:b0:2ee:889b:b11e with SMTP id 98e67ed59e1d1-2f782d972eamr59541677a91.30.1738013607746; Mon, 27 Jan 2025 13:33:27 -0800 (PST) Date: Mon, 27 Jan 2025 21:33:04 +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-3-wnliu@google.com> Subject: [PATCH 2/8] arm64: entry: add unwind info for various kernel entries 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" DWARF CFI (Call Frame Information) specifies how to recover the return address and callee-saved registers at each PC in a given function. Compilers are able to generate the CFI annotations when they compile the code to assembly language. For handcrafted assembly, we need to annotate them by hand. Annotate CFI unwind info for assembly for interrupt and exception handlers. Signed-off-by: Weinan Liu --- arch/arm64/kernel/entry.S | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 5ae2a34b50bd..fe3e3e29ee5d 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -579,7 +579,12 @@ SYM_CODE_START_LOCAL(el\el\ht\()_\regsize\()_\label) .if \el =3D=3D 0 b ret_to_user .else + .cfi_startproc + .cfi_def_cfa_offset PT_REGS_SIZE + .cfi_offset 29, S_FP - PT_REGS_SIZE + .cfi_offset 30, S_LR - PT_REGS_SIZE b ret_to_kernel + .cfi_endproc .endif SYM_CODE_END(el\el\ht\()_\regsize\()_\label) .endm @@ -889,6 +894,10 @@ SYM_FUNC_START(call_on_irq_stack) /* Move to the new stack and call the function there */ add sp, x16, #IRQ_STACK_SIZE blr x1 + .cfi_startproc + .cfi_def_cfa 29, 16 + .cfi_offset 29, -16 + .cfi_offset 30, -8 =20 /* * Restore the SP from the FP, and restore the FP and LR from the frame @@ -898,6 +907,7 @@ SYM_FUNC_START(call_on_irq_stack) ldp x29, x30, [sp], #16 scs_load_current ret + .cfi_endproc SYM_FUNC_END(call_on_irq_stack) NOKPROBE(call_on_irq_stack) =20 --=20 2.48.1.262.g85cc9f2d1e-goog From nobody Fri Dec 19 16:08:36 2025 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (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 1F69B1DA628 for ; Mon, 27 Jan 2025 21:33:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738013612; cv=none; b=LxQQEar7mjzBvGuAJdpwLsSr6YTUN7bwPGqYVqxfAevFE09ET9GDQXusyLPNrPtJ3cCmizoUSXulAD7nVLK6ArNbB9ccU9Oq58uwrgA8n44KOedE3Nfr/yO+ZP2EBZtv7UR4wLGi/W6VK9CAAZX6ylqiIHaAHMKZWMa5o9XJBew= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738013612; c=relaxed/simple; bh=VZs7OdIz9ylWCusavl8KUiNFzj24khVzjcrXOvfKj7c=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=sSgHXdDGzp6v6lN4ATBi8ZbGbtwv8Pwwl3kauxCaOGuhxuKTQcz35wfPoFCkHVIYvmWwBCBF8pr9XAht7vxYAIGhZdX8oDJYx7lPcmqSl/BcjGEJQNqVMVQelCX4Xq77B9HW831htF8b7JyHLJO2EYi3XE4s62eGU6ZRoD5GsvU= 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=4Wb2CZs3; arc=none smtp.client-ip=209.85.216.73 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="4Wb2CZs3" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-2eebfd6d065so13830875a91.3 for ; Mon, 27 Jan 2025 13:33:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1738013610; x=1738618410; 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=nDvBLRnKYJqb7wLRycvSsM5KYAbB3Uj/Gas8Bcx9QpY=; b=4Wb2CZs3eTxCA/+G1p3hHwEEtp7WVr4gOS17eM/eDZ+ycKI4mY6YwSmdJwtT8Kvg8F CR+ztuHpSnoqLjaezHQ7otpOagHo4t60x9L3KThyVlHK/JJ1RuA61Amt/nkj6iZ+lwwI AQFd6Bg219yV8CrLobdSylTLNmcDptF4MHJeX71qCQd99UShixQQsRQUt7qDszwjTDXe J1GQUAetFMFBKIgnXQ0VgoKaHPfHTbhoyfw2Ji0IKc2Pezh/qrhQxGqvohdNYwgm3KD0 2U8Q24BzM/LmwBGHxRXPXI7Ge0yuPaDQPZ2vMHapBwSucw1U6k/nUHUG4xUvKaU2gdf6 oHiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738013610; x=1738618410; 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=nDvBLRnKYJqb7wLRycvSsM5KYAbB3Uj/Gas8Bcx9QpY=; b=Mg+SfLsiwrOqk1T2v7oefMq/S69imuODG5NOFzqmLCTgXoyJiFs9S0fUPpzXu44RyO zG5jPnpSyW93a791hy9Qi8WVcdkFGGUukGnG9ervoO8cUIGLIzhLObUR3I8CkSQWVML/ blMN0he1IbGHx/M1Aa1pvYybg46NdLNW//dpq+Bub4gzJJE5rXIa8JaAXCDsvvca4nIM ADpjDg4RgXNjhk+9PB59UL6j3o7YRhNiLkJXrG0dB/+Q3hB3SxwA0FOtyUvPiHBdE/4R bb2WoZ9fFlDeHKtJQGer/qzBkAZThsXm3Rcdcmg3yh0gewYQ/YUAikyVVOmcY/8WlSkO uoqA== X-Forwarded-Encrypted: i=1; AJvYcCVBe+q7ar6he6O+kKdb1S1ayGvgCZLeiU+AYc01ZSIIUC7Ngd82UpC55WSkvRLjBGkUizNXGyfSbEchysg=@vger.kernel.org X-Gm-Message-State: AOJu0Yz53rdqnRe9oANUfwMs6N2apueCnFd7Zo2y3kYbZ8M4f2ewl60K OdgCSbnaUHonGHQceGk6KVlTCsNEXCur8asFuF4p0Yhpincji+kD1i9/pGc9Xq06pOa19RqZ/g= = X-Google-Smtp-Source: AGHT+IE7cBiyjRItliwSAg3VmD1SKevW9jTi2EfBECUlXP+PwVTan7NlAVSGrkNopkq3143PUhyvXE76zA== X-Received: from pfd10.prod.google.com ([2002:a05:6a00:a80a:b0:725:d350:a304]) (user=wnliu job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:ad8a:b0:72a:bc54:84f7 with SMTP id d2e1a72fcca58-72dafa03117mr57971799b3a.12.1738013610397; Mon, 27 Jan 2025 13:33:30 -0800 (PST) Date: Mon, 27 Jan 2025 21:33:05 +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-4-wnliu@google.com> Subject: [PATCH 3/8] unwind: add sframe v2 header 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" Add sframe header so that we know how to access the sframe section generated by compilers. This is the sframe header file borrowed from the patchset [1] Josh Poimboeuf according to sframe v2 spec [2]. [1]: https://lore.kernel.org/lkml/42c0a99236af65c09c8182e260af7bcf5aa1e158.= 1730150953.git.jpoimboe@kernel.org/ [2]: https://sourceware.org/binutils/docs/sframe-spec.html Signed-off-by: Weinan Liu Reviewed-by: Prasanna Kumar T S M . --- kernel/sframe.h | 215 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 215 insertions(+) create mode 100644 kernel/sframe.h diff --git a/kernel/sframe.h b/kernel/sframe.h new file mode 100644 index 000000000000..11b9be7ad82e --- /dev/null +++ b/kernel/sframe.h @@ -0,0 +1,215 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2023, Oracle and/or its affiliates. + * + * This file contains definitions for the SFrame stack tracing format, whi= ch is + * documented at https://sourceware.org/binutils/docs + */ +#ifndef _SFRAME_H +#define _SFRAME_H + +#include + +#define SFRAME_VERSION_1 1 +#define SFRAME_VERSION_2 2 +#define SFRAME_MAGIC 0xdee2 + +/* 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 patter= ns + * in the relevant program stub. + */ + +/* Unwinders perform a (PC >=3D FRE_START_ADDR) to look up a matching FRE.= */ +#define SFRAME_FDE_TYPE_PCINC 0 +/* + * Unwinders perform a (PC & FRE_START_ADDR_AS_MASK >=3D FRE_START_ADDR_AS= _MASK) + * to look up a matching FRE. Typical usecases are pltN entries, trampolin= es + * etc. + */ +#define SFRAME_FDE_TYPE_PCMASK 1 + +/** + * struct sframe_preamble - SFrame Preamble. + * @magic: Magic number (SFRAME_MAGIC). + * @version: Format version number (SFRAME_VERSION). + * @flags: Various flags. + */ +struct sframe_preamble { + u16 magic; + u8 version; + u8 flags; +} __packed; + +/** + * struct sframe_header - SFrame Header. + * @preamble: SFrame preamble. + * @abi_arch: Identify the arch (including endianness) and ABI. + * @cfa_fixed_fp_offset: Offset for the Frame Pointer (FP) from CFA may be + * fixed for some ABIs ((e.g, in AMD64 when -fno-omit-frame-pointer is + * used). When fixed, this field specifies the fixed stack frame offset + * and the individual FREs do not need to track it. When not fixed, it + * is set to SFRAME_CFA_FIXED_FP_INVALID, and the individual FREs may + * provide the applicable stack frame offset, if any. + * @cfa_fixed_ra_offset: Offset for the Return Address from CFA is fixed f= or + * some ABIs. When fixed, this field specifies the fixed stack frame + * offset and the individual FREs do not need to track it. When not + * fixed, it is set to SFRAME_CFA_FIXED_FP_INVALID. + * @auxhdr_len: Number of bytes making up the auxiliary header, if any. + * Some ABI/arch, in the future, may use this space for extending the + * information in SFrame header. Auxiliary header is contained in bytes + * sequentially following the sframe_header. + * @num_fdes: Number of SFrame FDEs in this SFrame section. + * @num_fres: Number of SFrame Frame Row Entries. + * @fre_len: Number of bytes in the SFrame Frame Row Entry section. + * @fdes_off: Offset of SFrame Function Descriptor Entry section. + * @fres_off: Offset of SFrame Frame Row Entry section. + */ +struct sframe_header { + struct sframe_preamble preamble; + u8 abi_arch; + s8 cfa_fixed_fp_offset; + s8 cfa_fixed_ra_offset; + u8 auxhdr_len; + u32 num_fdes; + u32 num_fres; + u32 fre_len; + u32 fdes_off; + u32 fres_off; +} __packed; + +#define SFRAME_HDR_SIZE(sframe_hdr) \ + ((sizeof(struct sframe_header) + (sframe_hdr).auxhdr_len)) + +/* Two possible keys for executable (instruction) pointers signing. */ +#define SFRAME_AARCH64_PAUTH_KEY_A 0 /* Key A. */ +#define SFRAME_AARCH64_PAUTH_KEY_B 1 /* Key B. */ + +/** + * struct sframe_fde - SFrame Function Descriptor Entry. + * @start_addr: Function start address. Encoded as a signed offset, + * relative to the current FDE. + * @size: Size of the function in bytes. + * @fres_off: Offset of the first SFrame Frame Row Entry of the function, + * relative to the beginning of the SFrame Frame Row Entry sub-section. + * @fres_num: Number of frame row entries for the function. + * @info: Additional information for deciphering the stack trace + * information for the function. Contains information about SFrame FRE + * type, SFrame FDE type, PAC authorization A/B key, etc. + * @rep_size: Block size for SFRAME_FDE_TYPE_PCMASK + * @padding: Unused + */ +struct sframe_fde { + s32 start_addr; + u32 size; + u32 fres_off; + u32 fres_num; + u8 info; + u8 rep_size; + u16 padding; +} __packed; + +/* + * 'func_info' in SFrame FDE contains additional information for decipheri= ng + * the stack trace information for the function. In V1, the information is + * organized as follows: + * - 4-bits: Identify the FRE type used for the function. + * - 1-bit: Identify the FDE type of the function - mask or inc. + * - 1-bit: PAC authorization A/B key (aarch64). + * - 2-bits: Unused. + * --------------------------------------------------------------------- + * | Unused | PAC auth A/B key (aarch64) | FDE type | FRE type | + * | | Unused (amd64) | | | + * --------------------------------------------------------------------- + * 8 6 5 4 0 + */ + +/* Note: Set PAC auth key to SFRAME_AARCH64_PAUTH_KEY_A by default. */ +#define SFRAME_FUNC_INFO(fde_type, fre_enc_type) \ + (((SFRAME_AARCH64_PAUTH_KEY_A & 0x1) << 5) | \ + (((fde_type) & 0x1) << 4) | ((fre_enc_type) & 0xf)) + +#define SFRAME_FUNC_FRE_TYPE(data) ((data) & 0xf) +#define SFRAME_FUNC_FDE_TYPE(data) (((data) >> 4) & 0x1) +#define SFRAME_FUNC_PAUTH_KEY(data) (((data) >> 5) & 0x1) + +/* + * Size of stack frame offsets in an SFrame Frame Row Entry. A single + * SFrame FRE has all offsets of the same size. Offset size may vary + * across frame row entries. + */ +#define SFRAME_FRE_OFFSET_1B 0 +#define SFRAME_FRE_OFFSET_2B 1 +#define SFRAME_FRE_OFFSET_4B 2 + +/* An SFrame Frame Row Entry can be SP or FP based. */ +#define SFRAME_BASE_REG_FP 0 +#define SFRAME_BASE_REG_SP 1 + +/* + * The index at which a specific offset is presented in the variable length + * bytes of an FRE. + */ +#define SFRAME_FRE_CFA_OFFSET_IDX 0 +/* + * The RA stack offset, if present, will always be at index 1 in the varia= ble + * length bytes of the FRE. + */ +#define SFRAME_FRE_RA_OFFSET_IDX 1 +/* + * The FP stack offset may appear at offset 1 or 2, depending on the ABI a= s RA + * may or may not be tracked. + */ +#define SFRAME_FRE_FP_OFFSET_IDX 2 + +/* + * 'fre_info' in SFrame FRE contains information about: + * - 1 bit: base reg for CFA + * - 4 bits: Number of offsets (N). A value of up to 3 is allowed to tra= ck + * all three of CFA, FP and RA (fixed implicit order). + * - 2 bits: information about size of the offsets (S) in bytes. + * Valid values are SFRAME_FRE_OFFSET_1B, SFRAME_FRE_OFFSET_2B, + * SFRAME_FRE_OFFSET_4B + * - 1 bit: Mangled RA state bit (aarch64 only). + * --------------------------------------------------------------- + * | Mangled-RA (aarch64) | Size of | Number of | base_reg | + * | Unused (amd64) | offsets | offsets | | + * --------------------------------------------------------------- + * 8 7 5 1 0 + */ + +/* Note: Set mangled_ra_p to zero by default. */ +#define SFRAME_FRE_INFO(base_reg_id, offset_num, offset_size) \ + (((0 & 0x1) << 7) | (((offset_size) & 0x3) << 5) | \ + (((offset_num) & 0xf) << 1) | ((base_reg_id) & 0x1)) + +/* Set the mangled_ra_p bit as indicated. */ +#define SFRAME_FRE_INFO_UPDATE_MANGLED_RA_P(mangled_ra_p, fre_info) \ + ((((mangled_ra_p) & 0x1) << 7) | ((fre_info) & 0x7f)) + +#define SFRAME_FRE_CFA_BASE_REG_ID(data) ((data) & 0x1) +#define SFRAME_FRE_OFFSET_COUNT(data) (((data) >> 1) & 0xf) +#define SFRAME_FRE_OFFSET_SIZE(data) (((data) >> 5) & 0x3) +#define SFRAME_FRE_MANGLED_RA_P(data) (((data) >> 7) & 0x1) + +#endif /* _SFRAME_H */ --=20 2.48.1.262.g85cc9f2d1e-goog From nobody Fri Dec 19 16:08:36 2025 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 DC7391DB951 for ; Mon, 27 Jan 2025 21:33:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738013618; cv=none; b=QPyVN7s+CNea3Y+9i8dVLQzv7DZEXzqeO5iHs/ULAOx6XNHYuiH6meq5ahRYmDDKcwkde4NIE1m0XLkrtUhlfp0E+c2h4lwud1OqSQuQF0T4wuEvLLp0GQobHW/saonhkTGFzCwsgGLnaX9M6V2E7QFkOYs6oDz5PmfNiGduBVE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738013618; c=relaxed/simple; bh=4qOdPw6hOBZxSpET+wd7E8BTc7x5s3vFgcr6W7+jzvI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=IquGMoqntJ3L36dv4wmHA0BNie7PZAIiNW6EvqCtPodqGxEbo41v6YNR6lB6caPZi/BiKeq6yaT8xoJ+du1GlwfP7NyZkB9JjUp7dcJWWEvBAplSzmOx7u0Iq2mycAn2vVfT7Qn7uYHizypE1f2eyHnTq0Bo7hFUCHepIVCWOIU= 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=DZWUlv6T; arc=none smtp.client-ip=209.85.216.74 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="DZWUlv6T" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2efa74481fdso9895165a91.1 for ; Mon, 27 Jan 2025 13:33:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1738013615; x=1738618415; 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=vFxyJQizGcViiMZLcjGdqbFKo+O4vKLRWZRU/ldO2O0=; b=DZWUlv6TF2/2MW26VDsxa2TuwozQBrHsJsnW0UNCq1LyxFFgSg5KtccP6o7vPy+nvF k2rKskMz1gU51W7T5QnBUg4Sk8opHXU9bEcWp84fHBkMnGYfnZ7aelo+sRMvMFEQF3BH STCXSRCyV/5JnNsTKgKNX1xUll7weXlqfIorS+gLE9RakrQ9XLU55VSyclKsyBSOOrQZ 3qNSrBVEzbaSwzhgvGwp7Bpimcv8US/57mN/iq0QiUyNjZaRV3cDr8qa4O4CiprSIXdM 1M9vWoOb+ycLScelHwJkK5fNjacrtd13rk6mty6UO4zix1ELbUqtfzSaaZqtyRsgfiWD yw+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738013615; x=1738618415; 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=vFxyJQizGcViiMZLcjGdqbFKo+O4vKLRWZRU/ldO2O0=; b=RaVF3DY5ZdKIkYcXauwCU2+hvObF+uI3/rauN+4AWCWc2BsIS0LdZ9xlc7Y0Wb5Cgi tQGM50Eslj1cnB7ggmEUiXeIcw5ujgeXtJT73b+HRfcRGPxEtEpJbpOE1UcII63OjxJc Kc6krYqPA2xKS+wv7LQh8Z/qgcAUf3F8Sli1U0QU4C9ZSXJFnVuqUOhWAr7pZd9w4rHD VmCh4Ou9o2SsO7GoJrkNLEoTx3gwPqF/zTPsPBDk+gSsgGGIh+iTWnbJT2TI51IZ5m6V X8tFsi/LaRcGZ4bJXdPmlmqI9SpdqSiu/Y/Fanmfyi2CaHXnL0rvyuwdxRog3IfFASXq F3TQ== X-Forwarded-Encrypted: i=1; AJvYcCVguFPtPE+LWArVpSkpVpdzqzldWasvRXDRafYQpCiBH1Skke1uXJnOvZ/ySMdcV0keWXFrXutuB5acZxQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yy0lK0a2ypgepKMza0wS8beR9FoW7BqTGc+L3HcckKsVeKcavar WSSrRHoN/Fgu+c0jpJ/iu4v7GG0HBL9yXX5mDPj1i5nH+iKAGW1F9HPiszwQHXtbjL3P/6gJqg= = X-Google-Smtp-Source: AGHT+IHHPT3SHafekGNUGDZsLxe9xIeZEZ7pS5XFwvuSD16m5Qqb3+3tw3GkG+JemAl3HyjyegOXze/WMg== X-Received: from pjbpa16.prod.google.com ([2002:a17:90b:2650:b0:2da:ac73:93e0]) (user=wnliu job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:2751:b0:2ee:f440:53ed with SMTP id 98e67ed59e1d1-2f782d9a1d5mr60272909a91.31.1738013614965; Mon, 27 Jan 2025 13:33:34 -0800 (PST) Date: Mon, 27 Jan 2025 21:33:06 +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-5-wnliu@google.com> Subject: [PATCH 4/8] unwind: Implement generic sframe unwinder library 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" This change introduces a kernel space unwinder using sframe table for architectures without ORC unwinder support. The implementation is adapted from Josh's userspace sframe unwinder proposal[1] according to the sframe v2 spec[2]. [1] https://lore.kernel.org/lkml/42c0a99236af65c09c8182e260af7bcf5aa1e158.1= 730150953.git.jpoimboe@kernel.org/ [2] https://sourceware.org/binutils/docs/sframe-spec.html Signed-off-by: Weinan Liu Reviewed-by: Prasanna Kumar T S M . --- include/linux/sframe_lookup.h | 43 ++++++++ kernel/Makefile | 1 + kernel/sframe_lookup.c | 196 ++++++++++++++++++++++++++++++++++ 3 files changed, 240 insertions(+) create mode 100644 include/linux/sframe_lookup.h create mode 100644 kernel/sframe_lookup.c diff --git a/include/linux/sframe_lookup.h b/include/linux/sframe_lookup.h new file mode 100644 index 000000000000..1c26cf1f38d4 --- /dev/null +++ b/include/linux/sframe_lookup.h @@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_SFRAME_LOOKUP_H +#define _LINUX_SFRAME_LOOKUP_H + +/** + * struct sframe_ip_entry - sframe unwind info for given ip + * @cfa_offset: Offset for the Canonical Frame Address(CFA) from Frame + * Pointer(FP) or Stack Pointer(SP) + * @ra_offset: Offset for the Return Address from CFA. + * @fp_offset: Offset for the Frame Pointer (FP) from CFA. + * @use_fp: Use FP to get next CFA or not + */ +struct sframe_ip_entry { + int32_t cfa_offset; + int32_t ra_offset; + int32_t fp_offset; + bool use_fp; +}; + +/** + * struct sframe_table - sframe struct of a table + * @sfhdr_p: Pointer to sframe header + * @fde_p: Pointer to the first of sframe frame description entry(FDE). + * @fre_p: Pointer to the first of sframe frame row entry(FRE). + */ +struct sframe_table { + struct sframe_header *sfhdr_p; + struct sframe_fde *fde_p; + char *fre_p; +}; + +#ifdef CONFIG_SFRAME_UNWINDER +void init_sframe_table(void); +int sframe_find_pc(unsigned long pc, struct sframe_ip_entry *entry); +#else +static inline void init_sframe_table(void) {} +static inline int sframe_find_pc(unsigned long pc, struct sframe_ip_entry = *entry) +{ + return -EINVAL; +} +#endif + +#endif /* _LINUX_SFRAME_LOOKUP_H */ diff --git a/kernel/Makefile b/kernel/Makefile index 87866b037fbe..705c9277e5cd 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -131,6 +131,7 @@ obj-$(CONFIG_WATCH_QUEUE) +=3D watch_queue.o =20 obj-$(CONFIG_RESOURCE_KUNIT_TEST) +=3D resource_kunit.o obj-$(CONFIG_SYSCTL_KUNIT_TEST) +=3D sysctl-test.o +obj-$(CONFIG_SFRAME_UNWINDER) +=3D sframe_lookup.o =20 CFLAGS_stackleak.o +=3D $(DISABLE_STACKLEAK_PLUGIN) obj-$(CONFIG_GCC_PLUGIN_STACKLEAK) +=3D stackleak.o diff --git a/kernel/sframe_lookup.c b/kernel/sframe_lookup.c new file mode 100644 index 000000000000..846f1da95d89 --- /dev/null +++ b/kernel/sframe_lookup.c @@ -0,0 +1,196 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include +#include +#include +#include +#include "sframe.h" + +#define pr_fmt(fmt) "sframe: " fmt + +extern char __start_sframe_header[]; +extern char __stop_sframe_header[]; + +static bool sframe_init __ro_after_init; +static struct sframe_table sftbl; + +#define SFRAME_READ_TYPE(in, out, type) \ +({ \ + type __tmp; \ + memcpy(&__tmp, in, sizeof(__tmp)); \ + in +=3D sizeof(__tmp); \ + out =3D __tmp; \ +}) + +#define SFRAME_READ_ROW_ADDR(in_addr, out_addr, type) \ +({ \ + switch (type) { \ + case SFRAME_FRE_TYPE_ADDR1: \ + SFRAME_READ_TYPE(in_addr, out_addr, u8); \ + break; \ + case SFRAME_FRE_TYPE_ADDR2: \ + SFRAME_READ_TYPE(in_addr, out_addr, u16); \ + break; \ + case SFRAME_FRE_TYPE_ADDR4: \ + SFRAME_READ_TYPE(in_addr, out_addr, u32); \ + break; \ + default: \ + break; \ + } \ +}) + +#define SFRAME_READ_ROW_OFFSETS(in_addr, out_addr, size) \ +({ \ + switch (size) { \ + case 1: \ + SFRAME_READ_TYPE(in_addr, out_addr, s8); \ + break; \ + case 2: \ + SFRAME_READ_TYPE(in_addr, out_addr, s16); \ + break; \ + case 4: \ + SFRAME_READ_TYPE(in_addr, out_addr, s32); \ + break; \ + default: \ + break; \ + } \ +}) + +static struct sframe_fde *find_fde(const struct sframe_table *tbl, unsigne= d long pc) +{ + int l, r, m, f; + int32_t ip; + struct sframe_fde *fdep; + + if (!tbl || !tbl->sfhdr_p || !tbl->fde_p) + return NULL; + + ip =3D (pc - (unsigned long)tbl->sfhdr_p); + + /* Do a binary range search to find the rightmost FDE start_addr < ip */ + l =3D m =3D f =3D 0; + r =3D tbl->sfhdr_p->num_fdes; + while (l < r) { + m =3D l + ((r - l) / 2); + fdep =3D tbl->fde_p + m; + if (fdep->start_addr > ip) + r =3D m; + else + l =3D m + 1; + } + /* use l - 1 because l will be the first item fdep->start_addr > ip */ + f =3D l - 1; + if (f >=3D tbl->sfhdr_p->num_fdes || f < 0) + return NULL; + fdep =3D tbl->fde_p + f; + if (ip < fdep->start_addr || ip >=3D fdep->start_addr + fdep->size) + return NULL; + + return fdep; +} + +static int find_fre(const struct sframe_table *tbl, unsigned long pc, + const struct sframe_fde *fdep, struct sframe_ip_entry *entry) +{ + int i, offset_size, offset_count; + char *fres, *offsets_loc; + int32_t ip_off; + uint32_t next_row_ip_off; + uint8_t fre_info, fde_type =3D SFRAME_FUNC_FDE_TYPE(fdep->info), + fre_type =3D SFRAME_FUNC_FRE_TYPE(fdep->info); + + fres =3D tbl->fre_p + fdep->fres_off; + + /* Whether PCs in the FREs should be treated as masks or not */ + if (fde_type =3D=3D SFRAME_FDE_TYPE_PCMASK) + ip_off =3D pc % fdep->rep_size; + else + ip_off =3D (int32_t)(pc - (unsigned long)tbl->sfhdr_p) - fdep->start_add= r; + + if (ip_off < 0 || ip_off >=3D fdep->size) + return -EINVAL; + + /* + * FRE structure starts by address of the entry with variants length. Use + * two pointers to track current head(fres) and the address of last + * offset(offsets_loc) + */ + for (i =3D 0; i < fdep->fres_num; i++) { + SFRAME_READ_ROW_ADDR(fres, next_row_ip_off, fre_type); + if (ip_off < next_row_ip_off) + break; + SFRAME_READ_TYPE(fres, fre_info, u8); + offsets_loc =3D fres; + /* + * jump to the start of next fre + * fres +=3D fre_offets_cnt*offset_size + */ + fres +=3D SFRAME_FRE_OFFSET_COUNT(fre_info) << SFRAME_FRE_OFFSET_SIZE(fr= e_info); + } + + offset_size =3D 1 << SFRAME_FRE_OFFSET_SIZE(fre_info); + offset_count =3D SFRAME_FRE_OFFSET_COUNT(fre_info); + + if (offset_count > 0) { + SFRAME_READ_ROW_OFFSETS(offsets_loc, entry->cfa_offset, offset_size); + offset_count--; + } + if (offset_count > 0 && !entry->ra_offset) { + SFRAME_READ_ROW_OFFSETS(offsets_loc, entry->ra_offset, offset_size); + offset_count--; + } + if (offset_count > 0 && !entry->fp_offset) { + SFRAME_READ_ROW_OFFSETS(offsets_loc, entry->fp_offset, offset_size); + offset_count--; + } + if (offset_count) + return -EINVAL; + + entry->use_fp =3D SFRAME_FRE_CFA_BASE_REG_ID(fre_info) =3D=3D SFRAME_BASE= _REG_FP; + + return 0; +} + +int sframe_find_pc(unsigned long pc, struct sframe_ip_entry *entry) +{ + struct sframe_fde *fdep; + struct sframe_table *sftbl_p =3D &sftbl; + int err; + + if (!sframe_init) + return -EINVAL; + + memset(entry, 0, sizeof(*entry)); + entry->ra_offset =3D sftbl_p->sfhdr_p->cfa_fixed_ra_offset; + entry->fp_offset =3D sftbl_p->sfhdr_p->cfa_fixed_fp_offset; + + fdep =3D find_fde(sftbl_p, pc); + if (!fdep) + return -EINVAL; + err =3D find_fre(sftbl_p, pc, fdep, entry); + if (err) + return err; + + return 0; +} + +void __init init_sframe_table(void) +{ + size_t sframe_size =3D (void *)__stop_sframe_header - (void *)__start_sfr= ame_header; + void *sframe_buf =3D __start_sframe_header; + + if (sframe_size <=3D 0) + return; + sftbl.sfhdr_p =3D sframe_buf; + if (!sftbl.sfhdr_p || sftbl.sfhdr_p->preamble.magic !=3D SFRAME_MAGIC || + sftbl.sfhdr_p->preamble.version !=3D SFRAME_VERSION_2 || + !(sftbl.sfhdr_p->preamble.flags & SFRAME_F_FDE_SORTED)) { + pr_warn("WARNING: Unable to read sframe header. Disabling unwinder.\n"); + return; + } + + sftbl.fde_p =3D (struct sframe_fde *)(__start_sframe_header + SFRAME_HDR_= SIZE(*sftbl.sfhdr_p) + + sftbl.sfhdr_p->fdes_off); + sftbl.fre_p =3D __start_sframe_header + SFRAME_HDR_SIZE(*sftbl.sfhdr_p) + + sftbl.sfhdr_p->fres_off; + sframe_init =3D true; +} --=20 2.48.1.262.g85cc9f2d1e-goog From nobody Fri Dec 19 16:08:36 2025 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (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 C19EE1DC04A for ; Mon, 27 Jan 2025 21:33:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738013619; cv=none; b=klMT5unNYPyckU5GrZHLl3c/abYc2vJFmZ+H6RpNhgeB7NBAw/H9xgtxBQq8tMvQPajrvUydAXWvnjLHt3x7ISaIf5MdMNwOwjJnNAbmdxGswW8tajEupIGqp/u9xGq2ldEycwfFTgPYRyNHajzprGu6AZEaX7zY1wcMbS2otgE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738013619; c=relaxed/simple; bh=0ubT0xAtIOtmf4+xnpRjnjYol+CqTrZ8xAjo8nvcNvM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=FL9rX4xiZVFtZ69j7YZ+lq0OB8r7MFjbFPwOfFYQOg+GO0GfJ++p3hVWRmW/brtxNPyb932hpRAQSe1hRSpQB2TMiw9cR75xntZuXM+kwlsBYBC5SvoeBeg/YwUtH8Poy9i/qAS2KYzp+tOTEpU8oRxq7+NPhlQyfMyZmE4GKt4= 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=byKFvHqx; arc=none smtp.client-ip=209.85.214.202 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="byKFvHqx" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2163dc0f689so144572365ad.1 for ; Mon, 27 Jan 2025 13:33:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1738013617; x=1738618417; 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=mFZXsTdloa5FzORw/CsOyUNbSmbFrEPnylJyQFApTRk=; b=byKFvHqxa6uwtj1PpyusG9Crc0EIWmJqd+MM6iNb6/8i/imykVkJFRzl1jJ45smEf1 Ys7kiBwq3XxjKlAxy9wtxYbuVnO7oq6VD5ZgTxDjiZpwbeeC2xNohSkBC+LxSiaN0571 mLieTnpf2OipXafKJ6YeVdGQHu+ganUmCuNqc4J379Rww5KTX54Yk0GsGG0XG+rLhgmE Xwi5p/ZsaJMr/T72e9oXQApap9CMB2BoFDKthZOxpvIaWVgppvp2Lh5fNQXCAuG8ydoM swRUg8/q19FL0G3te1MgYdX5SU4+bXHU9jHHQYE4YhJqzuafiKHonOxcBZg1p2CedG/7 P4vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738013617; x=1738618417; 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=mFZXsTdloa5FzORw/CsOyUNbSmbFrEPnylJyQFApTRk=; b=sNI5cT9ISzy3j/UqtfNTI1M9fdL4EAOiK2C2VC8EHqBkjg1b4N5IDyZ/+y0Dlh9Zgv iCyk0EuJAwMxHrgoRu7WBnRY13UXbI1znv6r4KxBkdu4FQnnpTWXqvwuK0TGfXzpdCOG Kh63wFrmUG8MsjQdod3gDAMXSP7YqV6YHofelZgM19zjyQ7NKwXO2GVx+hWx1MH4HCkH 4pzTw+wAbJeVqBDrlAEH9nSoRrhZHZzX6sYA7vgriRvlE868vf5o/uZ5ztXAPTKrvliG yixdpf6TJLMW9IxGNo40EAtay/J7ru2TDXpalYlKkJU1m9yhBGcraNxwwgVY/5eAQteE q73A== X-Forwarded-Encrypted: i=1; AJvYcCXFOkNulgCEA1nkjlZ/G6o/cV3wbALdFCDLZJ1ens1ey//RC+BPM86J909i7n8Wq5ejMYX72ZogErM1V0I=@vger.kernel.org X-Gm-Message-State: AOJu0Ywnmvhv841LVk7kWBMixVLkQwMOh+sHtx1tmxOQqSVuTn9trMi4 APREyp4sx2+jRlb5TaYmi8hxUt3LegjJKr2UiIFox8dnIJCfG98SWGfoi1tcXFTSss1ZGSKorQ= = X-Google-Smtp-Source: AGHT+IENha76YNN6DTFkO6aZG4PVMEo+T4QLkeiQTYtMA7zB4aNyty+JXRxi3cxPQYVRs4yLEbvYOf/KmQ== X-Received: from pfbbx20.prod.google.com ([2002:a05:6a00:4294:b0:729:14f9:2f50]) (user=wnliu job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:12c6:b0:1e0:e000:ca60 with SMTP id adf61e73a8af0-1eb215ec22fmr70877628637.28.1738013617138; Mon, 27 Jan 2025 13:33:37 -0800 (PST) Date: Mon, 27 Jan 2025 21:33:07 +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-6-wnliu@google.com> Subject: [PATCH 5/8] unwind: arm64: Add sframe unwinder on arm64 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" Add unwind_next_frame_sframe() function to unwind by sframe info. Built with GNU Binutils 2.42 to verify that this sframe unwinder can backtrace correctly on arm64. Signed-off-by: Weinan Liu Reviewed-by: Prasanna Kumar T S M . --- arch/arm64/include/asm/stacktrace/common.h | 4 ++ arch/arm64/kernel/setup.c | 2 + arch/arm64/kernel/stacktrace.c | 59 ++++++++++++++++++++++ 3 files changed, 65 insertions(+) diff --git a/arch/arm64/include/asm/stacktrace/common.h b/arch/arm64/includ= e/asm/stacktrace/common.h index 821a8fdd31af..19edae8a5b1a 100644 --- a/arch/arm64/include/asm/stacktrace/common.h +++ b/arch/arm64/include/asm/stacktrace/common.h @@ -25,6 +25,7 @@ struct stack_info { * @stack: The stack currently being unwound. * @stacks: An array of stacks which can be unwound. * @nr_stacks: The number of stacks in @stacks. + * @cfa: The sp value at the call site of the current function. */ struct unwind_state { unsigned long fp; @@ -33,6 +34,9 @@ struct unwind_state { struct stack_info stack; struct stack_info *stacks; int nr_stacks; +#ifdef CONFIG_SFRAME_UNWINDER + unsigned long cfa; +#endif }; =20 static inline struct stack_info stackinfo_get_unknown(void) diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 4f613e8e0745..d3ac92b624f3 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -32,6 +32,7 @@ #include #include #include +#include =20 #include #include @@ -377,6 +378,7 @@ void __init __no_sanitize_address setup_arch(char **cmd= line_p) "This indicates a broken bootloader or old kernel\n", boot_args[1], boot_args[2], boot_args[3]); } + init_sframe_table(); } =20 static inline bool cpu_can_disable(unsigned int cpu) diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c index 1d9d51d7627f..c035adb8fe8a 100644 --- a/arch/arm64/kernel/stacktrace.c +++ b/arch/arm64/kernel/stacktrace.c @@ -14,6 +14,7 @@ #include #include #include +#include =20 #include #include @@ -242,6 +243,53 @@ kunwind_next_frame_record(struct kunwind_state *state) return 0; } =20 +#ifdef CONFIG_SFRAME_UNWINDER +/* + * Unwind to the next frame according to sframe. + */ +static __always_inline int +unwind_next_frame_sframe(struct unwind_state *state) +{ + unsigned long fp =3D state->fp, ip =3D state->pc; + unsigned long base_reg, cfa; + unsigned long pc_addr, fp_addr; + struct sframe_ip_entry entry; + struct stack_info *info; + struct frame_record *record =3D (struct frame_record *)fp; + + int err; + + /* frame record alignment 8 bytes */ + if (fp & 0x7) + return -EINVAL; + + info =3D unwind_find_stack(state, fp, sizeof(*record)); + if (!info) + return -EINVAL; + + err =3D sframe_find_pc(ip, &entry); + if (err) + return -EINVAL; + + unwind_consume_stack(state, info, fp, sizeof(*record)); + + base_reg =3D entry.use_fp ? fp : state->cfa; + + /* Set up the initial CFA using fp based info if CFA is not set */ + if (!state->cfa) + cfa =3D fp - entry.fp_offset; + else + cfa =3D base_reg + entry.cfa_offset; + fp_addr =3D cfa + entry.fp_offset; + pc_addr =3D cfa + entry.ra_offset; + state->cfa =3D cfa; + state->fp =3D READ_ONCE(*(unsigned long *)(fp_addr)); + state->pc =3D READ_ONCE(*(unsigned long *)(pc_addr)); + + return 0; +} +#endif + /* * Unwind from one frame record (A) to the next frame record (B). * @@ -261,7 +309,15 @@ kunwind_next(struct kunwind_state *state) case KUNWIND_SOURCE_CALLER: case KUNWIND_SOURCE_TASK: case KUNWIND_SOURCE_REGS_PC: +#ifdef CONFIG_SFRAME_UNWINDER + err =3D unwind_next_frame_sframe(&state->common); + + /* Fallback to FP based unwinder */ + if (err) err =3D kunwind_next_frame_record(state); +#else + err =3D kunwind_next_frame_record(state); +#endif break; default: err =3D -EINVAL; @@ -347,6 +403,9 @@ kunwind_stack_walk(kunwind_consume_fn consume_state, .common =3D { .stacks =3D stacks, .nr_stacks =3D ARRAY_SIZE(stacks), +#ifdef CONFIG_SFRAME_UNWINDER + .cfa =3D 0, +#endif }, }; =20 --=20 2.48.1.262.g85cc9f2d1e-goog From nobody Fri Dec 19 16:08:36 2025 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (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 1145E1DC98B for ; Mon, 27 Jan 2025 21:33:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738013621; cv=none; b=LrWb0RerbcRVRxrxxgl0zPVWQGG2gGOYfCdtPGJggEiCTNSeTqfp5XidAuLG2RgY/usWauRDe2He+Ej8KueZIF+ASBh9Lk48F1LT/S2z63Y6xJpW2tcMP+J16VZPslk9BugSNATnLoGVqxTxfckOghQuvucFJpv9kSPZL9sMvm0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738013621; c=relaxed/simple; bh=tLQk9i7rfIosZMUbrAAbSOIaa7HREbh9qj/W4g2I5R0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=VVN0khwWNiA/qpunCU6qw7f1jBK7AnaOcsFyMadyB2DVMf9K1kXg+Z59ynYKPop81wx1pJmXM4tZrQVhOkucy0YuQ3Lkp4DHv508KY7GxgnE6GCIR6pQj8SkalT4kf9Gf/xv3kUK8GaGBxM9PBk+fwFAEL9+yU6GtrAZqZJQ65s= 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=UJjR64Tw; arc=none smtp.client-ip=209.85.214.202 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="UJjR64Tw" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-21655569152so96002525ad.2 for ; Mon, 27 Jan 2025 13:33:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1738013619; x=1738618419; 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=FcMmLMqjQF9870LrAMy1ogNf6Ad9PcDDaPxJ25OGjiY=; b=UJjR64Twt0a/emLT+XNSdujeU7vYZURAjRUPGpFeJDkby7i07DSNHLR8rnGPWOfd0M aGxnYZJ0QUhpjwC8P5DrCb3/FKHI+4BR4/JHAYiRIDNXCaZ1xPgTIUFmpb1GdXckUkJB l0Hb03BR89lyeV5mNco8xVD4cqBlIhtHuhqhBAP2/gUIh/GqrhZtfPXrlDW13yzNyj80 dJu1pWM1HSUvjWB7SV/WzXI7lMzigKUuZFhHYnSInmb9U+VpSfMzcWTFoCvYgLi9qZJk bdBtfXowLHxLVP/ehik04W5ZBRtcjrGm8mwerEY3tOQszgbFVqNWJ5l+Lx8/iE31XtnO VFzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738013619; x=1738618419; 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=FcMmLMqjQF9870LrAMy1ogNf6Ad9PcDDaPxJ25OGjiY=; b=WYj//AoKqsEL0j/5pncwwyEcppPQ8NZrAgsDmWLbq5DiztE9HEXS60VymBsTCJfnsD o683RQ0GyVVAzrrnNhpYs+IdtzUu8YwAFf/1/IEH9Q5TrMPtQ7FbqhgMaOh8As0WBYcS KJZvGOXs0eeme635QFkPe0/+XYidfOoCqGlOx435lsa58/MMxr/85ox1dZh9ckehWbho mrQ/e69yHDdXBT/iQiNe6rCv3XY2zzNu885IdFQVTBRIv2t36S4kc/MhyUMV7B0Z/fbL 78etvBTGV+AvUVaL5RHidIURl8cmc4Zmrmn3cm7QkJDw7rHSyGnMHXQCsNy3YRcprmRG rogA== X-Forwarded-Encrypted: i=1; AJvYcCUD2FcdOrAkbiqjrU1WBDgHiVhpuORTf0QPG28JYyXCYcYdLFnpt85mgxfi2hkossBxu0hKI8J1zgpV6VQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yz+b0vkFVBf1UG2NAAkPr+6uxBmWqOA0xpS+gwNcxSjqBfLaP1n H+KyOeDEkb5Y9CkVw+5Z8lUOEIYOyKKSLE+C7AUqcJ/DJT4b6CrX0rGsYV7iX2h7ilP3h6dIrg= = X-Google-Smtp-Source: AGHT+IENqQ4a+JpNNuEyJE6twpdJLH79mb1KDwUiISYTqFmJctu2Pc5D2j5e3Ta7eQhNemgumBMfeJjRgA== X-Received: from pgbbg17.prod.google.com ([2002:a05:6a02:111:b0:7fc:2b57:38f5]) (user=wnliu job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:841c:b0:1e0:d9a0:4ff7 with SMTP id adf61e73a8af0-1eb21599eecmr80987482637.32.1738013619557; Mon, 27 Jan 2025 13:33:39 -0800 (PST) Date: Mon, 27 Jan 2025 21:33:08 +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-7-wnliu@google.com> Subject: [PATCH 6/8] unwind: arm64: add reliable stacktrace support for arm64 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" To support livepatch, we need to add arch_stack_walk_reliable to support reliable stacktrace according to https://docs.kernel.org/livepatch/reliable-stacktrace.html#requirements report stacktrace is not reliable if we are not able to unwind the stack by sframe unwinder and fallback to FP based unwinder Signed-off-by: Weinan Liu Reviewed-by: Prasanna Kumar T S M . --- arch/arm64/include/asm/stacktrace/common.h | 2 + arch/arm64/kernel/stacktrace.c | 47 +++++++++++++++++++++- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/stacktrace/common.h b/arch/arm64/includ= e/asm/stacktrace/common.h index 19edae8a5b1a..26449cd402db 100644 --- a/arch/arm64/include/asm/stacktrace/common.h +++ b/arch/arm64/include/asm/stacktrace/common.h @@ -26,6 +26,7 @@ struct stack_info { * @stacks: An array of stacks which can be unwound. * @nr_stacks: The number of stacks in @stacks. * @cfa: The sp value at the call site of the current function. + * @unreliable: Stacktrace is unreliable. */ struct unwind_state { unsigned long fp; @@ -36,6 +37,7 @@ struct unwind_state { int nr_stacks; #ifdef CONFIG_SFRAME_UNWINDER unsigned long cfa; + bool unreliable; #endif }; =20 diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c index c035adb8fe8a..eab16dc05bb5 100644 --- a/arch/arm64/kernel/stacktrace.c +++ b/arch/arm64/kernel/stacktrace.c @@ -310,11 +310,16 @@ kunwind_next(struct kunwind_state *state) case KUNWIND_SOURCE_TASK: case KUNWIND_SOURCE_REGS_PC: #ifdef CONFIG_SFRAME_UNWINDER - err =3D unwind_next_frame_sframe(&state->common); + if (!state->common.unreliable) + err =3D unwind_next_frame_sframe(&state->common); =20 /* Fallback to FP based unwinder */ - if (err) + if (err || state->common.unreliable) { err =3D kunwind_next_frame_record(state); + /* Mark its stacktrace result as unreliable if it is unwindable via FP */ + if (!err) + state->common.unreliable =3D true; + } #else err =3D kunwind_next_frame_record(state); #endif @@ -446,6 +451,44 @@ noinline noinstr void arch_stack_walk(stack_trace_cons= ume_fn consume_entry, kunwind_stack_walk(arch_kunwind_consume_entry, &data, task, regs); } =20 +#ifdef CONFIG_SFRAME_UNWINDER +struct kunwind_reliable_consume_entry_data { + stack_trace_consume_fn consume_entry; + void *cookie; + bool unreliable; +}; + +static __always_inline bool +arch_kunwind_reliable_consume_entry(const struct kunwind_state *state, voi= d *cookie) +{ + struct kunwind_reliable_consume_entry_data *data =3D cookie; + + if (state->common.unreliable) { + data->unreliable =3D true; + return false; + } + return data->consume_entry(data->cookie, state->common.pc); +} + +noinline notrace int arch_stack_walk_reliable( + stack_trace_consume_fn consume_entry, + void *cookie, struct task_struct *task) +{ + struct kunwind_reliable_consume_entry_data data =3D { + .consume_entry =3D consume_entry, + .cookie =3D cookie, + .unreliable =3D false, + }; + + kunwind_stack_walk(arch_kunwind_reliable_consume_entry, &data, task, NULL= ); + + if (data.unreliable) + return -EINVAL; + + return 0; +} +#endif + struct bpf_unwind_consume_entry_data { bool (*consume_entry)(void *cookie, u64 ip, u64 sp, u64 fp); void *cookie; --=20 2.48.1.262.g85cc9f2d1e-goog From nobody Fri Dec 19 16:08:36 2025 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (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 79E541DD0D6 for ; Mon, 27 Jan 2025 21:33:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738013624; cv=none; b=OwQYNxiINphJ5mliQ0B3nmVSyfEJLTpsqohvZu6+DjM36csp1+SUd2zZrY8p5cgcnI8MyQKcjSkjFInIyd6HvzEDga6iIe93dFDSwwnErRhkwzZM+ixx+UF9ykkFY0l/c8RQAHe0xpwm3yI13v2Eo4580F1e6cr3XEuVf8NUm+g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738013624; c=relaxed/simple; bh=f0JKhNQwV53/GhmzpUTomtyLPYdsyZ5pafPvoAy0J6E=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=fdAQ8VjnLpFs4QjGD1Sp/Hp5oeSbNVO3aQJJR3RMu3Uok9dtKMgVCuwrnRRpKnJmv8dy+IX9iRsc7KLNFegeOj3XNzHEZXL3s7JTTd64BlfQwWZXlSDX1BLb+gG6reP3ts1ilmWuKVfXiOUjN4lPEuLJXPMvPhmmjlEBBW0l83M= 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=H/RMbZVG; arc=none smtp.client-ip=209.85.214.202 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="H/RMbZVG" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-21650d4612eso132665915ad.2 for ; Mon, 27 Jan 2025 13:33:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1738013622; x=1738618422; 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=rrEAyoRWIZk//3vjAjFd2Tppwtrq4EACKZ1CutvRWx8=; b=H/RMbZVGsKZEadYkMlYhMppTW+d/pWPbTXDpRM7tz7vmKj8fOlmfKWcc16C47hgebb YTNey0lrYVxSsGzNPe/gbKZL+bINL4XIRtFt6N32aYU9xx+5pwLqnXa/oQ39opmWPDMm 2//ylrrNsEP8QVZ65LZ6LclK2TgwvVlIvGYGR4UisLY5O72noTtGZXu5tR0t8ywQBhnQ iqFEt2ewEJS/dOiDIjt2+gL0pG++D/03csTu/krns5i389kOQAlOKixt0cXcJw0B+7ch jk10TFO7Cn0ZFycrrsFjsPN5qKgVlEQjh7Zq50EzFSamzKoMdTW9ibDF/tyAhG+G83S6 kI8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738013622; x=1738618422; 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=rrEAyoRWIZk//3vjAjFd2Tppwtrq4EACKZ1CutvRWx8=; b=VCMwAG/Wb2i7lnbNGfcxidkYAYN46yTH7nVWJ79D+9LbE7K0uC7dbzRigZ7WaNdbPS N2rAMmclQW8HRG1XeRKaI2H9lh9OqU+slWiZ6fhYgaqXmn/V9AEAVEbg8caH1OBmMkvl Rd2NSXhkDdKW0NaiMXA+cyh7QRsh+bCYTyCMt65i0Y/XNsag1ghjfR/Mj9IgQrw/Oqrm qa0XW7eBwoPDMUqsFNNnJywacnq7UudfP84N1ZTxt3ilOE452hZq2R+iIOGV33u/Yzai IFHKn8hf2MV0TDG+fdoDiQAYlB/tQEH42BD876R0xM8sNYPuHpQKnTvbKMInrq4DW2ji p1xw== X-Forwarded-Encrypted: i=1; AJvYcCWhuielSx8DJY7ZArhtSGMKsHJo1yjVa2fpG7rhb/8xDh4qwNj4AiOJyJe06vSeOxDFAz2kF3NNpTpOess=@vger.kernel.org X-Gm-Message-State: AOJu0Yx7InO5do4KehOVtAGh/WKbsUz7X4Ey/LGZytw8WmlTa46n33I0 WDvwxGFfiXi8hmg5NqyPHqzDOAPw5hfHuim3KNXzFseEWJ1XtVMWhWjm7eVNHkKrMUL4ihbAPw= = X-Google-Smtp-Source: AGHT+IFFYVquifAUjWGrSZ5hEYAV0U5je02EgbAStisFUtw2EXTxIW8KfHqT+GqGJXHAuJ9zxlbXu/WPRQ== X-Received: from plblq6.prod.google.com ([2002:a17:903:1446:b0:215:515c:124e]) (user=wnliu job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:d2d2:b0:215:b01a:627f with SMTP id d9443c01a7336-21c352de4c0mr685131525ad.4.1738013621760; Mon, 27 Jan 2025 13:33:41 -0800 (PST) Date: Mon, 27 Jan 2025 21:33:09 +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-8-wnliu@google.com> Subject: [PATCH 7/8] arm64: Define TIF_PATCH_PENDING for livepatch 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, "Madhavan T. Venkataraman" , Suraj Jitindar Singh , Weinan Liu Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Madhavan T. Venkataraman" - Define TIF_PATCH_PENDING in arch/arm64/include/asm/thread_info.h for livepatch. - Check TIF_PATCH_PENDING in do_notify_resume() to patch the current task for livepatch. Signed-off-by: Suraj Jitindar Singh Signed-off-by: Madhavan T. Venkataraman Signed-off-by: Weinan Liu Reviewed-by: Prasanna Kumar T S M . --- arch/arm64/include/asm/thread_info.h | 4 +++- arch/arm64/kernel/entry-common.c | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/= thread_info.h index 1114c1c3300a..3810c2f3914e 100644 --- a/arch/arm64/include/asm/thread_info.h +++ b/arch/arm64/include/asm/thread_info.h @@ -64,6 +64,7 @@ void arch_setup_new_exec(void); #define TIF_UPROBE 4 /* uprobe breakpoint or singlestep */ #define TIF_MTE_ASYNC_FAULT 5 /* MTE Asynchronous Tag Check Fault */ #define TIF_NOTIFY_SIGNAL 6 /* signal notifications exist */ +#define TIF_PATCH_PENDING 7 /* pending live patching update */ #define TIF_SYSCALL_TRACE 8 /* syscall trace active */ #define TIF_SYSCALL_AUDIT 9 /* syscall auditing */ #define TIF_SYSCALL_TRACEPOINT 10 /* syscall tracepoint for ftrace */ @@ -99,11 +100,12 @@ void arch_setup_new_exec(void); #define _TIF_MTE_ASYNC_FAULT (1 << TIF_MTE_ASYNC_FAULT) #define _TIF_NOTIFY_SIGNAL (1 << TIF_NOTIFY_SIGNAL) #define _TIF_TSC_SIGSEGV (1 << TIF_TSC_SIGSEGV) +#define _TIF_PATCH_PENDING (1 << TIF_PATCH_PENDING) =20 #define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \ _TIF_NOTIFY_RESUME | _TIF_FOREIGN_FPSTATE | \ _TIF_UPROBE | _TIF_MTE_ASYNC_FAULT | \ - _TIF_NOTIFY_SIGNAL) + _TIF_NOTIFY_SIGNAL | _TIF_PATCH_PENDING) =20 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \ _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | \ diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-com= mon.c index b260ddc4d3e9..b537af333b42 100644 --- a/arch/arm64/kernel/entry-common.c +++ b/arch/arm64/kernel/entry-common.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -144,6 +145,9 @@ static void do_notify_resume(struct pt_regs *regs, unsi= gned long thread_flags) (void __user *)NULL, current); } =20 + if (thread_flags & _TIF_PATCH_PENDING) + klp_update_patch_state(current); + if (thread_flags & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL)) do_signal(regs); =20 --=20 2.48.1.262.g85cc9f2d1e-goog From nobody Fri Dec 19 16:08:36 2025 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 E006D1DDA0C for ; Mon, 27 Jan 2025 21:33:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738013626; cv=none; b=DyleJNzaSho+gAJoyAn/oQedMBoZkVeoNBLrVHYqAk4Tm1lsl/1Eod8q7yfx0rORoSvwzTUNb44cEqf+PeDZl2Z+lbyoPAygibLi7ODyZ82toeco7Jf6PVQ+Hb05D7QGMx153A0aJ5VlYB5gP4KucHxS8w2K1iW75rxayirflzM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738013626; c=relaxed/simple; bh=pI3FZDlF646LxEDSftCYlwDERzfFSfxkeBl5dFk7tWo=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=O+/gs0tNASyS/gV9l94HA/W9CVPP4bjDaAY2XiiUcXdSymaILjNTpzgEtQlkwNSU4TmuoekNEkSUQQJ2wD5uE4hSI7wXMRDrkRKdNAPhAeAAltbklHomQ4ZNbISgtKKbgOasVb5Y8etp3zDkFI/4DfMofeIv85jyWo3BkSOaQac= 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=3C5M9N0x; arc=none smtp.client-ip=209.85.216.74 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="3C5M9N0x" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2ef114d8346so9460093a91.0 for ; Mon, 27 Jan 2025 13:33:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1738013624; x=1738618424; 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=rDc9oon22Zy8JtV6oJyK3eShWNaKTPBJnRLwhRmq6mE=; b=3C5M9N0xNULISmGFd/fTiZuWZvO/EzaEtFt5ztUdecJEdBoWdTBi5fvE1RyO/zwA4q L/43idHs/7qP0Ph292HIt6P4slCDb2UlNu5dTyeFH/U7Mo/GFmcBSjAOPPuaRPybwICy t7QXoh5VAug70Veelhkm/QOWoIhuUCfTqAJnx9MtJT/hgOEBu8FAw/Osi4L6PAQUVud2 QmMieWtzGbmpKifrM0xAf/rGaBT8ddxZ6SeE8AsEpCyfppKDii+srQ4A4+yM+GsOKUD2 P5sVGTEbpn+mKL/wqi/IiEtEI/hxW6WjbZN4nAXfSwyWl0kEB3yJcfOQtap1IXPAMoye VrKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738013624; x=1738618424; 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=rDc9oon22Zy8JtV6oJyK3eShWNaKTPBJnRLwhRmq6mE=; b=b74tDc6nZeYDhK3+1AQoe49hkCamhvaceKrzw3bUPDy9Sk5Uubz7LDzs5OzPhkW/fJ spy+1xVdh042+SVdvBjlWBVaFXJIw+D3vJ7nOvsXtntZPgj+N85Q0ez0ojGnjM3J6LWU pISI+6Y7/rTOxydCsc01OFRaG4UUs5pShCOw/ST1orSM1GKLLCoa+griLSuCk+C4vGt6 kfNcapl1xYrgdEyzFJxoZD9MjKgzt2JHPEXfn4YAugoJFwyZtRKR7PgX0+VnzUPzV0NP gAdjsUXC1C4t8+J81Ly2LwipXo1QLC3GG9FFwzBJKiYohA9Novwfml82FSJfXzojjU2m F6ig== X-Forwarded-Encrypted: i=1; AJvYcCVBlrbljxwZyxPzncRJDmbi1q4R0cZUP8Q+m7/oUNVVjwHASOrXTZFX8o6eLZyZNHq67qtqpFdMEihsSdQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yy6EIVbG+JB2Mzve0xQEaa2BrYNAl09qDZPvCdRg7uE9xxnRg1+ 4hbvlGCCGOO+Vpx/1x7WyftN+RF8t86Lq1hXA197SGTLfuJVCzF7HeIApvb2f5r5P4isb7IMJQ= = X-Google-Smtp-Source: AGHT+IEfHevdTTJtb6AigZBRpVD2FnhyEzVTYMnATEtYpNkPmzEcW9Tro1KWiXPv1Vj43sJ3+gY4o9DCZA== X-Received: from pjbqo13.prod.google.com ([2002:a17:90b:3dcd:b0:2f4:47fc:7f17]) (user=wnliu job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:2808:b0:2ee:5edc:4b2 with SMTP id 98e67ed59e1d1-2f782cc0114mr60880084a91.20.1738013624271; Mon, 27 Jan 2025 13:33:44 -0800 (PST) Date: Mon, 27 Jan 2025 21:33:10 +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-9-wnliu@google.com> Subject: [PATCH 8/8] arm64: Enable livepatch for ARM64 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" Since SFrame is considered as reliable stacktrace, enable livepatch in arch/arm64/Kconfig Signed-off-by: Weinan Liu Reviewed-by: Prasanna Kumar T S M . --- arch/arm64/Kconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 100570a048c5..c292bc73b65c 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -271,6 +271,8 @@ config ARM64 select HAVE_SOFTIRQ_ON_OWN_STACK select USER_STACKTRACE_SUPPORT select VDSO_GETRANDOM + select HAVE_RELIABLE_STACKTRACE if SFRAME_UNWINDER + select HAVE_LIVEPATCH if HAVE_DYNAMIC_FTRACE_WITH_ARGS && HAVE_RELIABLE_= STACKTRACE help ARM 64-bit (AArch64) Linux support. =20 @@ -2498,3 +2500,4 @@ source "drivers/acpi/Kconfig" =20 source "arch/arm64/kvm/Kconfig" =20 +source "kernel/livepatch/Kconfig" --=20 2.48.1.262.g85cc9f2d1e-goog