Re: [patch V2 05/20] x86/extable: Rework the exception table mechanics

From: Alexei Starovoitov
Date: Tue Sep 07 2021 - 16:22:27 EST


On Tue, Sep 07, 2021 at 09:56:20PM +0200, Thomas Gleixner wrote:
> The exception table entries contain the instruction address, the fixup
> address and the handler address. All addresses are relative. Storing the
> handler address has a few downsides:
>
> 1) Most handlers need to be exported
>
> 2) Handlers can be defined everywhere and there is no overview about the
> handler types
>
> 3) MCE needs to check the handler type to decide whether an in kernel #MC
> can be recovered. The functionality of the handler itself is not in any
> way special, but for these checks there need to be separate functions
> which in the worst case have to be exported.
>
> Some of these 'recoverable' exception fixups are pretty obscure and
> just reuse some other handler to spare code. That obfuscates e.g. the
> #MC safe copy functions. Cleaning that up would require more handlers
> and exports
>
> Rework the exception fixup mechanics by storing a fixup type number instead
> of the handler address and invoke the proper handler for each fixup
> type. Also teach the extable sort to leave the type field alone.
>
> This makes most handlers static except for special cases like the MCE
> MSR fixup and the BPF fixup. This allows to add more types for cleaning up
> the obscure places without adding more handler code and exports.
>
> There is a marginal code size reduction for a production config and it
> removes _eight_ exported symbols.
>
> Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> Cc: Tony Luck <tony.luck@xxxxxxxxx>
> Cc: Song Liu <songliubraving@xxxxxx>
> Cc: Alexei Starovoitov <ast@xxxxxxxxxx>
> Cc: Daniel Borkmann <daniel@xxxxxxxxxxxxx>

bpf bits look good to me.
Acked-by: Alexei Starovoitov <ast@xxxxxxxxxx>