Re: [PATCH] x86/fpu/xstate: Fix XSTATE_WARN_ON() to emit relevant diagnostics

From: Borislav Petkov
Date: Wed Sep 28 2022 - 12:28:08 EST


On Wed, Aug 10, 2022 at 11:19:09PM +0100, Andrew Cooper wrote:
> "XSAVE consistency problem" has been reported under Xen, but that's the extent
> of my divination skills.
>
> Modify XSTATE_WARN_ON() to force the caller to provide relevant diagnostic
> information, and modify each caller suitably.
>
> For check_xstate_against_struct(), this removes a double WARN() where one will
> do perfectly fine.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> ---
> CC: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> CC: Ingo Molnar <mingo@xxxxxxxxxx>
> CC: Borislav Petkov <bp@xxxxxxxxx>
> CC: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
> CC: x86@xxxxxxxxxx
> CC: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
>
> RFC: CC stable? This has been wonky debugging for 7 years.
>
> Apparently "size 832 != kernel_size 0" so let the debugging continue...

I've got a similar bug report from people running Linux guest on some
other prop. HV. And I wanted to give them a debugging patch which dumps
*all* the relevant data along the path of paranoid_xstate_size_valid(),
the loop in there and xstate_calculate_size().

Looking how you might need something like that too, how about you extend
your patch to do that and have it being toggled on by a xstate=debug
cmdline?

It feels like this would be a useful thing to have with the gazillion of
XSTATE features and dynamic buffer allocation...

Thx.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette