Re: [PATCH v4 1/2] x86/mce: Check for writes ignored in MCA_STATUS register

Borislav Petkov
2022-05-03T21:14:17Z

On Mon, May 02, 2022 at 08:28:47PM -0700, Smita Koralahalli wrote:
> I'm bit more inclined towards your previous approach of
> hw_injection_possible
> check in do_inject(). This seems better than doing it in flags_write().

If you don't do it in flags_write() then the user would do

echo "hw" > flags

the command will succeed and the user will think that hw injection is
possible and then wonder why it fails later.

I even actually think that in the first run, when hw_injection_possible
is not determined yet, you should try to poke at MCi_STATUS of some
non-reserved bank - and we enumerate which those are at boot in
__mcheck_cpu_check_banks(), so you can pick a random, non-RAZ bank, save
its MCi_STATUS, try to write it and if it succeeds, restore it.

This way you'll determine whether hw injection is possible, store it
in the static hw_injection_possible and then query only that variable.
I.e., you'll have to poke that MCi_STATUS only once on driver init. And
this way it'll be the most optimal, methinks.

Thx.

--
Regards/Gruss,
Boris.