@samitouri / QOSamiQemu / commits / 5a2a13bc7a

target/arm: hvf: instantiate GIC early

While figuring out a better spot for it, put it in hv_arch_vm_create(). After hv_vcpu_create is documented as too late, and deferring vCPU initialization isn't enough either. Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-id: 20260429190532.26538-5-mohamed@unpredictable.fr Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Mohamed Mediouni committed May 5, 2026 at 09:25 UTC 5a2a13bc7a03f90388ab369531f2db3df06c8f7e
1 file changed +22
target/arm/hvf/hvf.c
+22
@@ -1230,6 +1230,28 @@ hv_return_t hvf_arch_vm_create(MachineState *ms, uint32_t pa_range)
1230 chosen_ipa_bit_size = pa_range;
1231
1232 ret = hv_vm_create(config);
1233 + if (hvf_irqchip_in_kernel()) {
1234 + if (__builtin_available(macOS 15.0, *)) {
1235 + /*
1236 + * Instantiate GIC.
1237 + * This must be done prior to the creation of any vCPU
1238 + * but past hv_vm_create()
1239 + */
1240 + hv_gic_config_t cfg = hv_gic_config_create();
1241 + hv_gic_config_set_distributor_base(cfg, 0x08000000);
1242 + hv_gic_config_set_redistributor_base(cfg, 0x080A0000);
1243 + ret = hv_gic_create(cfg);
1244 + if (ret != HV_SUCCESS) {
1245 + error_report("error creating platform VGIC");
1246 + goto cleanup;
1247 + }
1248 + os_release(cfg);
1249 + } else {
1250 + error_report("HVF: Unsupported OS for platform vGIC.");
1251 + ret = HV_UNSUPPORTED;
1252 + goto cleanup;
1253 + }
1254 + }
1255
1256 cleanup:
1257 os_release(config);