Re: [RFC PATCH 01/25] KVM: arm64: Add has_reset_once flag for vcpu

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Andrew,

On Fri, Oct 15, 2021 at 3:13 AM Andrew Jones <drjones@xxxxxxxxxx> wrote:
>
> On Mon, Oct 11, 2021 at 09:35:11PM -0700, Reiji Watanabe wrote:
> > Introduce 'has_reset_once' flag in kvm_vcpu_arch, which indicates
> > if the vCPU reset has been done once, for later use.
> >
> > Signed-off-by: Reiji Watanabe <reijiw@xxxxxxxxxx>
> > ---
> >  arch/arm64/include/asm/kvm_host.h | 2 ++
> >  arch/arm64/kvm/reset.c            | 4 ++++
> >  2 files changed, 6 insertions(+)
> >
> > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
> > index f8be56d5342b..9b5e7a3b6011 100644
> > --- a/arch/arm64/include/asm/kvm_host.h
> > +++ b/arch/arm64/include/asm/kvm_host.h
> > @@ -384,6 +384,7 @@ struct kvm_vcpu_arch {
> >               u64 last_steal;
> >               gpa_t base;
> >       } steal;
> > +     bool has_reset_once;
> >  };
> >
> >  /* Pointer to the vcpu's SVE FFR for sve_{save,load}_state() */
> > @@ -449,6 +450,7 @@ struct kvm_vcpu_arch {
> >
> >  #define vcpu_has_sve(vcpu) (system_supports_sve() &&                 \
> >                           ((vcpu)->arch.flags & KVM_ARM64_GUEST_HAS_SVE))
> > +#define      vcpu_has_reset_once(vcpu) ((vcpu)->arch.has_reset_once)
> >
> >  #ifdef CONFIG_ARM64_PTR_AUTH
> >  #define vcpu_has_ptrauth(vcpu)                                               \
> > diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c
> > index 5ce36b0a3343..4d34e5c1586c 100644
> > --- a/arch/arm64/kvm/reset.c
> > +++ b/arch/arm64/kvm/reset.c
> > @@ -305,6 +305,10 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu)
> >       if (loaded)
> >               kvm_arch_vcpu_load(vcpu, smp_processor_id());
> >       preempt_enable();
> > +
> > +     if (!ret && !vcpu->arch.has_reset_once)
> > +             vcpu->arch.has_reset_once = true;
> > +
> >       return ret;
> >  }
> >
> > --
> > 2.33.0.882.g93a45727a2-goog
> >
>
> Hi Reiji,
>
> Can't we use kvm_vcpu_initialized(vcpu)? vcpu->arch.target should
> only be >= when we've successfully reset the vcpu at least once.

Thank you for reviewing the patch (and other patches as well) !

As you already noticed, we can't simply use kvm_vcpu_initialized()
because vcpu->arch.target is currently set earlier than the first
vcpu reset.

Thanks,
Reiji
_______________________________________________
kvmarm mailing list
kvmarm@xxxxxxxxxxxxxxxxxxxxx
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm



[Index of Archives]     [Linux KVM]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux