diff options
| author | Oliver Upton <oliver.upton@linux.dev> | 2025-09-17 14:20:35 -0700 |
|---|---|---|
| committer | Marc Zyngier <maz@kernel.org> | 2025-09-24 19:23:32 +0100 |
| commit | 8911c7dbc607212bf3dfc963004b062588c0ab38 (patch) | |
| tree | 17b64b9067ebe4c2cf814ee129e2d3178630372b /tools/testing/selftests/kvm/lib/arm64/processor.c | |
| parent | b8daa7ceac1c56e39b6ef4e62510a7d846511695 (diff) | |
KVM: arm64: selftests: Create a VGICv3 for 'default' VMs
Start creating a VGICv3 by default unless explicitly opted-out by the
test. While having an interrupt controller is nice, the real benefit
here is clearing a hurdle for EL2 VMs which mandate the presence of a
VGIC.
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Diffstat (limited to 'tools/testing/selftests/kvm/lib/arm64/processor.c')
| -rw-r--r-- | tools/testing/selftests/kvm/lib/arm64/processor.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/tools/testing/selftests/kvm/lib/arm64/processor.c b/tools/testing/selftests/kvm/lib/arm64/processor.c index caed1998c7b3..de77d9a7e0cd 100644 --- a/tools/testing/selftests/kvm/lib/arm64/processor.c +++ b/tools/testing/selftests/kvm/lib/arm64/processor.c @@ -12,6 +12,7 @@ #include "kvm_util.h" #include "processor.h" #include "ucall_common.h" +#include "vgic.h" #include <linux/bitfield.h> #include <linux/sizes.h> @@ -655,14 +656,37 @@ void wfi(void) } static bool request_mte; +static bool request_vgic = true; void test_wants_mte(void) { request_mte = true; } -void kvm_arch_vm_post_create(struct kvm_vm *vm) +void test_disable_default_vgic(void) +{ + request_vgic = false; +} + +void kvm_arch_vm_post_create(struct kvm_vm *vm, unsigned int nr_vcpus) { if (request_mte && vm_check_cap(vm, KVM_CAP_ARM_MTE)) vm_enable_cap(vm, KVM_CAP_ARM_MTE, 0); + + if (request_vgic && kvm_supports_vgic_v3()) { + vm->arch.gic_fd = __vgic_v3_setup(vm, nr_vcpus, 64); + vm->arch.has_gic = true; + } +} + +void kvm_arch_vm_finalize_vcpus(struct kvm_vm *vm) +{ + if (vm->arch.has_gic) + __vgic_v3_init(vm->arch.gic_fd); +} + +void kvm_arch_vm_release(struct kvm_vm *vm) +{ + if (vm->arch.has_gic) + close(vm->arch.gic_fd); } |