mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Inochi Amaoto <inochiama@gmail.com>
To: Anup Patel <anup@brainfault.org>, Inochi Amaoto <inochiama@gmail.com>
Cc: Atish Patra <atish.patra@linux.dev>,
	Paul Walmsley <pjw@kernel.org>,
	 Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	 Alexandre Ghiti <alex@ghiti.fr>,
	kvm@vger.kernel.org, kvm-riscv@lists.infradead.org,
	 linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
	Yixun Lan <dlan@gentoo.org>,  Longbin Li <looong.bin@gmail.com>
Subject: Re: [PATCH v2 3/3] RISC-V: KVM: Reset the SBI extension when disable it
Date: Thu, 30 Jul 2026 06:33:45 +0800	[thread overview]
Message-ID: <amp_hOi78SGkPjAp@inochi.infowork> (raw)
In-Reply-To: <CAAhSdy3qnvWF1cdxJxnJxR9jf0_BUpKbauNAuJcY_AAVaJw9AQ@mail.gmail.com>

On Wed, Jul 29, 2026 at 01:32:40PM +0530, Anup Patel wrote:
> On Mon, Jul 6, 2026 at 7:42 AM Inochi Amaoto <inochiama@gmail.com> wrote:
> >
> > The SBI extension validation callback can only fix the parameter if
> > the extension is enabled. However, if the extension is disabled after
> > modifty some parameters, the state of the extension is still broken.
> >
> > Reset the extension when the extenion is disabled so it can have
> 
> s/extenion/extension/
> 
> > a clear context.
> >
> > Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
> > ---
> >  arch/riscv/kvm/vcpu_sbi.c | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> >
> > diff --git a/arch/riscv/kvm/vcpu_sbi.c b/arch/riscv/kvm/vcpu_sbi.c
> > index b737e9a7a12a..3eb7b7c57059 100644
> > --- a/arch/riscv/kvm/vcpu_sbi.c
> > +++ b/arch/riscv/kvm/vcpu_sbi.c
> > @@ -221,6 +221,7 @@ static int riscv_vcpu_set_sbi_ext_single(struct kvm_vcpu *vcpu,
> >  {
> >         struct kvm_vcpu_sbi_context *scontext = &vcpu->arch.sbi_context;
> >         const struct kvm_riscv_sbi_extension_entry *sext;
> > +       const struct kvm_vcpu_sbi_extension *ext;
> >
> >         if (reg_val != 1 && reg_val != 0)
> >                 return -EINVAL;
> > @@ -229,6 +230,15 @@ static int riscv_vcpu_set_sbi_ext_single(struct kvm_vcpu *vcpu,
> >         if (!sext || scontext->ext_status[sext->ext_idx] == KVM_RISCV_SBI_EXT_STATUS_UNAVAILABLE)
> >                 return -ENOENT;
> >
> > +       ext = sext->ext_ptr;
> > +
> > +       if (!reg_val && scontext->ext_status[sext->ext_idx] == KVM_RISCV_SBI_EXT_STATUS_ENABLED) {
> > +               if (ext->reset) {
> > +                       ext->reset(vcpu);
> > +                       vcpu->arch.csr_dirty = true;
> 
> Let's not blindly set "csr_dirty" when any SBI extension is disabled,
> instead we should set "csr_dirtry" in kvm_sbi_ext_fwft_reset() (just
> like we do in kvm_sbi_ext_fwft_set_reg()).
> 

Good, I will move this line to the kvm_sbi_ext_fwft_reset() in the new version.

> > +               }
> > +       }
> > +
> >         scontext->ext_status[sext->ext_idx] = (reg_val) ?
> >                         KVM_RISCV_SBI_EXT_STATUS_ENABLED :
> >                         KVM_RISCV_SBI_EXT_STATUS_DISABLED;
> > --
> > 2.55.0
> >
> 
> Regards,
> Anup
> 

Regards,
Inochi

      reply	other threads:[~2026-07-29 22:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-06  2:11 [PATCH v2 0/3] RISC-V: KVM: Cleanup SBI extension status when disable Inochi Amaoto
2026-07-06  2:11 ` [PATCH v2 1/3] RISC-V: KVM: Add SBI extension validate callback Inochi Amaoto
2026-07-29  7:59   ` Anup Patel
2026-07-06  2:11 ` [PATCH v2 2/3] RISC-V: KVM: Add SBI FWFT validation support Inochi Amaoto
2026-07-29  7:59   ` Anup Patel
2026-07-06  2:11 ` [PATCH v2 3/3] RISC-V: KVM: Reset the SBI extension when disable it Inochi Amaoto
2026-07-29  8:02   ` Anup Patel
2026-07-29 22:33     ` Inochi Amaoto [this message]

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=amp_hOi78SGkPjAp@inochi.infowork \
    --to=inochiama@gmail.com \
    --cc=alex@ghiti.fr \
    --cc=anup@brainfault.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=atish.patra@linux.dev \
    --cc=dlan@gentoo.org \
    --cc=kvm-riscv@lists.infradead.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=looong.bin@gmail.com \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    /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

all inboxes | Powered by JetHome®