From: sashiko-bot@kernel.org
To: "Inochi Amaoto" <inochiama@gmail.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v6 3/8] RISC-V: KVM: Allow Zicfiss/Zicfilp extensions for Guest/VM
Date: Mon, 13 Jul 2026 01:17:28 +0000 [thread overview]
Message-ID: <20260713011728.852BF1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260713010302.303278-4-inochiama@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Missing context switch logic and ONE_REG state management for the unbanked `CSR_SSP` register (Zicfiss).
- [High] Missing hardware enablement for Zicfiss (`ENVCFG_SSE`) and Zicfilp (`ENVCFG_LPE`) in the hypervisor's `henvcfg` register.
--
--- Patch [3]: [PATCH v6 3/8] RISC-V: KVM: Allow Zicfiss/Zicfilp extensions for Guest/VM ---
commit e9ffdcbcaf04d693405f356426ae62f60a2aa04c
Author: Inochi Amaoto <inochiama@gmail.com>
RISC-V: KVM: Allow Zicfiss/Zicfilp extensions for Guest/VM
This commit extends the KVM ISA extension array to allow userspace to detect
and enable the Zicfiss and Zicfilp extensions for the guest VM.
> diff --git a/arch/riscv/include/uapi/asm/kvm.h b/arch/riscv/include/uapi/asm/kvm.h
> index 7bbea8812d927..a27de850fa4cc 100644
> --- a/arch/riscv/include/uapi/asm/kvm.h
> +++ b/arch/riscv/include/uapi/asm/kvm.h
[ ... ]
> @@ -199,6 +199,8 @@ enum KVM_RISCV_ISA_EXT_ID {
> KVM_RISCV_ISA_EXT_ZCLSD,
> KVM_RISCV_ISA_EXT_ZILSD,
> KVM_RISCV_ISA_EXT_ZALASR,
> + KVM_RISCV_ISA_EXT_ZICFILP,
> + KVM_RISCV_ISA_EXT_ZICFISS,
> KVM_RISCV_ISA_EXT_MAX,
> };
>
> diff --git a/arch/riscv/kvm/isa.c b/arch/riscv/kvm/isa.c
> index 1132d909cc25c..9852a91fdecc9 100644
> --- a/arch/riscv/kvm/isa.c
> +++ b/arch/riscv/kvm/isa.c
[ ... ]
> @@ -65,6 +65,8 @@ static const unsigned long kvm_isa_ext_arr[] = {
> KVM_ISA_EXT_ARR(ZICBOP),
> KVM_ISA_EXT_ARR(ZICBOZ),
> KVM_ISA_EXT_ARR(ZICCRSE),
> + KVM_ISA_EXT_ARR(ZICFILP),
[Severity: High]
Is hardware enablement for Zicfiss and Zicfilp missing in the hypervisor's
henvcfg register?
KVM populates cfg->henvcfg based on enabled ISA extensions here:
arch/riscv/kvm/vcpu_config.c:kvm_riscv_vcpu_config_ran_once() {
...
if (riscv_isa_extension_available(isa, ZICBOM))
cfg->henvcfg |= (ENVCFG_CBIE | ENVCFG_CBCFE);
...
}
If ENVCFG_SSE and ENVCFG_LPE are not delegated to henvcfg, will the guest
kernel's attempts to set senvcfg.SSE and senvcfg.LPE silently fail?
This would leave the fields read-only zero in the guest, preventing the
advertised CFI extensions from being used.
> + KVM_ISA_EXT_ARR(ZICFISS),
[Severity: High]
Will the guest's CSR_SSP register be corrupted when context switching?
When a guest with Zicfiss enabled sets a valid shadow stack pointer in
CSR_SSP, and a VM exit occurs, the host scheduler may preempt the KVM vCPU
thread.
The host's exception return path overwrites CSR_SSP for the new process, and
upon switching back, the host's exception entry path zeroes CSR_SSP.
Since the C-level CSR context switch logic in
kvm_riscv_vcpu_swap_in_guest_state() and the assembly path in
__kvm_riscv_switch_to() lack save/restore operations for CSR_SSP:
arch/riscv/kvm/vcpu_switch.S:__kvm_riscv_switch_to() {
...
SAVE_HOST_AND_RESTORE_GUEST_CSRS .Lkvm_switch_return
...
SAVE_GUEST_AND_RESTORE_HOST_CSRS
...
}
Does this cause the guest to resume with a zeroed CSR_SSP and crash on its
next CFI instruction? Should CSR_SSP also be exposed via the ONE_REG
interface for state management?
> KVM_ISA_EXT_ARR(ZICNTR),
> KVM_ISA_EXT_ARR(ZICOND),
> KVM_ISA_EXT_ARR(ZICSR),
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260713010302.303278-1-inochiama@gmail.com?part=3
next prev parent reply other threads:[~2026-07-13 1:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-13 1:02 [PATCH v6 0/8] RISC-V: KVM: Add Svadu/Zicfiss/Zicfilp FWFT support Inochi Amaoto
2026-07-13 1:02 ` [PATCH v6 1/8] RISC-V: KVM: Add support for Svadu FWFT features Inochi Amaoto
2026-07-13 1:02 ` [PATCH v6 2/8] KVM: riscv: selftests: add Svadu FWFT extension to get-reg-list test Inochi Amaoto
2026-07-13 1:02 ` [PATCH v6 3/8] RISC-V: KVM: Allow Zicfiss/Zicfilp extensions for Guest/VM Inochi Amaoto
2026-07-13 1:17 ` sashiko-bot [this message]
2026-07-13 1:02 ` [PATCH v6 4/8] RISC-V: KVM: Add ssp context save/restore Inochi Amaoto
2026-07-13 1:20 ` sashiko-bot
2026-07-13 1:02 ` [PATCH v6 5/8] RISC-V: KVM: Handle software-check exits for VCPU Inochi Amaoto
2026-07-13 1:02 ` [PATCH v6 6/8] RISC-V: KVM: Delegate SPELP bit to VS/VU mode if landing pad is enabled Inochi Amaoto
2026-07-13 1:17 ` sashiko-bot
2026-07-13 1:03 ` [PATCH v6 7/8] RISC-V: KVM: Add support for control-flow integrity FWFT features Inochi Amaoto
2026-07-13 1:03 ` [PATCH v6 8/8] KVM: riscv: selftests: add Zicfiss/Zicfilp extension to get-reg-list test Inochi Amaoto
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260713011728.852BF1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=inochiama@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox