|
@@ -907,7 +907,9 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
|
|
r |= hv_vcpu_destroy(fd);
|
|
r |= hv_vcpu_destroy(fd);
|
|
|
|
|
|
#if !defined(CONFIG_HVF_PRIVATE)
|
|
#if !defined(CONFIG_HVF_PRIVATE)
|
|
- clamp_id_aa64mmfr0_parange_to_ipa_size(&host_isar.id_aa64mmfr0);
|
|
|
|
|
|
+ if (__builtin_available(macOS 13.0, *)) {
|
|
|
|
+ clamp_id_aa64mmfr0_parange_to_ipa_size(&host_isar.id_aa64mmfr0);
|
|
|
|
+ }
|
|
#endif
|
|
#endif
|
|
|
|
|
|
ahcf->isar = host_isar;
|
|
ahcf->isar = host_isar;
|
|
@@ -962,26 +964,34 @@ static hv_return_t hvf_vcpu_set_actlr(hv_vcpu_t vcpu, uint64_t value)
|
|
|
|
|
|
uint32_t hvf_arm_get_default_ipa_bit_size(void)
|
|
uint32_t hvf_arm_get_default_ipa_bit_size(void)
|
|
{
|
|
{
|
|
- uint32_t default_ipa_size;
|
|
|
|
- hv_return_t ret = hv_vm_config_get_default_ipa_size(&default_ipa_size);
|
|
|
|
- assert_hvf_ok(ret);
|
|
|
|
|
|
+ if (__builtin_available(macOS 13.0, *)) {
|
|
|
|
+ uint32_t default_ipa_size;
|
|
|
|
+ hv_return_t ret = hv_vm_config_get_default_ipa_size(&default_ipa_size);
|
|
|
|
+ assert_hvf_ok(ret);
|
|
|
|
|
|
- return default_ipa_size;
|
|
|
|
|
|
+ return default_ipa_size;
|
|
|
|
+ } else {
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
uint32_t hvf_arm_get_max_ipa_bit_size(void)
|
|
uint32_t hvf_arm_get_max_ipa_bit_size(void)
|
|
{
|
|
{
|
|
- uint32_t max_ipa_size;
|
|
|
|
- hv_return_t ret = hv_vm_config_get_max_ipa_size(&max_ipa_size);
|
|
|
|
- assert_hvf_ok(ret);
|
|
|
|
|
|
+ if (__builtin_available(macOS 13.0, *)) {
|
|
|
|
+ uint32_t max_ipa_size;
|
|
|
|
+ hv_return_t ret = hv_vm_config_get_max_ipa_size(&max_ipa_size);
|
|
|
|
+ assert_hvf_ok(ret);
|
|
|
|
|
|
- /*
|
|
|
|
- * We clamp any IPA size we want to back the VM with to a valid PARange
|
|
|
|
- * value so the guest doesn't try and map memory outside of the valid range.
|
|
|
|
- * This logic just clamps the passed in IPA bit size to the first valid
|
|
|
|
- * PARange value <= to it.
|
|
|
|
- */
|
|
|
|
- return round_down_to_parange_bit_size(max_ipa_size);
|
|
|
|
|
|
+ /*
|
|
|
|
+ * We clamp any IPA size we want to back the VM with to a valid PARange
|
|
|
|
+ * value so the guest doesn't try and map memory outside of the valid
|
|
|
|
+ * range. This logic just clamps the passed in IPA bit size to the first
|
|
|
|
+ * valid PARange value <= to it.
|
|
|
|
+ */
|
|
|
|
+ return round_down_to_parange_bit_size(max_ipa_size);
|
|
|
|
+ } else {
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
#endif
|
|
#endif
|
|
@@ -1014,24 +1024,31 @@ void hvf_arch_vcpu_destroy(CPUState *cpu)
|
|
hv_return_t hvf_arch_vm_create(MachineState *ms, uint32_t pa_range)
|
|
hv_return_t hvf_arch_vm_create(MachineState *ms, uint32_t pa_range)
|
|
{
|
|
{
|
|
hv_return_t ret;
|
|
hv_return_t ret;
|
|
- hv_vm_config_t config = hv_vm_config_create();
|
|
|
|
|
|
+ hv_vm_config_t config = NULL;
|
|
|
|
|
|
#if defined(CONFIG_HVF_PRIVATE)
|
|
#if defined(CONFIG_HVF_PRIVATE)
|
|
if (hvf_tso_mode) {
|
|
if (hvf_tso_mode) {
|
|
|
|
+ config = hv_vm_config_create();
|
|
_hv_vm_config_set_isa(config, HV_VM_CONFIG_ISA_PRIVATE);
|
|
_hv_vm_config_set_isa(config, HV_VM_CONFIG_ISA_PRIVATE);
|
|
}
|
|
}
|
|
#else
|
|
#else
|
|
- ret = hv_vm_config_set_ipa_size(config, pa_range);
|
|
|
|
- if (ret != HV_SUCCESS) {
|
|
|
|
- goto cleanup;
|
|
|
|
|
|
+ if (__builtin_available(macOS 13.0, *)) {
|
|
|
|
+ config = hv_vm_config_create();
|
|
|
|
+ ret = hv_vm_config_set_ipa_size(config, pa_range);
|
|
|
|
+ if (ret != HV_SUCCESS) {
|
|
|
|
+ goto cleanup;
|
|
|
|
+ }
|
|
|
|
+ chosen_ipa_bit_size = pa_range;
|
|
}
|
|
}
|
|
- chosen_ipa_bit_size = pa_range;
|
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
ret = hv_vm_create(config);
|
|
ret = hv_vm_create(config);
|
|
|
|
|
|
cleanup:
|
|
cleanup:
|
|
- os_release(config);
|
|
|
|
|
|
+ if (config) {
|
|
|
|
+ os_release(config);
|
|
|
|
+ }
|
|
|
|
+
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1102,10 +1119,12 @@ int hvf_arch_init_vcpu(CPUState *cpu)
|
|
assert_hvf_ok(ret);
|
|
assert_hvf_ok(ret);
|
|
|
|
|
|
#if !defined(CONFIG_HVF_PRIVATE)
|
|
#if !defined(CONFIG_HVF_PRIVATE)
|
|
- clamp_id_aa64mmfr0_parange_to_ipa_size(&arm_cpu->isar.id_aa64mmfr0);
|
|
|
|
- ret = hv_vcpu_set_sys_reg(cpu->accel->fd, HV_SYS_REG_ID_AA64MMFR0_EL1,
|
|
|
|
- arm_cpu->isar.id_aa64mmfr0);
|
|
|
|
- assert_hvf_ok(ret);
|
|
|
|
|
|
+ if (__builtin_available(macOS 13.0, *)) {
|
|
|
|
+ clamp_id_aa64mmfr0_parange_to_ipa_size(&arm_cpu->isar.id_aa64mmfr0);
|
|
|
|
+ ret = hv_vcpu_set_sys_reg(cpu->accel->fd, HV_SYS_REG_ID_AA64MMFR0_EL1,
|
|
|
|
+ arm_cpu->isar.id_aa64mmfr0);
|
|
|
|
+ assert_hvf_ok(ret);
|
|
|
|
+ }
|
|
#endif
|
|
#endif
|
|
|
|
|
|
/* enable TSO mode */
|
|
/* enable TSO mode */
|