diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c index f7095183b6d1..7ddf044b39ee 100644 --- a/accel/hvf/hvf-accel-ops.c +++ b/accel/hvf/hvf-accel-ops.c @@ -341,7 +341,7 @@ static int hvf_accel_init(MachineState *ms) return hvf_arch_init(); } -#if defined(CONFIG_HVF_PRIVATE) && defined(__aarch64__) +#if defined(__aarch64__) static bool hvf_get_tso(Object *obj, Error **errp) { @@ -368,7 +368,7 @@ static void hvf_accel_class_init(ObjectClass *oc, void *data) ac->allowed = &hvf_allowed; ac->gdbstub_supported_sstep_flags = hvf_gdbstub_sstep_flags; -#if defined(CONFIG_HVF_PRIVATE) && defined(__aarch64__) +#if defined(__aarch64__) object_class_property_add_bool(oc, "tso", hvf_get_tso, hvf_set_tso); object_class_property_set_description(oc, "tso", diff --git a/include/sysemu/hvf_int.h b/include/sysemu/hvf_int.h index b47640e75c78..f7166956b5a0 100644 --- a/include/sysemu/hvf_int.h +++ b/include/sysemu/hvf_int.h @@ -19,13 +19,19 @@ typedef hv_vcpu_t hvf_vcpuid; typedef hv_vcpuid_t hvf_vcpuid; #endif -#if defined(CONFIG_HVF_PRIVATE) && defined(__aarch64__) +#if defined(CONFIG_HVF_PRIVATE) extern hv_return_t _hv_vm_config_set_isa(hv_vm_config_t config, uint32_t isa); extern hv_return_t _hv_vcpu_get_actlr(hv_vcpu_t vcpu, uint64_t* value); extern hv_return_t _hv_vcpu_set_actlr(hv_vcpu_t vcpu, uint64_t value); +#endif +#if defined(__aarch64__) +#if defined(CONFIG_HVF_PRIVATE) #define HV_VM_CONFIG_ISA_PRIVATE (3) #define ACTLR_EL1_TSO_ENABLE_MASK ((1 << 1) | (1 << 9)) +#else +#define ACTLR_EL1_TSO_ENABLE_MASK ((1 << 1)) +#endif #endif /* hvf_slot flags */ diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index bcf1cbcbd6a3..5411af348b4e 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -911,6 +911,33 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) return r == HV_SUCCESS; } +static hv_return_t hvf_vcpu_get_actlr(hv_vcpu_t vcpu, uint64_t* value) +{ +#if defined(CONFIG_HVF_PRIVATE) + return _hv_vcpu_get_actlr(vcpu, value); +#else + if (__builtin_available(macOS 15, *)) { + return hv_vcpu_get_sys_reg(vcpu, HV_SYS_REG_ACTLR_EL1, value); + } else { + return HV_UNSUPPORTED; + } +#endif +} + + +static hv_return_t hvf_vcpu_set_actlr(hv_vcpu_t vcpu, uint64_t value) +{ +#if defined(CONFIG_HVF_PRIVATE) + return _hv_vcpu_set_actlr(vcpu, value); +#else + if (__builtin_available(macOS 15, *)) { + return hv_vcpu_set_sys_reg(vcpu, HV_SYS_REG_ACTLR_EL1, value); + } else { + return HV_UNSUPPORTED; + } +#endif +} + void hvf_arm_set_cpu_features_from_host(ARMCPU *cpu) { if (!arm_host_cpu_features.dtb_compatible) { @@ -1002,17 +1029,15 @@ int hvf_arch_init_vcpu(CPUState *cpu) &arm_cpu->isar.id_aa64mmfr0); assert_hvf_ok(ret); -#if defined(CONFIG_HVF_PRIVATE) /* enable TSO mode */ if (hvf_tso_mode) { uint64_t actlr; - ret = _hv_vcpu_get_actlr(cpu->accel->fd, &actlr); + ret = hvf_vcpu_get_actlr(cpu->accel->fd, &actlr); assert_hvf_ok(ret); actlr |= ACTLR_EL1_TSO_ENABLE_MASK; - ret = _hv_vcpu_set_actlr(cpu->accel->fd, actlr); + ret = hvf_vcpu_set_actlr(cpu->accel->fd, actlr); assert_hvf_ok(ret); } -#endif return 0; }