Subject: Re: [PATCH] KVM: selftest: arm64: Run shadow_stage2 varying guest modes

From: Itaru Kitayama <[email-masked]>
Date: Fri, 29 May 2026 07:14:07 +0900

On Thu, May 28, 2026 at 05:02:30PM +0100, Wei-Lin Chang wrote:
> Hi Itaru,
> 
> On Thu, May 28, 2026 at 01:59:30PM +0900, Itaru Kitayama wrote:
> > Refactor main() to use for_each_guest_mode() helper to create
> > a single VCPU VM with a guest mode ID.
> > 
> > Signed-off-by: Itaru Kitayama <[email-masked]>
> > ---
> >  tools/testing/selftests/kvm/arm64/shadow_stage2.c | 9 +++++++--
> >  1 file changed, 7 insertions(+), 2 deletions(-)
> > 
> > diff --git a/tools/testing/selftests/kvm/arm64/shadow_stage2.c b/tools/testing/selftests/kvm/arm64/shadow_stage2.c
> > index 5bce55abdea7..05acca22eafe 100644
> > --- a/tools/testing/selftests/kvm/arm64/shadow_stage2.c
> > +++ b/tools/testing/selftests/kvm/arm64/shadow_stage2.c
> > @@ -105,7 +105,7 @@ static void guest_code(void)
> >  	GUEST_DONE();
> >  }
> >  
> > -int main(void)
> > +int run_test(enum vm_guest_mode mode, void *unused)
> >  {
> >  	struct kvm_vcpu_init init;
> >  	struct kvm_vcpu *vcpu;
> > @@ -114,7 +114,8 @@ int main(void)
> >  	gpa_t gpa;
> >  
> >  	TEST_REQUIRE(kvm_check_cap(KVM_CAP_ARM_EL2));
> > -	vm = vm_create(1);
> > +	vm = __vm_create(VM_SHAPE(mode), 1, 0);
> > +
> >  
> >  	kvm_get_default_vcpu_target(vm, &init);
> >  	init.features[0] |= BIT(KVM_ARM_VCPU_HAS_EL2);
> > @@ -163,3 +164,7 @@ int main(void)
> >  	kvm_vm_free(vm);
> >  	return 0;
> >  }
> > +
> > +int main(void) {
> > +	for_each_guest_mode(run_test, NULL);
> > +}
> > -- 
> > 2.43.0
> > 
> 
> Thanks! I think this is valuable.
> I can add your patch into the next version if you don't mind?

No, I would not, for the record your test rans with all the available guest
modes without an issue (ie ended DONE!) on QEMU in tcg mode.

Thanks,
Itaru.

> Thanks,
> Wei-Lin Chang