Skip to content

Commit 8911c7d

Browse files
ouptonMarc Zyngier
authored andcommitted
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>
1 parent b8daa7c commit 8911c7d

19 files changed

Lines changed: 60 additions & 56 deletions

tools/testing/selftests/kvm/arm64/arch_timer.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,6 @@ static void test_init_timer_irq(struct kvm_vm *vm)
176176
pr_debug("ptimer_irq: %d; vtimer_irq: %d\n", ptimer_irq, vtimer_irq);
177177
}
178178

179-
static int gic_fd;
180-
181179
struct kvm_vm *test_vm_create(void)
182180
{
183181
struct kvm_vm *vm;
@@ -206,7 +204,6 @@ struct kvm_vm *test_vm_create(void)
206204
vcpu_init_descriptor_tables(vcpus[i]);
207205

208206
test_init_timer_irq(vm);
209-
gic_fd = vgic_v3_setup(vm, nr_vcpus, 64);
210207

211208
/* Make all the test's cmdline args visible to the guest */
212209
sync_global_to_guest(vm, test_args);
@@ -216,6 +213,5 @@ struct kvm_vm *test_vm_create(void)
216213

217214
void test_vm_cleanup(struct kvm_vm *vm)
218215
{
219-
close(gic_fd);
220216
kvm_vm_free(vm);
221217
}

tools/testing/selftests/kvm/arm64/arch_timer_edge_cases.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -935,8 +935,6 @@ static void test_init_timer_irq(struct kvm_vm *vm, struct kvm_vcpu *vcpu)
935935
pr_debug("ptimer_irq: %d; vtimer_irq: %d\n", ptimer_irq, vtimer_irq);
936936
}
937937

938-
static int gic_fd;
939-
940938
static void test_vm_create(struct kvm_vm **vm, struct kvm_vcpu **vcpu,
941939
enum arch_timer timer)
942940
{
@@ -951,7 +949,6 @@ static void test_vm_create(struct kvm_vm **vm, struct kvm_vcpu **vcpu,
951949
vcpu_args_set(*vcpu, 1, timer);
952950

953951
test_init_timer_irq(*vm, *vcpu);
954-
gic_fd = vgic_v3_setup(*vm, 1, 64);
955952

956953
sync_global_to_guest(*vm, test_args);
957954
sync_global_to_guest(*vm, CVAL_MAX);
@@ -960,7 +957,6 @@ static void test_vm_create(struct kvm_vm **vm, struct kvm_vcpu **vcpu,
960957

961958
static void test_vm_cleanup(struct kvm_vm *vm)
962959
{
963-
close(gic_fd);
964960
kvm_vm_free(vm);
965961
}
966962

tools/testing/selftests/kvm/arm64/no-vgic-v3.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ int main(int argc, char *argv[])
163163
struct kvm_vm *vm;
164164
uint64_t pfr0;
165165

166+
test_disable_default_vgic();
167+
166168
vm = vm_create_with_one_vcpu(&vcpu, NULL);
167169
pfr0 = vcpu_get_reg(vcpu, KVM_ARM64_SYS_REG(SYS_ID_AA64PFR0_EL1));
168170
__TEST_REQUIRE(FIELD_GET(ID_AA64PFR0_EL1_GIC, pfr0),

tools/testing/selftests/kvm/arm64/psci_test.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ static struct kvm_vm *setup_vm(void *guest_code, struct kvm_vcpu **source,
9595
*source = aarch64_vcpu_add(vm, 0, &init, guest_code);
9696
*target = aarch64_vcpu_add(vm, 1, &init, guest_code);
9797

98+
kvm_arch_vm_finalize_vcpus(vm);
9899
return vm;
99100
}
100101

tools/testing/selftests/kvm/arm64/set_id_regs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,7 @@ int main(void)
763763
vm = vm_create(1);
764764
vm_enable_cap(vm, KVM_CAP_ARM_WRITABLE_IMP_ID_REGS, 0);
765765
vcpu = vm_vcpu_add(vm, 0, guest_code);
766+
kvm_arch_vm_finalize_vcpus(vm);
766767

767768
/* Check for AARCH64 only system */
768769
val = vcpu_get_reg(vcpu, KVM_ARM64_SYS_REG(SYS_ID_AA64PFR0_EL1));

tools/testing/selftests/kvm/arm64/smccc_filter.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ static struct kvm_vm *setup_vm(struct kvm_vcpu **vcpu)
7373
init.features[0] |= (1 << KVM_ARM_VCPU_PSCI_0_2);
7474

7575
*vcpu = aarch64_vcpu_add(vm, 0, &init, guest_main);
76+
kvm_arch_vm_finalize_vcpus(vm);
7677
return vm;
7778
}
7879

tools/testing/selftests/kvm/arm64/vgic_init.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -994,6 +994,8 @@ int main(int ac, char **av)
994994
int pa_bits;
995995
int cnt_impl = 0;
996996

997+
test_disable_default_vgic();
998+
997999
pa_bits = vm_guest_mode_params[VM_MODE_DEFAULT].pa_bits;
9981000
max_phys_size = 1ULL << pa_bits;
9991001

tools/testing/selftests/kvm/arm64/vgic_irq.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,7 @@ int main(int argc, char **argv)
802802
bool eoi_split = false;
803803

804804
TEST_REQUIRE(kvm_supports_vgic_v3());
805+
test_disable_default_vgic();
805806

806807
while ((opt = getopt(argc, argv, "hn:e:l:")) != -1) {
807808
switch (opt) {

tools/testing/selftests/kvm/arm64/vgic_lpi_stress.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static vm_paddr_t gpa_base;
2727

2828
static struct kvm_vm *vm;
2929
static struct kvm_vcpu **vcpus;
30-
static int gic_fd, its_fd;
30+
static int its_fd;
3131

3232
static struct test_data {
3333
bool request_vcpus_stop;
@@ -214,7 +214,6 @@ static void setup_test_data(void)
214214

215215
static void setup_gic(void)
216216
{
217-
gic_fd = vgic_v3_setup(vm, test_data.nr_cpus, 64);
218217
its_fd = vgic_its_setup(vm);
219218
}
220219

@@ -353,7 +352,6 @@ static void setup_vm(void)
353352
static void destroy_vm(void)
354353
{
355354
close(its_fd);
356-
close(gic_fd);
357355
kvm_vm_free(vm);
358356
free(vcpus);
359357
}

tools/testing/selftests/kvm/arm64/vpmu_counter_access.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
struct vpmu_vm {
2929
struct kvm_vm *vm;
3030
struct kvm_vcpu *vcpu;
31-
int gic_fd;
3231
};
3332

3433
static struct vpmu_vm vpmu_vm;
@@ -435,7 +434,8 @@ static void create_vpmu_vm(void *guest_code)
435434
init.features[0] |= (1 << KVM_ARM_VCPU_PMU_V3);
436435
vpmu_vm.vcpu = aarch64_vcpu_add(vpmu_vm.vm, 0, &init, guest_code);
437436
vcpu_init_descriptor_tables(vpmu_vm.vcpu);
438-
vpmu_vm.gic_fd = vgic_v3_setup(vpmu_vm.vm, 1, 64);
437+
438+
kvm_arch_vm_finalize_vcpus(vpmu_vm.vm);
439439

440440
/* Make sure that PMUv3 support is indicated in the ID register */
441441
dfr0 = vcpu_get_reg(vpmu_vm.vcpu, KVM_ARM64_SYS_REG(SYS_ID_AA64DFR0_EL1));
@@ -451,7 +451,6 @@ static void create_vpmu_vm(void *guest_code)
451451

452452
static void destroy_vpmu_vm(void)
453453
{
454-
close(vpmu_vm.gic_fd);
455454
kvm_vm_free(vpmu_vm.vm);
456455
}
457456

0 commit comments

Comments
 (0)