[PATCH 7.2 046/281] RISC-V: Clear HSTATUS.HU on CPU initialization

Miguel Ojeda ojeda at kernel.org
Tue Oct 13 06:05:51 PDT 2026


On Tue, 13 Oct 2026 13:36:02 +0200 Greg Kroah-Hartman <gregkh at linuxfoundation.org> wrote:
>
> 7.2-stable review patch.  If anyone has any objections, please let me know.
>
> ------------------
>
> From: Yong-Xuan Wang <yongxuan.wang at sifive.com>
>
> commit 6694612317e5225086e39ca1ba97ada2b1942e48 upstream.
>
> The RISC-V privileged specification does not mandate HSTATUS reset
> values, leaving the HU bit potentially set after hardware reset.
> When HU=1, hypervisor instructions (HLV/HLVX/HSV) can execute in
> U-mode to access guest memory, which may cause unintended behavior
> if not explicitly controlled.
>
> Clear HSTATUS.HU during CPU initialization to ensure hypervisor
> instructions are only available in HS-mode, preventing unexpected
> guest memory access from U-mode code.
>
> Signed-off-by: Yong-Xuan Wang <yongxuan.wang at sifive.com>
> Reviewed-by: Samuel Holland <samuel.holland at sifive.com>
> Link: https://patch.msgid.link/20260924-hstatus_hu-v2-1-7e970f5f1d8d@sifive.com
> Cc: stable at vger.kernel.org
> [pjw at kernel.org: capitalized RISCV_ISA_EXT_h to fix build; added stable cc]
> Signed-off-by: Paul Walmsley <pjw at kernel.org>
> Signed-off-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org>

For riscv64, I am seeing:

    arch/riscv/kernel/cpufeature.c:1189:36: error: use of undeclared identifier 'RISCV_ISA_EXT_H'
    1189 |         if (!riscv_has_extension_unlikely(RISCV_ISA_EXT_H))
         |                                           ^

It seems it is missing commit

  0c5a9ab5192b ("riscv: Standardize extension capitalization")

Either that or manually tweak the identifier to match 7.2.y.

6.18.y also breaks for the same reason.

I hope this helps!

Cc: Paul Walmsley <pjw at kernel.org>
Cc: Palmer Dabbelt <palmer at dabbelt.com>
Cc: Albert Ou <aou at eecs.berkeley.edu>
Cc: Alexandre Ghiti <alex at ghiti.fr>
Cc: linux-riscv at lists.infradead.org

Cheers,
Miguel



More information about the linux-riscv mailing list