[PATCH v3 08/19] unwind/x86: Enable CONFIG_HAVE_UNWIND_USER_FP

Josh Poimboeuf posted 19 patches 3 weeks, 6 days ago
[PATCH v3 08/19] unwind/x86: Enable CONFIG_HAVE_UNWIND_USER_FP
Posted by Josh Poimboeuf 3 weeks, 6 days ago
Use ARCH_INIT_USER_FP_FRAME to describe how frame pointers are unwound
on x86, and enable CONFIG_HAVE_UNWIND_USER_FP accordingly so the
unwind_user interfaces can be used.

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
 arch/x86/Kconfig                   |  1 +
 arch/x86/include/asm/unwind_user.h | 11 +++++++++++
 2 files changed, 12 insertions(+)
 create mode 100644 arch/x86/include/asm/unwind_user.h

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 0bdb7a394f59..f91098d6f535 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -289,6 +289,7 @@ config X86
 	select HAVE_SYSCALL_TRACEPOINTS
 	select HAVE_UACCESS_VALIDATION		if HAVE_OBJTOOL
 	select HAVE_UNSTABLE_SCHED_CLOCK
+	select HAVE_UNWIND_USER_FP		if X86_64
 	select HAVE_USER_RETURN_NOTIFIER
 	select HAVE_GENERIC_VDSO
 	select VDSO_GETRANDOM			if X86_64
diff --git a/arch/x86/include/asm/unwind_user.h b/arch/x86/include/asm/unwind_user.h
new file mode 100644
index 000000000000..19df26a65132
--- /dev/null
+++ b/arch/x86/include/asm/unwind_user.h
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_X86_UNWIND_USER_H
+#define _ASM_X86_UNWIND_USER_H
+
+#define ARCH_INIT_USER_FP_FRAME							\
+	.ra_off		= (s32)sizeof(long) * -1,				\
+	.cfa_off	= (s32)sizeof(long) * 2,				\
+	.fp_off		= (s32)sizeof(long) * -2,				\
+	.use_fp		= true,
+
+#endif /* _ASM_X86_UNWIND_USER_H */
-- 
2.47.0
Re: [PATCH v3 08/19] unwind/x86: Enable CONFIG_HAVE_UNWIND_USER_FP
Posted by Peter Zijlstra 3 weeks, 5 days ago
On Mon, Oct 28, 2024 at 02:47:35PM -0700, Josh Poimboeuf wrote:
> Use ARCH_INIT_USER_FP_FRAME to describe how frame pointers are unwound
> on x86, and enable CONFIG_HAVE_UNWIND_USER_FP accordingly so the
> unwind_user interfaces can be used.
> 
> Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
> ---
>  arch/x86/Kconfig                   |  1 +
>  arch/x86/include/asm/unwind_user.h | 11 +++++++++++
>  2 files changed, 12 insertions(+)
>  create mode 100644 arch/x86/include/asm/unwind_user.h
> 
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index 0bdb7a394f59..f91098d6f535 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -289,6 +289,7 @@ config X86
>  	select HAVE_SYSCALL_TRACEPOINTS
>  	select HAVE_UACCESS_VALIDATION		if HAVE_OBJTOOL
>  	select HAVE_UNSTABLE_SCHED_CLOCK
> +	select HAVE_UNWIND_USER_FP		if X86_64
>  	select HAVE_USER_RETURN_NOTIFIER
>  	select HAVE_GENERIC_VDSO
>  	select VDSO_GETRANDOM			if X86_64
> diff --git a/arch/x86/include/asm/unwind_user.h b/arch/x86/include/asm/unwind_user.h
> new file mode 100644
> index 000000000000..19df26a65132
> --- /dev/null
> +++ b/arch/x86/include/asm/unwind_user.h
> @@ -0,0 +1,11 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef _ASM_X86_UNWIND_USER_H
> +#define _ASM_X86_UNWIND_USER_H
> +
> +#define ARCH_INIT_USER_FP_FRAME							\
> +	.ra_off		= (s32)sizeof(long) * -1,				\
> +	.cfa_off	= (s32)sizeof(long) * 2,				\
> +	.fp_off		= (s32)sizeof(long) * -2,				\
> +	.use_fp		= true,
> +
> +#endif /* _ASM_X86_UNWIND_USER_H */

What about compat / 32bit userspace?
Re: [PATCH v3 08/19] unwind/x86: Enable CONFIG_HAVE_UNWIND_USER_FP
Posted by Josh Poimboeuf 3 weeks, 5 days ago
On Tue, Oct 29, 2024 at 02:13:03PM +0100, Peter Zijlstra wrote:
> On Mon, Oct 28, 2024 at 02:47:35PM -0700, Josh Poimboeuf wrote:
> > Use ARCH_INIT_USER_FP_FRAME to describe how frame pointers are unwound
> > on x86, and enable CONFIG_HAVE_UNWIND_USER_FP accordingly so the
> > unwind_user interfaces can be used.
> > 
> > Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
> > ---
> >  arch/x86/Kconfig                   |  1 +
> >  arch/x86/include/asm/unwind_user.h | 11 +++++++++++
> >  2 files changed, 12 insertions(+)
> >  create mode 100644 arch/x86/include/asm/unwind_user.h
> > 
> > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> > index 0bdb7a394f59..f91098d6f535 100644
> > --- a/arch/x86/Kconfig
> > +++ b/arch/x86/Kconfig
> > @@ -289,6 +289,7 @@ config X86
> >  	select HAVE_SYSCALL_TRACEPOINTS
> >  	select HAVE_UACCESS_VALIDATION		if HAVE_OBJTOOL
> >  	select HAVE_UNSTABLE_SCHED_CLOCK
> > +	select HAVE_UNWIND_USER_FP		if X86_64
> >  	select HAVE_USER_RETURN_NOTIFIER
> >  	select HAVE_GENERIC_VDSO
> >  	select VDSO_GETRANDOM			if X86_64
> > diff --git a/arch/x86/include/asm/unwind_user.h b/arch/x86/include/asm/unwind_user.h
> > new file mode 100644
> > index 000000000000..19df26a65132
> > --- /dev/null
> > +++ b/arch/x86/include/asm/unwind_user.h
> > @@ -0,0 +1,11 @@
> > +/* SPDX-License-Identifier: GPL-2.0 */
> > +#ifndef _ASM_X86_UNWIND_USER_H
> > +#define _ASM_X86_UNWIND_USER_H
> > +
> > +#define ARCH_INIT_USER_FP_FRAME							\
> > +	.ra_off		= (s32)sizeof(long) * -1,				\
> > +	.cfa_off	= (s32)sizeof(long) * 2,				\
> > +	.fp_off		= (s32)sizeof(long) * -2,				\
> > +	.use_fp		= true,
> > +
> > +#endif /* _ASM_X86_UNWIND_USER_H */
> 
> What about compat / 32bit userspace?

Sframe doesn't support 32-bit binaries at the moment.  Does anybody
actually care?

You're right this regresses existing perf behavior for the frame pointer
case.  I'll try to fix that.

-- 
Josh
Re: [PATCH v3 08/19] unwind/x86: Enable CONFIG_HAVE_UNWIND_USER_FP
Posted by Peter Zijlstra 3 weeks, 5 days ago
On Tue, Oct 29, 2024 at 09:31:10AM -0700, Josh Poimboeuf wrote:
> On Tue, Oct 29, 2024 at 02:13:03PM +0100, Peter Zijlstra wrote:

> > > +#define ARCH_INIT_USER_FP_FRAME							\
> > > +	.ra_off		= (s32)sizeof(long) * -1,				\
> > > +	.cfa_off	= (s32)sizeof(long) * 2,				\
> > > +	.fp_off		= (s32)sizeof(long) * -2,				\
> > > +	.use_fp		= true,
> > > +
> > > +#endif /* _ASM_X86_UNWIND_USER_H */
> > 
> > What about compat / 32bit userspace?
> 
> Sframe doesn't support 32-bit binaries at the moment.  Does anybody
> actually care?

Dunno, I think the only 32bit code I've recently ran is in selftests and
wine32 -- because Monkey Island rules :-)

> You're right this regresses existing perf behavior for the frame pointer
> case.  I'll try to fix that.

Thanks, this patch is the frame pointer unwinder, that really should do
32bit.