[PATCH 07/13] KVM: arm64: selftests: Provide helper for getting default vCPU target
Oliver Upton
oliver.upton at linux.dev
Wed Sep 17 15:00:41 PDT 2025
Hi Itaru,
Appreciate the review.
On Thu, Sep 18, 2025 at 06:56:27AM +0900, Itaru Kitayama wrote:
> On Wed, Sep 17, 2025 at 02:20:37PM -0700, Oliver Upton wrote:
> > The default vCPU target in KVM selftests is pretty boring in that it
> > doesn't enable any vCPU features. Expose a helper for getting the
> > default target to prepare for cramming in more features. Call
> > KVM_ARM_PREFERRED_TARGET directly from get-reg-list as it needs
> > fine-grained control over feature flags.
> >
> > Signed-off-by: Oliver Upton <oliver.upton at linux.dev>
> > ---
> > tools/testing/selftests/kvm/arm64/psci_test.c | 2 +-
> > .../testing/selftests/kvm/arm64/smccc_filter.c | 2 +-
> > .../selftests/kvm/arm64/vpmu_counter_access.c | 4 ++--
> > tools/testing/selftests/kvm/get-reg-list.c | 9 ++++++---
> > .../selftests/kvm/include/arm64/processor.h | 2 ++
> > .../testing/selftests/kvm/lib/arm64/processor.c | 17 +++++++++++------
> > 6 files changed, 23 insertions(+), 13 deletions(-)
> >
> > diff --git a/tools/testing/selftests/kvm/arm64/psci_test.c b/tools/testing/selftests/kvm/arm64/psci_test.c
> > index cf208390fd0e..0d4680da66d1 100644
> > --- a/tools/testing/selftests/kvm/arm64/psci_test.c
> > +++ b/tools/testing/selftests/kvm/arm64/psci_test.c
> > @@ -89,7 +89,7 @@ static struct kvm_vm *setup_vm(void *guest_code, struct kvm_vcpu **source,
> >
> > vm = vm_create(2);
> >
> > - vm_ioctl(vm, KVM_ARM_PREFERRED_TARGET, &init);
> > + kvm_get_default_vcpu_target(vm, &init);
> > init.features[0] |= (1 << KVM_ARM_VCPU_PSCI_0_2);
> >
> > *source = aarch64_vcpu_add(vm, 0, &init, guest_code);
>
> I wonder if the ioctl() can be called unconditionally in the
> aarch64_vcpu_add() function. If the intention is that the kvm selftest
> code needs to write this way I am fine with that.
I had a similar thought but decided against it as tests may need
fine-grained control over the feature flags (like above). I would hope
that most users will use the 'default' VM infrastructure if they do not
need this sort of control.
> Reviewed-by: Itaru Kitayama <itaru.kitayama at fujitsu.com>
Thanks!
Best,
Oliver
More information about the linux-arm-kernel
mailing list