Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [Critical] The mitigation for HSTATUS.HU is placed in KVM initialization, leaving systems vulnerable if KVM is not loaded.
--
--- Patch [1]: [PATCH] KVM: RISC-V: Clear HSTATUS.HU on hypervisor initialization ---
commit 57c0e5888211429befb42a79f59ff40cc9adf07a
Author: Yong-Xuan Wang <[email protected]>
KVM: RISC-V: Clear HSTATUS.HU on hypervisor initialization
This commit clears the HSTATUS.HU bit during KVM initialization. This
prevents U-mode code from executing hypervisor instructions (HLV/HLVX/HSV)
to access memory, as the RISC-V specification does not mandate a reset
value for this bit.
> diff --git a/arch/riscv/kvm/main.c b/arch/riscv/kvm/main.c
> index 85e772588fad6..e80a99e93d569 100644
> --- a/arch/riscv/kvm/main.c
> +++ b/arch/riscv/kvm/main.c
> @@ -47,6 +47,9 @@ static void kvm_riscv_csr_init(void)
> csr_write(CSR_HCOUNTEREN, 0x02);
>
> csr_write(CSR_HVIP, 0);
> +
> + /* clear HSTATUS.HU */
> + csr_clear(CSR_HSTATUS, HSTATUS_HU);
[Severity: Critical]
This is a pre-existing issue, but does placing this mitigation in
kvm_riscv_csr_init() leave the host vulnerable if the KVM module is never
loaded?
If the hardware or firmware leaves HSTATUS.HU=1 after reset, and KVM is
not initialized, could an unprivileged user-space (U-mode) process execute
hypervisor memory-management instructions (HLV/HSV)?
Since guest translation registers might remain in an uninitialized (Bare)
state, this might allow direct read/write access to host physical memory.
Should HSTATUS.HU be sanitized unconditionally during early core
architecture setup (e.g., in arch/riscv/kernel/setup.c) instead of only
when KVM is active?
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.