From nobody Sat Feb 7 19:46:02 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 494F21A23BE; Tue, 22 Apr 2025 18:35:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745346931; cv=none; b=b51Td/WyMAxZ7jgqoTxzquzsbclXtEAUPKJEvOtUAluVUaIfq0FIifymaHQ++4wgMu8/S6MLbk6Qy/p2QOR1B0RN4JX1afCD6BLfZErkKmCHKaWwgoNaurM5zH9KAOslAWB1VliNWzlNpzmSt8Hwc0UzrjnPTgYgSSEINWkkHjw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745346931; c=relaxed/simple; bh=QhCwiPnd0gPBrQvImDQRKzcjy0jlFgvpErnwXkD5KI4=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=O25xwVcTXNssLD57c4UooF3SyXUu27+cAegfIhLqTKjUUIKsdiRB3SC067QuJ8lItKJHdeNKyWQelMoWZm+1d4AGgK49enqN32HWeTzgU3z0jHEyb3n6VoS8jX89O4Suh2RTYS48U7g3vUIonOjUNq/kD/Ay5pEiOWhCFDIY2jk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF154C4CEE9; Tue, 22 Apr 2025 18:35:30 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.98) (envelope-from ) id 1u7IUk-0000000Fw7R-0tvf; Tue, 22 Apr 2025 14:37:22 -0400 Message-ID: <20250422183722.068940486@goodmis.org> User-Agent: quilt/0.68 Date: Tue, 22 Apr 2025 14:34:40 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Josh Poimboeuf , Jens Remus , x86@kernel.org, Peter Zijlstra , Ingo Molnar , Indu Bhagat , Andy Lutomirski , Thomas Gleixner , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Subject: [PATCH v5 1/6] x86/vdso: Fix DWARF generation for getrandom() References: <20250422183439.895236512@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Josh Poimboeuf Add CFI annotations to the VDSO implementation of getrandom() so it will have valid DWARF unwinding metadata. Fixes: 33385150ac45 ("x86: vdso: Wire up getrandom() vDSO implementation") Signed-off-by: Josh Poimboeuf Signed-off-by: Steven Rostedt (Google) --- arch/x86/entry/vdso/vgetrandom-chacha.S | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/x86/entry/vdso/vgetrandom-chacha.S b/arch/x86/entry/vdso/= vgetrandom-chacha.S index bcba5639b8ee..cc82da9216fb 100644 --- a/arch/x86/entry/vdso/vgetrandom-chacha.S +++ b/arch/x86/entry/vdso/vgetrandom-chacha.S @@ -4,7 +4,7 @@ */ =20 #include -#include +#include =20 .section .rodata, "a" .align 16 @@ -22,7 +22,7 @@ CONSTANTS: .octa 0x6b20657479622d323320646e61707865 * rcx: number of 64-byte blocks to write to output */ SYM_FUNC_START(__arch_chacha20_blocks_nostack) - + CFI_STARTPROC .set output, %rdi .set key, %rsi .set counter, %rdx @@ -175,4 +175,5 @@ SYM_FUNC_START(__arch_chacha20_blocks_nostack) pxor temp,temp =20 ret + CFI_ENDPROC SYM_FUNC_END(__arch_chacha20_blocks_nostack) --=20 2.47.2 From nobody Sat Feb 7 19:46:02 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 60FDB1DEFC8; Tue, 22 Apr 2025 18:35:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745346931; cv=none; b=RH9onyYaBCOx/R65O5zE8RA3CKgvxjkKnb658srZ0MsEidiX8p9Hrm+dr8/vVEwDtPKwaZJz+Dy5eh7wEsqvE6yYAC4mYIE6ZfoUjwrEqRlFnEOyXqz4nyAnuYSVadK4Zs3VL0VHjMiKUZicN/MzGihl+qyIrhVQDEAzlCYxCAw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745346931; c=relaxed/simple; bh=CayS5OAoG+jEWAfNo0q90M7R6fNDrO+CxAEV6GDanqw=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=UoJ1jAUdprJpjcopmKsNRWO0zgRkOLhejplgAeBfzCaX9XV9TcSlbysVVElsSDJLkRCsl9bHw3ymhjO8nmHOCDJUQsmK6DVYgHWMW4yaq5HNEHkQSW3di6PhRiWpcP+fA1VoJciM8oNBt0XvEtYuzZhwwelZ/OfL6u8nwyyqcOY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8A60C4CEED; Tue, 22 Apr 2025 18:35:30 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.98) (envelope-from ) id 1u7IUk-0000000Fw7v-1brT; Tue, 22 Apr 2025 14:37:22 -0400 Message-ID: <20250422183722.237323078@goodmis.org> User-Agent: quilt/0.68 Date: Tue, 22 Apr 2025 14:34:41 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Josh Poimboeuf , Jens Remus , x86@kernel.org, Peter Zijlstra , Ingo Molnar , Indu Bhagat , Andy Lutomirski , Thomas Gleixner , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Subject: [PATCH v5 2/6] x86/asm: Avoid emitting DWARF CFI for non-VDSO References: <20250422183439.895236512@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Josh Poimboeuf It was decided years ago that .cfi_* annotations aren't maintainable in the kernel. They were replaced by objtool unwind hints. For the kernel proper, ensure the CFI_* macros don't do anything. On the other hand the VDSO library *does* use them, so user space can unwind through it. Make sure these macros only work for VDSO. They aren't actually being used outside of VDSO anyway, so there's no functional change. Signed-off-by: Josh Poimboeuf Signed-off-by: Steven Rostedt (Google) --- arch/x86/include/asm/dwarf2.h | 51 ++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/arch/x86/include/asm/dwarf2.h b/arch/x86/include/asm/dwarf2.h index 302e11b15da8..65d958ef1178 100644 --- a/arch/x86/include/asm/dwarf2.h +++ b/arch/x86/include/asm/dwarf2.h @@ -6,6 +6,15 @@ #warning "asm/dwarf2.h should be only included in pure assembly files" #endif =20 +#ifdef BUILD_VDSO + + /* + * For the vDSO, emit both runtime unwind information and debug + * symbols for the .dbg file. + */ + + .cfi_sections .eh_frame, .debug_frame + #define CFI_STARTPROC .cfi_startproc #define CFI_ENDPROC .cfi_endproc #define CFI_DEF_CFA .cfi_def_cfa @@ -21,21 +30,31 @@ #define CFI_UNDEFINED .cfi_undefined #define CFI_ESCAPE .cfi_escape =20 -#ifndef BUILD_VDSO - /* - * Emit CFI data in .debug_frame sections, not .eh_frame sections. - * The latter we currently just discard since we don't do DWARF - * unwinding at runtime. So only the offline DWARF information is - * useful to anyone. Note we should not use this directive if we - * ever decide to enable DWARF unwinding at runtime. - */ - .cfi_sections .debug_frame -#else - /* - * For the vDSO, emit both runtime unwind information and debug - * symbols for the .dbg file. - */ - .cfi_sections .eh_frame, .debug_frame -#endif +#else /* !BUILD_VDSO */ + +/* + * On x86, these macros aren't used outside VDSO. As well they shouldn't = be: + * they're fragile and very difficult to maintain. + */ + +.macro nocfi args:vararg +.endm + +#define CFI_STARTPROC nocfi +#define CFI_ENDPROC nocfi +#define CFI_DEF_CFA nocfi +#define CFI_DEF_CFA_REGISTER nocfi +#define CFI_DEF_CFA_OFFSET nocfi +#define CFI_ADJUST_CFA_OFFSET nocfi +#define CFI_OFFSET nocfi +#define CFI_REL_OFFSET nocfi +#define CFI_REGISTER nocfi +#define CFI_RESTORE nocfi +#define CFI_REMEMBER_STATE nocfi +#define CFI_RESTORE_STATE nocfi +#define CFI_UNDEFINED nocfi +#define CFI_ESCAPE nocfi + +#endif /* !BUILD_VDSO */ =20 #endif /* _ASM_X86_DWARF2_H */ --=20 2.47.2 From nobody Sat Feb 7 19:46:02 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A31D728134C; Tue, 22 Apr 2025 18:35:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745346931; cv=none; b=iYJTGilWBjG5fcNn4INAJ1EuyJW08lLP75+7IK93p92rGfCkHyjSqOPlc3z9fi0fE6lVevBB8xp57AP7DbvBsgM2n5bXRzJ9Taw0iw4JfKEUG8Th5yk1o9PDvOcwnMCTRzaql5vsKCR95a+VdwZfhhseo9asMsImYmgl9PaMLS0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745346931; c=relaxed/simple; bh=0Bb/tQprLXZHVSifz2vrARZ2q/lox2IgCNaDFpKyfF0=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=oxlp26fk7Swcsu5Xt6MmtZW4h8WweTerWWE2erZ4IjjutUfwelzxhlXOWver8m6rgl+bT+qfkq79PQT8MSkqws72u+DxvUlI5Whmv/0m5h5t5T27vpaj+uszPsbHmypVSMw9b2qmNkAODkSaLIdgtczdTgohydO5e13IbDzIHkw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2BC1EC4CEF9; Tue, 22 Apr 2025 18:35:31 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.98) (envelope-from ) id 1u7IUk-0000000Fw8P-2Kdc; Tue, 22 Apr 2025 14:37:22 -0400 Message-ID: <20250422183722.404841398@goodmis.org> User-Agent: quilt/0.68 Date: Tue, 22 Apr 2025 14:34:42 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Josh Poimboeuf , Jens Remus , x86@kernel.org, Peter Zijlstra , Ingo Molnar , Indu Bhagat , Andy Lutomirski , Thomas Gleixner , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Subject: [PATCH v5 3/6] x86/asm: Fix VDSO DWARF generation with kernel IBT enabled References: <20250422183439.895236512@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Josh Poimboeuf The DWARF .cfi_startproc annotation needs to be at the very beginning of a function. But with kernel IBT that doesn't happen as ENDBR is sneakily embedded in SYM_FUNC_START. As a result the DWARF unwinding info is wrong at the beginning of all the VDSO functions. Fix it by adding CFI_STARTPROC and CFI_ENDPROC to SYM_FUNC_START_* and SYM_FUNC_END respectively. Note this only affects VDSO, as the CFI_* macros are empty for the kernel proper. Fixes: c4691712b546 ("x86/linkage: Add ENDBR to SYM_FUNC_START*()") Signed-off-by: Josh Poimboeuf [ Fixed rebased issues. May need extra review ] Signed-off-by: Steven Rostedt (Google) --- Changes since v4: https://lore.kernel.org/all/5c7992c111adee94e242fbca2b3e6= 4ab8e96e595.1737511963.git.jpoimboe@kernel.org/ - Rebased to latest kernel which had changes to the ENDBR caused by: 582077c94052 ("x86/cfi: Clean up linkage") arch/x86/entry/vdso/vdso-layout.lds.S | 2 +- arch/x86/entry/vdso/vgetrandom-chacha.S | 2 -- arch/x86/entry/vdso/vsgx.S | 4 --- arch/x86/include/asm/linkage.h | 33 ++++++++++++++++++++----- arch/x86/include/asm/vdso.h | 1 - 5 files changed, 28 insertions(+), 14 deletions(-) diff --git a/arch/x86/entry/vdso/vdso-layout.lds.S b/arch/x86/entry/vdso/vd= so-layout.lds.S index ec1ac191a057..60747905de2b 100644 --- a/arch/x86/entry/vdso/vdso-layout.lds.S +++ b/arch/x86/entry/vdso/vdso-layout.lds.S @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -#include +#include #include #include =20 diff --git a/arch/x86/entry/vdso/vgetrandom-chacha.S b/arch/x86/entry/vdso/= vgetrandom-chacha.S index cc82da9216fb..a33212594731 100644 --- a/arch/x86/entry/vdso/vgetrandom-chacha.S +++ b/arch/x86/entry/vdso/vgetrandom-chacha.S @@ -22,7 +22,6 @@ CONSTANTS: .octa 0x6b20657479622d323320646e61707865 * rcx: number of 64-byte blocks to write to output */ SYM_FUNC_START(__arch_chacha20_blocks_nostack) - CFI_STARTPROC .set output, %rdi .set key, %rsi .set counter, %rdx @@ -175,5 +174,4 @@ SYM_FUNC_START(__arch_chacha20_blocks_nostack) pxor temp,temp =20 ret - CFI_ENDPROC SYM_FUNC_END(__arch_chacha20_blocks_nostack) diff --git a/arch/x86/entry/vdso/vsgx.S b/arch/x86/entry/vdso/vsgx.S index 37a3d4c02366..c0342238c976 100644 --- a/arch/x86/entry/vdso/vsgx.S +++ b/arch/x86/entry/vdso/vsgx.S @@ -24,8 +24,6 @@ .section .text, "ax" =20 SYM_FUNC_START(__vdso_sgx_enter_enclave) - /* Prolog */ - .cfi_startproc push %rbp .cfi_adjust_cfa_offset 8 .cfi_rel_offset %rbp, 0 @@ -143,8 +141,6 @@ SYM_FUNC_START(__vdso_sgx_enter_enclave) jle .Lout jmp .Lenter_enclave =20 - .cfi_endproc - _ASM_VDSO_EXTABLE_HANDLE(.Lenclu_eenter_eresume, .Lhandle_exception) =20 SYM_FUNC_END(__vdso_sgx_enter_enclave) diff --git a/arch/x86/include/asm/linkage.h b/arch/x86/include/asm/linkage.h index b51d8a4673f5..1ba1f208414f 100644 --- a/arch/x86/include/asm/linkage.h +++ b/arch/x86/include/asm/linkage.h @@ -40,6 +40,10 @@ =20 #ifdef __ASSEMBLER__ =20 +#ifndef LINKER_SCRIPT +#include +#endif + #if defined(CONFIG_MITIGATION_RETHUNK) && !defined(__DISABLE_EXPORTS) && != defined(BUILD_VDSO) #define RET jmp __x86_return_thunk #else /* CONFIG_MITIGATION_RETPOLINE */ @@ -112,34 +116,51 @@ # define SYM_FUNC_ALIAS_MEMFUNC SYM_FUNC_ALIAS #endif =20 +#define __SYM_FUNC_START \ + CFI_STARTPROC ASM_NL + +#define __SYM_FUNC_END \ + CFI_ENDPROC ASM_NL + /* SYM_TYPED_FUNC_START -- use for indirectly called globals, w/ CFI type = */ #define SYM_TYPED_FUNC_START(name) \ SYM_TYPED_START(name, SYM_L_GLOBAL, SYM_F_ALIGN) \ + __SYM_FUNC_START \ ENDBR =20 /* SYM_FUNC_START -- use for global functions */ #define SYM_FUNC_START(name) \ - SYM_START(name, SYM_L_GLOBAL, SYM_F_ALIGN) + SYM_START(name, SYM_L_GLOBAL, SYM_F_ALIGN) \ + __SYM_FUNC_START =20 /* SYM_FUNC_START_NOALIGN -- use for global functions, w/o alignment */ #define SYM_FUNC_START_NOALIGN(name) \ - SYM_START(name, SYM_L_GLOBAL, SYM_A_NONE) + SYM_START(name, SYM_L_GLOBAL, SYM_A_NONE) \ + __SYM_FUNC_START =20 /* SYM_FUNC_START_LOCAL -- use for local functions */ #define SYM_FUNC_START_LOCAL(name) \ - SYM_START(name, SYM_L_LOCAL, SYM_F_ALIGN) + SYM_START(name, SYM_L_LOCAL, SYM_F_ALIGN) \ + __SYM_FUNC_START =20 /* SYM_FUNC_START_LOCAL_NOALIGN -- use for local functions, w/o alignment = */ #define SYM_FUNC_START_LOCAL_NOALIGN(name) \ - SYM_START(name, SYM_L_LOCAL, SYM_A_NONE) + SYM_START(name, SYM_L_LOCAL, SYM_A_NONE) \ + __SYM_FUNC_START =20 /* SYM_FUNC_START_WEAK -- use for weak functions */ #define SYM_FUNC_START_WEAK(name) \ - SYM_START(name, SYM_L_WEAK, SYM_F_ALIGN) + SYM_START(name, SYM_L_WEAK, SYM_F_ALIGN) \ + __SYM_FUNC_START =20 /* SYM_FUNC_START_WEAK_NOALIGN -- use for weak functions, w/o alignment */ #define SYM_FUNC_START_WEAK_NOALIGN(name) \ - SYM_START(name, SYM_L_WEAK, SYM_A_NONE) + SYM_START(name, SYM_L_WEAK, SYM_A_NONE) \ + __SYM_FUNC_START + +#define SYM_FUNC_END(name) \ + __SYM_FUNC_END \ + SYM_END(name, SYM_T_FUNC) =20 #endif /* _ASM_X86_LINKAGE_H */ =20 diff --git a/arch/x86/include/asm/vdso.h b/arch/x86/include/asm/vdso.h index b7253ef3205a..c4290dadba66 100644 --- a/arch/x86/include/asm/vdso.h +++ b/arch/x86/include/asm/vdso.h @@ -2,7 +2,6 @@ #ifndef _ASM_X86_VDSO_H #define _ASM_X86_VDSO_H =20 -#include #include #include =20 --=20 2.47.2 From nobody Sat Feb 7 19:46:02 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7C7C296160; Tue, 22 Apr 2025 18:35:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745346931; cv=none; b=jKouJ/Zvf1Wc7Cy+53y6EV1RaHt33kkCxYgw+qfRpClJQZ07bycSbEBcwYwqrWyPB+hNN0UWk0chaKVFh4FauDBM/+CLPHZ49UFxRrbV8B8ql5sNtyirpnjZ7MQkuRgnNUDYtIu7qmaGAwuhZVmUYizJVorIaEbtwnncY7I3tqM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745346931; c=relaxed/simple; bh=5Uhvh8HGrIx0ciAQYGLxRvRE7Ph0FW5SI4Y5OS4TRF4=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=UJwtsDVyQRtoI/Nv8VnlxVy12kNjFF6KrJ82PW4BAj4tzr0+1JY249KmOm3HLkNQthxX5FXieAw5+xnx4NyFhHh9JE321X/MaFPzOHg7+A38+bb08INlguyYoWUCOm0edpzuql165Iye+7ZXi9smZJ7+V05s8WCeIKibFZIUj9A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39F6FC4CEF0; Tue, 22 Apr 2025 18:35:31 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.98) (envelope-from ) id 1u7IUk-0000000Fw8t-33dx; Tue, 22 Apr 2025 14:37:22 -0400 Message-ID: <20250422183722.578001358@goodmis.org> User-Agent: quilt/0.68 Date: Tue, 22 Apr 2025 14:34:43 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Josh Poimboeuf , Jens Remus , x86@kernel.org, Peter Zijlstra , Ingo Molnar , Indu Bhagat , Andy Lutomirski , Thomas Gleixner , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Subject: [PATCH v5 4/6] x86/vdso: Use SYM_FUNC_{START,END} in __kernel_vsyscall() References: <20250422183439.895236512@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Josh Poimboeuf Use SYM_FUNC_{START,END} instead of all the boilerplate. No functional change. Signed-off-by: Josh Poimboeuf Signed-off-by: Steven Rostedt (Google) --- arch/x86/entry/vdso/vdso32/system_call.S | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/arch/x86/entry/vdso/vdso32/system_call.S b/arch/x86/entry/vdso= /vdso32/system_call.S index d33c6513fd2c..bdc576548240 100644 --- a/arch/x86/entry/vdso/vdso32/system_call.S +++ b/arch/x86/entry/vdso/vdso32/system_call.S @@ -9,11 +9,7 @@ #include =20 .text - .globl __kernel_vsyscall - .type __kernel_vsyscall,@function - ALIGN -__kernel_vsyscall: - CFI_STARTPROC +SYM_FUNC_START(__kernel_vsyscall) /* * Reshuffle regs so that all of any of the entry instructions * will preserve enough state. @@ -79,7 +75,5 @@ SYM_INNER_LABEL(int80_landing_pad, SYM_L_GLOBAL) CFI_RESTORE ecx CFI_ADJUST_CFA_OFFSET -4 RET - CFI_ENDPROC - - .size __kernel_vsyscall,.-__kernel_vsyscall +SYM_FUNC_END(__kernel_vsyscall) .previous --=20 2.47.2 From nobody Sat Feb 7 19:46:02 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C6B622D793; Tue, 22 Apr 2025 18:35:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745346931; cv=none; b=KC5XwLNyrn9+f2Kmt6/K3EiYrDCeDarpJqykwKeaUR1k7LDPVWzLegy3ZDWdj0q8SvlItivsjli+m9Ky29+AyiqzSEwxxpTVxZOZRrwYmd0EYNJwoOpOKq9XNLnyKmOacemLXSF7IXY/3A+zC5MAiKPuEP1MaQlctdCgwxRQWn8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745346931; c=relaxed/simple; bh=UihD/TmxEBCrTh8U8AQInq1+Tc3Opzly13UDOmOBkLE=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=sBLxByRtfk2pBAA/RG0COaxWtttT3+Prl4SnrMbJnCz4d9n8qt/nFLWUnBrgfyJLzunLs+AD7WILlW+uLzCwHNHNF+ovhBQapTHMAlECJxFwB5Ed40tl5ZubPSkG7CUyA6WUEbM/Hu4/AJy3ZYiY0OHHwYONBAZ/vdm9pJ/Wf4I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73F31C4CEE9; Tue, 22 Apr 2025 18:35:31 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.98) (envelope-from ) id 1u7IUk-0000000Fw9N-3lUc; Tue, 22 Apr 2025 14:37:22 -0400 Message-ID: <20250422183722.751258699@goodmis.org> User-Agent: quilt/0.68 Date: Tue, 22 Apr 2025 14:34:44 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Josh Poimboeuf , Jens Remus , x86@kernel.org, Peter Zijlstra , Ingo Molnar , Indu Bhagat , Andy Lutomirski , Thomas Gleixner , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Subject: [PATCH v5 5/6] x86/vdso: Use CFI macros in __vdso_sgx_enter_enclave() References: <20250422183439.895236512@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Josh Poimboeuf Use the CFI macros instead of the raw .cfi_* directives to be consistent with the rest of the VDSO asm. It's also easier on the eyes. No functional changes. Signed-off-by: Josh Poimboeuf Signed-off-by: Steven Rostedt (Google) --- arch/x86/entry/vdso/vsgx.S | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/arch/x86/entry/vdso/vsgx.S b/arch/x86/entry/vdso/vsgx.S index c0342238c976..8d7b8eb45c50 100644 --- a/arch/x86/entry/vdso/vsgx.S +++ b/arch/x86/entry/vdso/vsgx.S @@ -24,13 +24,14 @@ .section .text, "ax" =20 SYM_FUNC_START(__vdso_sgx_enter_enclave) + SYM_F_ALIGN push %rbp - .cfi_adjust_cfa_offset 8 - .cfi_rel_offset %rbp, 0 + CFI_ADJUST_CFA_OFFSET 8 + CFI_REL_OFFSET %rbp, 0 mov %rsp, %rbp - .cfi_def_cfa_register %rbp + CFI_DEF_CFA_REGISTER %rbp push %rbx - .cfi_rel_offset %rbx, -8 + CFI_REL_OFFSET %rbx, -8 =20 mov %ecx, %eax .Lenter_enclave: @@ -77,13 +78,11 @@ SYM_FUNC_START(__vdso_sgx_enter_enclave) .Lout: pop %rbx leave - .cfi_def_cfa %rsp, 8 + CFI_DEF_CFA %rsp, 8 RET =20 - /* The out-of-line code runs with the pre-leave stack frame. */ - .cfi_def_cfa %rbp, 16 - .Linvalid_input: + CFI_DEF_CFA %rbp, 16 mov $(-EINVAL), %eax jmp .Lout =20 --=20 2.47.2 From nobody Sat Feb 7 19:46:02 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD9AE296179; Tue, 22 Apr 2025 18:35:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745346931; cv=none; b=vBtVksNV7+qou2mov1X5H8G1IdMlK7OtkLJRstmgp+ZrHUwnXe9YbYo7Yw04HyipwX4+R5e5+hcsbxyR0bUYD0iOOT/QvZSPK/9+Vx21TLheZ2RUjdcGHjPsg3/HO3/ASX7eFUU77cm2jw7o7csdDx4wwYvqQMjrjxPdl2GN60k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745346931; c=relaxed/simple; bh=qJMQ/YdxbpuMLffInkxJPnf55MoP0hvxW+wRtlvozRk=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=mgGTnsu6o20tAhr9bous8m8aMxWNa4QvTeqUYllRYmypqBlpdYv9eVLGxt4byqqttj01PZNWzkUiN3UzcsjA8XU3Hil+O7xb8M4rYe5vNLXxTWV724l+12VpgwuGM/k6MWurbK76HOR8mbAstdpagcTNBDD6W7bh1176rznUR2w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8570BC4CEEB; Tue, 22 Apr 2025 18:35:31 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.98) (envelope-from ) id 1u7IUl-0000000Fw9r-0G3p; Tue, 22 Apr 2025 14:37:23 -0400 Message-ID: <20250422183722.919601983@goodmis.org> User-Agent: quilt/0.68 Date: Tue, 22 Apr 2025 14:34:45 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Josh Poimboeuf , Jens Remus , x86@kernel.org, Peter Zijlstra , Ingo Molnar , Indu Bhagat , Andy Lutomirski , Thomas Gleixner , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Subject: [PATCH v5 6/6] x86/vdso: Enable sframe generation in VDSO References: <20250422183439.895236512@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Josh Poimboeuf Enable sframe generation in the VDSO library so kernel and user space can unwind through it. Signed-off-by: Josh Poimboeuf Signed-off-by: Steven Rostedt (Google) --- Changes since v4: https://lore.kernel.org/all/c93fbd53f01c2c86f747af27040ac= 11f16dee032.1737511963.git.jpoimboe@kernel.org/ - Changed #ifdef to include SFRAME config: #if defined(__x86_64__) && defined(CONFIG_AS_SFRAME) (Jens Remus) - Fixed Makefile to use "ifeq" and not "#ifdef" (Jens Remus) arch/Kconfig | 3 +++ arch/x86/entry/vdso/Makefile | 10 +++++++--- arch/x86/entry/vdso/vdso-layout.lds.S | 3 +++ arch/x86/include/asm/dwarf2.h | 5 ++++- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/arch/Kconfig b/arch/Kconfig index b0adb665041f..6e7d739e853b 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -435,6 +435,9 @@ config HAVE_HARDLOCKUP_DETECTOR_ARCH It uses the same command line parameters, and sysctl interface, as the generic hardlockup detectors. =20 +config AS_SFRAME + def_bool $(as-instr,.cfi_sections .sframe\n.cfi_startproc\n.cfi_endproc) + config HAVE_PERF_REGS bool help diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile index 54d3e9774d62..3bab770337b3 100644 --- a/arch/x86/entry/vdso/Makefile +++ b/arch/x86/entry/vdso/Makefile @@ -47,13 +47,17 @@ quiet_cmd_vdso2c =3D VDSO2C $@ $(obj)/vdso-image-%.c: $(obj)/vdso%.so.dbg $(obj)/vdso%.so $(obj)/vdso2c F= ORCE $(call if_changed,vdso2c) =20 +ifeq ($(CONFIG_AS_SFRAME),y) + SFRAME_CFLAGS :=3D -Wa$(comma)-gsframe +endif + # # Don't omit frame pointers for ease of userspace debugging, but do # optimize sibling calls. # CFL :=3D $(PROFILING) -mcmodel=3Dsmall -fPIC -O2 -fasynchronous-unwind-tab= les -m64 \ $(filter -g%,$(KBUILD_CFLAGS)) -fno-stack-protector \ - -fno-omit-frame-pointer -foptimize-sibling-calls \ + -fno-omit-frame-pointer $(SFRAME_CFLAGS) -foptimize-sibling-calls \ -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO =20 ifdef CONFIG_MITIGATION_RETPOLINE @@ -63,7 +67,7 @@ endif endif =20 $(vobjs): KBUILD_CFLAGS :=3D $(filter-out $(PADDING_CFLAGS) $(CC_FLAGS_LTO= ) $(CC_FLAGS_CFI) $(RANDSTRUCT_CFLAGS) $(GCC_PLUGINS_CFLAGS) $(RETPOLINE_CF= LAGS),$(KBUILD_CFLAGS)) $(CFL) -$(vobjs): KBUILD_AFLAGS +=3D -DBUILD_VDSO +$(vobjs): KBUILD_AFLAGS +=3D -DBUILD_VDSO $(SFRAME_CFLAGS) =20 # # vDSO code runs in userspace and -pg doesn't help with profiling anyway. @@ -104,7 +108,7 @@ $(obj)/%-x32.o: $(obj)/%.o FORCE =20 targets +=3D vdsox32.lds $(vobjx32s-y) =20 -$(obj)/%.so: OBJCOPYFLAGS :=3D -S --remove-section __ex_table +$(obj)/%.so: OBJCOPYFLAGS :=3D -g --remove-section __ex_table $(obj)/%.so: $(obj)/%.so.dbg FORCE $(call if_changed,objcopy) =20 diff --git a/arch/x86/entry/vdso/vdso-layout.lds.S b/arch/x86/entry/vdso/vd= so-layout.lds.S index 60747905de2b..24b92687597b 100644 --- a/arch/x86/entry/vdso/vdso-layout.lds.S +++ b/arch/x86/entry/vdso/vdso-layout.lds.S @@ -59,6 +59,7 @@ SECTIONS .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr .eh_frame : { KEEP (*(.eh_frame)) } :text =20 + .sframe : { *(.sframe) } :text :sframe =20 /* * Text is well-separated from actual data: there's plenty of @@ -87,6 +88,7 @@ SECTIONS * Very old versions of ld do not recognize this name token; use the const= ant. */ #define PT_GNU_EH_FRAME 0x6474e550 +#define PT_GNU_SFRAME 0x6474e554 =20 /* * We must supply the ELF program headers explicitly to get just one @@ -98,4 +100,5 @@ PHDRS dynamic PT_DYNAMIC FLAGS(4); /* PF_R */ note PT_NOTE FLAGS(4); /* PF_R */ eh_frame_hdr PT_GNU_EH_FRAME; + sframe PT_GNU_SFRAME; } diff --git a/arch/x86/include/asm/dwarf2.h b/arch/x86/include/asm/dwarf2.h index 65d958ef1178..ce294e6c9017 100644 --- a/arch/x86/include/asm/dwarf2.h +++ b/arch/x86/include/asm/dwarf2.h @@ -12,8 +12,11 @@ * For the vDSO, emit both runtime unwind information and debug * symbols for the .dbg file. */ - +#if defined(__x86_64__) && defined(CONFIG_AS_SFRAME) + .cfi_sections .eh_frame, .debug_frame, .sframe +#else .cfi_sections .eh_frame, .debug_frame +#endif =20 #define CFI_STARTPROC .cfi_startproc #define CFI_ENDPROC .cfi_endproc --=20 2.47.2