Skip to content

Commit 46fb941

Browse files
Ricardo KollerMarc Zyngier
authored andcommitted
KVM: arm64: selftests: Make vgic_init/vm_gic_create version agnostic
Make vm_gic_create GIC version agnostic in the vgic_init test. Also add a nr_vcpus arg into it instead of defaulting to NR_VCPUS. No functional change. Reviewed-by: Eric Auger <[email protected]> Signed-off-by: Ricardo Koller <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 3f4db37 commit 46fb941

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
struct vm_gic {
2929
struct kvm_vm *vm;
3030
int gic_fd;
31+
uint32_t gic_dev_type;
3132
};
3233

3334
static int max_ipa_bits;
@@ -61,12 +62,13 @@ static int run_vcpu(struct kvm_vm *vm, uint32_t vcpuid)
6162
return 0;
6263
}
6364

64-
static struct vm_gic vm_gic_v3_create(void)
65+
static struct vm_gic vm_gic_create_with_vcpus(uint32_t gic_dev_type, uint32_t nr_vcpus)
6566
{
6667
struct vm_gic v;
6768

68-
v.vm = vm_create_default_with_vcpus(NR_VCPUS, 0, 0, guest_code, NULL);
69-
v.gic_fd = kvm_create_device(v.vm, KVM_DEV_TYPE_ARM_VGIC_V3, false);
69+
v.gic_dev_type = gic_dev_type;
70+
v.vm = vm_create_default_with_vcpus(nr_vcpus, 0, 0, guest_code, NULL);
71+
v.gic_fd = kvm_create_device(v.vm, gic_dev_type, false);
7072

7173
return v;
7274
}
@@ -257,8 +259,7 @@ static void test_v3_vgic_then_vcpus(uint32_t gic_dev_type)
257259
struct vm_gic v;
258260
int ret, i;
259261

260-
v.vm = vm_create_default(0, 0, guest_code);
261-
v.gic_fd = kvm_create_device(v.vm, KVM_DEV_TYPE_ARM_VGIC_V3, false);
262+
v = vm_gic_create_with_vcpus(gic_dev_type, 1);
262263

263264
subtest_v3_dist_rdist(&v);
264265

@@ -278,7 +279,7 @@ static void test_v3_vcpus_then_vgic(uint32_t gic_dev_type)
278279
struct vm_gic v;
279280
int ret;
280281

281-
v = vm_gic_v3_create();
282+
v = vm_gic_create_with_vcpus(gic_dev_type, NR_VCPUS);
282283

283284
subtest_v3_dist_rdist(&v);
284285

@@ -295,7 +296,7 @@ static void test_v3_new_redist_regions(void)
295296
uint64_t addr;
296297
int ret;
297298

298-
v = vm_gic_v3_create();
299+
v = vm_gic_create_with_vcpus(KVM_DEV_TYPE_ARM_VGIC_V3, NR_VCPUS);
299300
subtest_v3_redist_regions(&v);
300301
kvm_device_access(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_CTRL,
301302
KVM_DEV_ARM_VGIC_CTRL_INIT, NULL, true);
@@ -306,7 +307,7 @@ static void test_v3_new_redist_regions(void)
306307

307308
/* step2 */
308309

309-
v = vm_gic_v3_create();
310+
v = vm_gic_create_with_vcpus(KVM_DEV_TYPE_ARM_VGIC_V3, NR_VCPUS);
310311
subtest_v3_redist_regions(&v);
311312

312313
addr = REDIST_REGION_ATTR_ADDR(1, 0x280000, 0, 2);
@@ -320,7 +321,7 @@ static void test_v3_new_redist_regions(void)
320321

321322
/* step 3 */
322323

323-
v = vm_gic_v3_create();
324+
v = vm_gic_create_with_vcpus(KVM_DEV_TYPE_ARM_VGIC_V3, NR_VCPUS);
324325
subtest_v3_redist_regions(&v);
325326

326327
_kvm_device_access(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR,

0 commit comments

Comments
 (0)