RE: [PATCH v2 08/10] x86/mce: Remove the redundant zeroing assignments
From: Zhuo, Qiuxu
Date: Sat Oct 19 2024 - 03:37:23 EST
> From: Mehta, Sohil <sohil.mehta@xxxxxxxxx>
> [...]
> > @@ -1284,8 +1282,6 @@ __mc_scan_banks(struct mce *m, struct pt_regs
> *regs, struct mce *final,
> > if (!mce_banks[i].ctl)
> > continue;
> >
> > - m->misc = 0;
> > - m->addr = 0;
> > m->bank = i;
> >
>
> However, in this case, I am not fully convinced if the misc and addr would
> already be 0 when we reach here.
>
> There are potentially a lot of things that happen in do_machine_check()
> between mce_gather_info() and __mc_scan_banks(). Especially,
> mce_no_way_out() which could theoretically call mce_read_aux() in some
> cases.
>
> Maybe it doesn't matter, misc and addr would be overwritten anyway. But I
> feel some more details in the commit message would be useful. It doesn't
> seem as simple as the brief description makes it sound (at least to me).
>
Your concern is reasonable. Thanks!
For both diffs, mce->misc and mce->addr can be guaranteed to be zeroed the first time
they reach here. However, I didn't notice that both diffs were in a for() loop where
mce->misc and mce->addr could retain the old values assigned by mce_read_aux() in
the previous iteration. So need to zero mce-misc and mce->addr in each iteration to
ensure they don't contain stale values.
I'll drop this patch in the next version.
-Qiuxu