Re: [PATCH v3 2/4] x86/traps: Print non-canonical address on #GP
From: Ingo Molnar
Date: Wed Nov 20 2019 - 07:31:05 EST
* Jann Horn <jannh@xxxxxxxxxx> wrote:
> You mean something like this?
>
> ========================
> diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
> index 9b23c4bda243..16a6bdaccb51 100644
> --- a/arch/x86/kernel/traps.c
> +++ b/arch/x86/kernel/traps.c
> @@ -516,32 +516,36 @@ dotraplinkage void do_bounds(struct pt_regs
> *regs, long error_code)
> * On 64-bit, if an uncaught #GP occurs while dereferencing a non-canonical
> * address, return that address.
> */
> -static unsigned long get_kernel_gp_address(struct pt_regs *regs)
> +static bool get_kernel_gp_address(struct pt_regs *regs, unsigned long *addr,
> + bool *non_canonical)
Yeah, that's pretty much the perfect end result!
> I guess that could potentially be useful if a #GP is triggered by
> something like an SSE alignment error? I'll add it in unless someone
> else complains.
Yeah - also it's correct information about the context of the fault, so
it probably cannot *hurt*, and will allow us to debug/validate everything
in this area faster.
> > > +#define GPFSTR "general protection fault"
> > > dotraplinkage void
> >
> > Please separate macro and function definitions by an additional newline.
>
> Will change it.
Thanks!
Ingo