Re: [patch V4 part 3 13/29] x86/traps: Prepare for using DEFINE_IDTENTRY

Andy Lutomirski
2020-05-14T04:37:25Z

On Tue, May 5, 2020 at 7:15 AM Thomas Gleixner <tglx@linutronix.de> wrote:
>
> From: Thomas Gleixner <tglx@linutronix.de>
>
> Prepare for using IDTENTRY to define the C exception/trap entry points. It
> would be possible to glue this into the existing macro maze, but it's
> simpler and better to read at the end to just make them distinct. Provide
> a trivial inline helper to read the trap address.
>
> The existing macros will be removed once all instances are converted.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Reviewed-by: Alexandre Chartre <alexandre.chartre@oracle.com>
>
> ---
> arch/x86/kernel/traps.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> --- a/arch/x86/kernel/traps.c
> +++ b/arch/x86/kernel/traps.c
> @@ -205,6 +205,11 @@ static void do_error_trap(struct pt_regs
> }
> }
>
> +static __always_inline void __user *error_get_trap_addr(struct pt_regs *regs)
> +{
> + return (void __user *)uprobe_get_trap_addr(regs);
> +}

My mind boggles. WTF is this?

Perhaps this should have a comment like:

/*
* Returns the address from which a user trap originated. This would
be the same as regs->ip,
* except for frhgnieawfn nvlrkvklsrvs and mfkealwf, and this lets the
thingummy pass a
* modified value to the signal frame, but only for #DE and #UD,
because #*!&@&#@.
*/

except with the blanks filled in.

After reading a bit of uprobe code, I assume this is a fixup for when
we're running code that got moved out of line because it got replaced
by a breakpoint. I'm still mystified by why it only seems to apply to
#DE and #UD.