All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Inochi Amaoto" <inochiama@gmail.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v3 1/4] RISC-V: KVM: Add SBI extension validate callback
Date: Wed, 29 Jul 2026 23:39:11 +0000	[thread overview]
Message-ID: <20260729233912.347AE1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260729232527.139183-2-inochiama@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The validate callback is skipped for disabled extensions, defeating its stated purpose of cleaning up state.
- [High] The FWFT extension completely lacks the implementation of the new validate callback.
--

--- Patch [1]: [PATCH v3 1/4] RISC-V: KVM: Add SBI extension validate callback ---
commit 3b3c6bd10bd24fef09cd0cfc1f43717873d6c992
Author: Inochi Amaoto <inochiama@gmail.com>

RISC-V: KVM: Add SBI extension validate callback

This commit adds a generic SBI extension validate callback to allow extensions
to correct their parameters before the first run. It is specifically intended
to fix an issue where vCPU state remains broken if the FWFT extension is
disabled after its features have been configured.

> Add the generic SBI extension validate callback so the FWFT
> extension can fix its parameters before the first run.

[Severity: High]
Is the actual implementation of the validate callback for the FWFT extension 
missing from this patch? 

The generic framework is added here, but the validate function pointer 
assignment for vcpu_sbi_ext_fwft in arch/riscv/kvm/vcpu_sbi_fwft.c appears 
to be absent. 

Without implementing this callback in the FWFT extension itself, the 
parameters will not actually be fixed when the extension is disabled.

> diff --git a/arch/riscv/kvm/vcpu_sbi.c b/arch/riscv/kvm/vcpu_sbi.c
> index 46ab7b989432b..b737e9a7a12a2 100644
> --- a/arch/riscv/kvm/vcpu_sbi.c
> +++ b/arch/riscv/kvm/vcpu_sbi.c

[ ... ]

> @@ -723,3 +723,26 @@ void kvm_riscv_vcpu_sbi_reset(struct kvm_vcpu *vcpu)
>  		ext->reset(vcpu);
>  	}
>  }
> +
> +void kvm_riscv_vcpu_sbi_validate(struct kvm_vcpu *vcpu)
> +{
> +	struct kvm_vcpu_sbi_context *scontext = &vcpu->arch.sbi_context;
> +	const struct kvm_riscv_sbi_extension_entry *entry;
> +	const struct kvm_vcpu_sbi_extension *ext;
> +	int idx, i;
> +
> +	for (i = 0; i < ARRAY_SIZE(sbi_ext); i++) {
> +		entry = &sbi_ext[i];
> +		ext = entry->ext_ptr;
> +		idx = entry->ext_idx;
> +
> +		if (idx < 0 || idx >= ARRAY_SIZE(scontext->ext_status))
> +			continue;
> +
> +		if (scontext->ext_status[idx] != KVM_RISCV_SBI_EXT_STATUS_ENABLED ||
> +		    !ext->validate)
> +			continue;

[Severity: High]
Will this condition prevent disabled extensions from cleaning up their state?

The commit message notes this callback is needed to fix the vCPU state when a 
user disables the FWFT extension after setting a value. 

However, kvm_riscv_vcpu_sbi_validate() explicitly skips extensions unless 
their status is KVM_RISCV_SBI_EXT_STATUS_ENABLED. 

Does this mean a disabled extension will not have its validate callback 
invoked at all, leaving the vCPU in an inconsistent state?

> +
> +		ext->validate(vcpu);
> +	}
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260729232527.139183-1-inochiama@gmail.com?part=1

  reply	other threads:[~2026-07-29 23:39 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-29 23:25 [PATCH v3 0/4] RISC-V: KVM: Cleanup SBI extension status when disable Inochi Amaoto
2026-07-29 23:25 ` Inochi Amaoto
2026-07-29 23:25 ` Inochi Amaoto
2026-07-29 23:25 ` [PATCH v3 1/4] RISC-V: KVM: Add SBI extension validate callback Inochi Amaoto
2026-07-29 23:25   ` Inochi Amaoto
2026-07-29 23:25   ` Inochi Amaoto
2026-07-29 23:39   ` sashiko-bot [this message]
2026-07-29 23:25 ` [PATCH v3 2/4] RISC-V: KVM: Add SBI FWFT validation support Inochi Amaoto
2026-07-29 23:25   ` Inochi Amaoto
2026-07-29 23:25   ` Inochi Amaoto
2026-07-29 23:52   ` sashiko-bot
2026-07-29 23:25 ` [PATCH v3 3/4] RISC-V: KVM: Reset the SBI extension when disable it Inochi Amaoto
2026-07-29 23:25   ` Inochi Amaoto
2026-07-29 23:25   ` Inochi Amaoto
2026-07-30  6:34   ` Anup Patel
2026-07-30  6:34     ` Anup Patel
2026-07-30  6:34     ` Anup Patel
2026-07-29 23:25 ` [PATCH v3 4/4] RISC-V: KVM: Mark the reset callback of FWFT extension always dirties CSR Inochi Amaoto
2026-07-29 23:25   ` Inochi Amaoto
2026-07-29 23:25   ` Inochi Amaoto
2026-07-29 23:54   ` sashiko-bot
2026-07-30  6:36   ` Anup Patel
2026-07-30  6:36     ` Anup Patel
2026-07-30  6:36     ` Anup Patel
2026-07-30  6:40 ` [PATCH v3 0/4] RISC-V: KVM: Cleanup SBI extension status when disable Anup Patel
2026-07-30  6:40   ` Anup Patel
2026-07-30  6:40   ` Anup Patel

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=20260729233912.347AE1F000E9@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.