Re: [PATCH 03/13] RISC-V: KVM: Check kvm_riscv_vcpu_alloc_vector_context() return value

From: Anup Patel
Date: Mon Jun 09 2025 - 01:02:02 EST


On Fri, Jun 6, 2025 at 5:46 AM Atish Patra <atish.patra@xxxxxxxxx> wrote:
>
>
> On 6/4/25 11:14 PM, Anup Patel wrote:
> > The kvm_riscv_vcpu_alloc_vector_context() does return an error code
> > upon failure so don't ignore this in kvm_arch_vcpu_create().
>
> currently, kvm_riscv_vcpu_alloc_vector_context returns -ENOMEM only.
>
> Do you have some plans to return different errors in the future ?

Even if kvm_riscv_vcpu_alloc_vector_context() always returns -ENOMEM,
the caller should not assume anything about the return value.

>
> Otherwise, the code remains same before and after.
>
> > Signed-off-by: Anup Patel <apatel@xxxxxxxxxxxxxxxx>
> > ---
> > arch/riscv/kvm/vcpu.c | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/riscv/kvm/vcpu.c b/arch/riscv/kvm/vcpu.c
> > index e0a01af426ff..6a1914b21ec3 100644
> > --- a/arch/riscv/kvm/vcpu.c
> > +++ b/arch/riscv/kvm/vcpu.c
> > @@ -148,8 +148,10 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)
> >
> > spin_lock_init(&vcpu->arch.reset_state.lock);
> >
> > - if (kvm_riscv_vcpu_alloc_vector_context(vcpu))
> > - return -ENOMEM;
> > + /* Setup VCPU vector context */
> The function name is pretty self explanatory. So no need of this comment ?

Yes, no need for this comment. I will drop it in the next revision.

> > + rc = kvm_riscv_vcpu_alloc_vector_context(vcpu);
> > + if (rc)
> > + return rc;
> >
> > /* Setup VCPU timer */
> > kvm_riscv_vcpu_timer_init(vcpu);
>

Regards,
Anup