|
18 | 18 | #include "test_util.h"
|
19 | 19 | #include "perf_test_util.h"
|
20 | 20 | #include "guest_modes.h"
|
| 21 | + |
21 | 22 | #ifdef __aarch64__
|
22 | 23 | #include "aarch64/vgic.h"
|
23 | 24 |
|
24 | 25 | #define GICD_BASE_GPA 0x8000000ULL
|
25 | 26 | #define GICR_BASE_GPA 0x80A0000ULL
|
| 27 | + |
| 28 | +static int gic_fd; |
| 29 | + |
| 30 | +static void arch_setup_vm(struct kvm_vm *vm, unsigned int nr_vcpus) |
| 31 | +{ |
| 32 | + /* |
| 33 | + * The test can still run even if hardware does not support GICv3, as it |
| 34 | + * is only an optimization to reduce guest exits. |
| 35 | + */ |
| 36 | + gic_fd = vgic_v3_setup(vm, nr_vcpus, 64, GICD_BASE_GPA, GICR_BASE_GPA); |
| 37 | +} |
| 38 | + |
| 39 | +static void arch_cleanup_vm(struct kvm_vm *vm) |
| 40 | +{ |
| 41 | + if (gic_fd > 0) |
| 42 | + close(gic_fd); |
| 43 | +} |
| 44 | + |
| 45 | +#else /* __aarch64__ */ |
| 46 | + |
| 47 | +static void arch_setup_vm(struct kvm_vm *vm, unsigned int nr_vcpus) |
| 48 | +{ |
| 49 | +} |
| 50 | + |
| 51 | +static void arch_cleanup_vm(struct kvm_vm *vm) |
| 52 | +{ |
| 53 | +} |
| 54 | + |
26 | 55 | #endif
|
27 | 56 |
|
28 | 57 | /* How many host loops to run by default (one KVM_GET_DIRTY_LOG for each loop)*/
|
@@ -206,9 +235,7 @@ static void run_test(enum vm_guest_mode mode, void *arg)
|
206 | 235 | vm_enable_cap(vm, &cap);
|
207 | 236 | }
|
208 | 237 |
|
209 |
| -#ifdef __aarch64__ |
210 |
| - vgic_v3_setup(vm, nr_vcpus, 64, GICD_BASE_GPA, GICR_BASE_GPA); |
211 |
| -#endif |
| 238 | + arch_setup_vm(vm, nr_vcpus); |
212 | 239 |
|
213 | 240 | /* Start the iterations */
|
214 | 241 | iteration = 0;
|
@@ -302,6 +329,7 @@ static void run_test(enum vm_guest_mode mode, void *arg)
|
302 | 329 | }
|
303 | 330 |
|
304 | 331 | free_bitmaps(bitmaps, p->slots);
|
| 332 | + arch_cleanup_vm(vm); |
305 | 333 | perf_test_destroy_vm(vm);
|
306 | 334 | }
|
307 | 335 |
|
|
0 commit comments