Skip to content

Commit

Permalink
hvf: arm: support TSO on macOS 15
Browse files Browse the repository at this point in the history
  • Loading branch information
osy committed Oct 4, 2024
1 parent 849e1db commit f2387eb
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
4 changes: 2 additions & 2 deletions accel/hvf/hvf-accel-ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion include/sysemu/hvf_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ 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__)
#define HV_VM_CONFIG_ISA_PRIVATE (3)
#define ACTLR_EL1_TSO_ENABLE_MASK ((1 << 1) | (1 << 9))
#endif
Expand Down
33 changes: 29 additions & 4 deletions target/arm/hvf/hvf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit f2387eb

Please sign in to comment.