[PATCH v3 02/19] x86/asm: Avoid emitting DWARF CFI for non-VDSO

Josh Poimboeuf posted 19 patches 3 weeks, 6 days ago
[PATCH v3 02/19] x86/asm: Avoid emitting DWARF CFI for non-VDSO
Posted by Josh Poimboeuf 3 weeks, 6 days ago
VDSO is the only part of the "kernel" using DWARF CFI directives.  For
the kernel proper, ensure the CFI_* macros don't do anything.

These macros aren't yet being used outside of VDSO, so there's no
functional change.

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
 arch/x86/include/asm/dwarf2.h | 37 +++++++++++++++++++++++++++--------
 1 file changed, 29 insertions(+), 8 deletions(-)

diff --git a/arch/x86/include/asm/dwarf2.h b/arch/x86/include/asm/dwarf2.h
index 430fca13bb56..b1aa3fcd5bca 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
 
+#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,7 +30,8 @@
 #define CFI_UNDEFINED		.cfi_undefined
 #define CFI_ESCAPE		.cfi_escape
 
-#ifndef BUILD_VDSO
+#else /* !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
@@ -29,13 +39,24 @@
 	 * 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
+
+#define CFI_STARTPROC
+#define CFI_ENDPROC
+#define CFI_DEF_CFA
+#define CFI_DEF_CFA_REGISTER
+#define CFI_DEF_CFA_OFFSET
+#define CFI_ADJUST_CFA_OFFSET
+#define CFI_OFFSET
+#define CFI_REL_OFFSET
+#define CFI_REGISTER
+#define CFI_RESTORE
+#define CFI_REMEMBER_STATE
+#define CFI_RESTORE_STATE
+#define CFI_UNDEFINED
+#define CFI_ESCAPE
+
+#endif /* !BUILD_VDSO */
 
 #endif /* _ASM_X86_DWARF2_H */
-- 
2.47.0
Re: [PATCH v3 02/19] x86/asm: Avoid emitting DWARF CFI for non-VDSO
Posted by Jens Remus 3 weeks, 4 days ago
On 28.10.2024 22:47, Josh Poimboeuf wrote:
> VDSO is the only part of the "kernel" using DWARF CFI directives.  For
> the kernel proper, ensure the CFI_* macros don't do anything.
> 
> These macros aren't yet being used outside of VDSO, so there's no
> functional change.

...

> diff --git a/arch/x86/include/asm/dwarf2.h b/arch/x86/include/asm/dwarf2.h
> index 430fca13bb56..b1aa3fcd5bca 100644
> --- a/arch/x86/include/asm/dwarf2.h
> +++ b/arch/x86/include/asm/dwarf2.h
...
> @@ -29,13 +39,24 @@
>   	 * 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
> +
> +#define CFI_STARTPROC
> +#define CFI_ENDPROC
> +#define CFI_DEF_CFA
> +#define CFI_DEF_CFA_REGISTER
> +#define CFI_DEF_CFA_OFFSET
> +#define CFI_ADJUST_CFA_OFFSET
> +#define CFI_OFFSET
> +#define CFI_REL_OFFSET
> +#define CFI_REGISTER
> +#define CFI_RESTORE
> +#define CFI_REMEMBER_STATE
> +#define CFI_RESTORE_STATE
> +#define CFI_UNDEFINED
> +#define CFI_ESCAPE

Don't all of the above need to be defined to "#", so that they change 
any parameters into an assembler comment? For example:

#define CFI_STARTPROC		#

> +
> +#endif /* !BUILD_VDSO */
>   
>   #endif /* _ASM_X86_DWARF2_H */

Thanks and regards,
Jens
-- 
Jens Remus
Linux on Z Development (D3303) and z/VSE Support
+49-7031-16-1128 Office
jremus@de.ibm.com

IBM

IBM Deutschland Research & Development GmbH; Vorsitzender des 
Aufsichtsrats: Wolfgang Wendt; Geschäftsführung: David Faller; Sitz der 
Gesellschaft: Böblingen; Registergericht: Amtsgericht Stuttgart, HRB 243294
IBM Data Privacy Statement: https://www.ibm.com/privacy/

Re: [PATCH v3 02/19] x86/asm: Avoid emitting DWARF CFI for non-VDSO
Posted by Josh Poimboeuf 3 weeks, 4 days ago
On Wed, Oct 30, 2024 at 06:19:43PM +0100, Jens Remus wrote:
> > +#define CFI_STARTPROC
> > +#define CFI_ENDPROC
> > +#define CFI_DEF_CFA
> > +#define CFI_DEF_CFA_REGISTER
> > +#define CFI_DEF_CFA_OFFSET
> > +#define CFI_ADJUST_CFA_OFFSET
> > +#define CFI_OFFSET
> > +#define CFI_REL_OFFSET
> > +#define CFI_REGISTER
> > +#define CFI_RESTORE
> > +#define CFI_REMEMBER_STATE
> > +#define CFI_RESTORE_STATE
> > +#define CFI_UNDEFINED
> > +#define CFI_ESCAPE
> 
> Don't all of the above need to be defined to "#", so that they change any
> parameters into an assembler comment? For example:
> 
> #define CFI_STARTPROC		#

Indeed.  Or maybe they could be .macros which ignore the arguments.

-- 
Josh