28
28
struct vm_gic {
29
29
struct kvm_vm * vm ;
30
30
int gic_fd ;
31
+ uint32_t gic_dev_type ;
31
32
};
32
33
33
34
static int max_ipa_bits ;
@@ -61,12 +62,13 @@ static int run_vcpu(struct kvm_vm *vm, uint32_t vcpuid)
61
62
return 0 ;
62
63
}
63
64
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 )
65
66
{
66
67
struct vm_gic v ;
67
68
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);
70
72
71
73
return v ;
72
74
}
@@ -257,8 +259,7 @@ static void test_v3_vgic_then_vcpus(uint32_t gic_dev_type)
257
259
struct vm_gic v ;
258
260
int ret , i ;
259
261
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 );
262
263
263
264
subtest_v3_dist_rdist (& v );
264
265
@@ -278,7 +279,7 @@ static void test_v3_vcpus_then_vgic(uint32_t gic_dev_type)
278
279
struct vm_gic v ;
279
280
int ret ;
280
281
281
- v = vm_gic_v3_create ( );
282
+ v = vm_gic_create_with_vcpus ( gic_dev_type , NR_VCPUS );
282
283
283
284
subtest_v3_dist_rdist (& v );
284
285
@@ -295,7 +296,7 @@ static void test_v3_new_redist_regions(void)
295
296
uint64_t addr ;
296
297
int ret ;
297
298
298
- v = vm_gic_v3_create ( );
299
+ v = vm_gic_create_with_vcpus ( KVM_DEV_TYPE_ARM_VGIC_V3 , NR_VCPUS );
299
300
subtest_v3_redist_regions (& v );
300
301
kvm_device_access (v .gic_fd , KVM_DEV_ARM_VGIC_GRP_CTRL ,
301
302
KVM_DEV_ARM_VGIC_CTRL_INIT , NULL , true);
@@ -306,7 +307,7 @@ static void test_v3_new_redist_regions(void)
306
307
307
308
/* step2 */
308
309
309
- v = vm_gic_v3_create ( );
310
+ v = vm_gic_create_with_vcpus ( KVM_DEV_TYPE_ARM_VGIC_V3 , NR_VCPUS );
310
311
subtest_v3_redist_regions (& v );
311
312
312
313
addr = REDIST_REGION_ATTR_ADDR (1 , 0x280000 , 0 , 2 );
@@ -320,7 +321,7 @@ static void test_v3_new_redist_regions(void)
320
321
321
322
/* step 3 */
322
323
323
- v = vm_gic_v3_create ( );
324
+ v = vm_gic_create_with_vcpus ( KVM_DEV_TYPE_ARM_VGIC_V3 , NR_VCPUS );
324
325
subtest_v3_redist_regions (& v );
325
326
326
327
_kvm_device_access (v .gic_fd , KVM_DEV_ARM_VGIC_GRP_ADDR ,
0 commit comments