Re: [PATCH 02/16] KVM: selftests: Allow arm64 tests to create protected VMs
From: Joey Gouly
Date: Thu Nov 05 2026 - 07:35:40 EST
On Wed, Nov 04, 2026 at 08:48:28AM +0000, Fuad Tabba wrote:
> On arm64, the VM type passed to KVM_CREATE_VM carries the IPA size,
> which the selftest library fills in. The library rejects any type a test
> provides in vm_shape.type. A protected VM is created by setting
> KVM_VM_TYPE_ARM_PROTECTED in that type, so a test can't create one.
>
> Accept KVM_VM_TYPE_ARM_PROTECTED from the test, and add the IPA size to
> it as for any other VM.
>
> Signed-off-by: Fuad Tabba <fuad.tabba@xxxxxxxxx>
Similar to what I did for realms locally, and will have to expand to
support KVM_VM_TYPE_ARM_REALM.
Reviewed-by: Joey Gouly <joey.gouly@xxxxxxx>
> ---
> tools/testing/selftests/kvm/lib/kvm_util.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
> index d42e201eba763..96c1e70dba3d3 100644
> --- a/tools/testing/selftests/kvm/lib/kvm_util.c
> +++ b/tools/testing/selftests/kvm/lib/kvm_util.c
> @@ -400,9 +400,10 @@ struct kvm_vm *____vm_create(struct vm_shape shape)
> }
>
> #ifdef __aarch64__
> - TEST_ASSERT(!vm->type, "ARM doesn't support test-provided types");
> + TEST_ASSERT(!(vm->type & ~KVM_VM_TYPE_ARM_PROTECTED),
> + "ARM supports only KVM_VM_TYPE_ARM_PROTECTED as a test-provided type");
> if (vm->pa_bits != 40)
> - vm->type = KVM_VM_TYPE_ARM_IPA_SIZE(vm->pa_bits);
> + vm->type |= KVM_VM_TYPE_ARM_IPA_SIZE(vm->pa_bits);
> #endif
>
> vm_open(vm);
> --
> 2.47.3
>