Re: [PATCH v3 1/3] riscv: hwprobe: initialize pair->value in hwprobe_one_pair()
Jesse Taube <[email protected]> Wed, 5 Aug 2026 12:56:48 -0400
| Newsgroups | org.infradead.lists.linux-riscv |
|---|---|
| Message-ID | <CADRr4bft5RDmZYjeWN2m7y0O6iF2WS5ZbJXhdKhKV5NTyPL3NA@mail.gmail.com> |
On Fri, Jul 24, 2026 at 9:14 PM Andy Chiu <[email protected]> wrote: > > The vendor-extension handlers reached from hwprobe_one_pair() > (hwprobe_isa_vendor_ext_thead_0() and friends) only OR the present bits > into pair->value via VENDOR_EXTENSION_SUPPORTED() and clear their own > missing bits; they assume the caller has already zeroed pair->value. > > That holds for hwprobe_get_values() (it zeroes each pair) and > hwprobe_get_cpus() (it re-initializes its scratch pair per key), but not > for complete_hwprobe_vdso_data(), which reuses a single pair across all > keys For loop moment LOL > without re-zeroing. A vendor key therefore inherits stale bits from > the previously probed key, and the wrong value is cached in the vDSO > all_cpu_hwprobe_values[] and handed to userspace on the fast patih. > > Zero pair->value once at the top of hwprobe_one_pair() so every handler > starts from a clean value regardless of the caller, and drop the now > redundant zeroing in the *_BLOCK_SIZE cases. hwprobe_isa_ext0() keeps its > own zeroing because hwprobe_ext0_has() calls it directly, bypassing > hwprobe_one_pair(). > > Fixes: a5ea53da65c5 ("riscv: hwprobe: Add thead vendor extension probing") > Signed-off-by: Andy Chiu <[email protected]> Reviewed-by: Jesse Taube <[email protected]> > --- > Changelog v3: > - new patch since v3 > --- > arch/riscv/kernel/sys_hwprobe.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/arch/riscv/kernel/sys_hwprobe.c b/arch/riscv/kernel/sys_hwprobe.c > index caf6762427c8..d2bb70fed8b9 100644 > --- a/arch/riscv/kernel/sys_hwprobe.c > +++ b/arch/riscv/kernel/sys_hwprobe.c > @@ -295,6 +295,8 @@ static u64 hwprobe_vec_misaligned(const struct cpumask *cpus) > static void hwprobe_one_pair(struct riscv_hwprobe *pair, > const struct cpumask *cpus) > { > + pair->value = 0; > + > switch (pair->key) { > case RISCV_HWPROBE_KEY_MVENDORID: > case RISCV_HWPROBE_KEY_MARCHID: > @@ -329,17 +331,14 @@ static void hwprobe_one_pair(struct riscv_hwprobe *pair, > break; > > case RISCV_HWPROBE_KEY_ZICBOZ_BLOCK_SIZE: > - pair->value = 0; > if (hwprobe_ext0_has(cpus, RISCV_HWPROBE_EXT_ZICBOZ)) > pair->value = riscv_cboz_block_size; > break; > case RISCV_HWPROBE_KEY_ZICBOM_BLOCK_SIZE: > - pair->value = 0; > if (hwprobe_ext0_has(cpus, RISCV_HWPROBE_EXT_ZICBOM)) > pair->value = riscv_cbom_block_size; > break; > case RISCV_HWPROBE_KEY_ZICBOP_BLOCK_SIZE: > - pair->value = 0; > if (hwprobe_ext0_has(cpus, RISCV_HWPROBE_EXT_ZICBOP)) > pair->value = riscv_cbop_block_size; > break; > -- > 2.43.0 > > > _______________________________________________ > linux-riscv mailing list > [email protected] > http://lists.infradead.org/mailman/listinfo/linux-riscv > _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv