Re: [PATCH v3 5/8] sframe: Allow unsorted FDEs.

Jens Remus
2026-04-16T14:58:16Z

On 4/6/2026 8:49 PM, Dylan Hatch wrote:
> The .sframe in kernel modules is built without SFRAME_F_FDE_SORTED set.
> In order to allow sframe PC lookup in modules, add a code path to handle
> unsorted FDE tables by doing a simple linear search.
>
> Signed-off-by: Dylan Hatch <dylanbhatch@google.com>

With my below two minor comments considered:

Reviewed-by: Jens Remus <jremus@linux.ibm.com>

> diff --git a/include/linux/sframe.h b/include/linux/sframe.h

> @@ -64,6 +64,7 @@ struct sframe_section {
> unsigned long text_start;
> unsigned long text_end;
>
> + bool fdes_sorted;
> unsigned long fdes_start;
> unsigned long fres_start;
> unsigned long fres_end;

The struct would be smaller if the bool fdes_sorted flag would be
inserted after the unsigned int num_fdes field:

$ pahole -C sframe_section kernel/unwind/sframe.o

Yours:
size: 96

With bool fdes_sorted moved after unsigned int num_fdes:
size: 88

> diff --git a/kernel/unwind/sframe.c b/kernel/unwind/sframe.c

> @@ -179,9 +179,34 @@ static __always_inline int __read_fde(struct sframe_section *sec,
> return -EFAULT;
> }
>
> -static __always_inline int __find_fde(struct sframe_section *sec,
> - unsigned long ip,
> - struct sframe_fde_internal *fde)
> +static __always_inline int __find_fde_unsorted(struct sframe_section *sec,
> + unsigned long ip,
> + struct sframe_fde_internal *fde)
> +{
> + struct sframe_fde_v3 *cur, *start, *end;
> +
> + start = (struct sframe_fde_v3 *)sec->fdes_start;
> + end = start + sec->num_fdes;
> +
> + for (cur = start; cur < end; cur++) {
> + s64 func_off;
> + u32 func_size;
> + unsigned long func_addr;
> +
> + DATA_GET(sec, func_off, &cur->func_start_off, s64, Efault);
> + DATA_GET(sec, func_size, &cur->func_size, u32, Efault);
> + func_addr = (unsigned long)cur + func_off;
> +
> + if (ip >= func_addr && ip < func_addr + func_size)
> + return __read_fde(sec, cur - start, fde);
> + }

__find_fde() (now __find_fde_sorted()) returns -EINVAL, if no FDE is found:

return -EINVAL;

> +Efault:
> + return -EFAULT;
> +}
Regards,
Jens
--
Jens Remus
Linux on Z Development (D3303)
jremus@de.ibm.com / jremus@linux.ibm.com

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