Skip to content

Commit f2387eb

Browse files
committed
hvf: arm: support TSO on macOS 15
1 parent 849e1db commit f2387eb

File tree

3 files changed

+34
-7
lines changed

3 files changed

+34
-7
lines changed

accel/hvf/hvf-accel-ops.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ static int hvf_accel_init(MachineState *ms)
341341
return hvf_arch_init();
342342
}
343343

344-
#if defined(CONFIG_HVF_PRIVATE) && defined(__aarch64__)
344+
#if defined(__aarch64__)
345345

346346
static bool hvf_get_tso(Object *obj, Error **errp)
347347
{
@@ -368,7 +368,7 @@ static void hvf_accel_class_init(ObjectClass *oc, void *data)
368368
ac->allowed = &hvf_allowed;
369369
ac->gdbstub_supported_sstep_flags = hvf_gdbstub_sstep_flags;
370370

371-
#if defined(CONFIG_HVF_PRIVATE) && defined(__aarch64__)
371+
#if defined(__aarch64__)
372372
object_class_property_add_bool(oc, "tso",
373373
hvf_get_tso, hvf_set_tso);
374374
object_class_property_set_description(oc, "tso",

include/sysemu/hvf_int.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ typedef hv_vcpu_t hvf_vcpuid;
1919
typedef hv_vcpuid_t hvf_vcpuid;
2020
#endif
2121

22-
#if defined(CONFIG_HVF_PRIVATE) && defined(__aarch64__)
22+
#if defined(CONFIG_HVF_PRIVATE)
2323
extern hv_return_t _hv_vm_config_set_isa(hv_vm_config_t config, uint32_t isa);
2424
extern hv_return_t _hv_vcpu_get_actlr(hv_vcpu_t vcpu, uint64_t* value);
2525
extern hv_return_t _hv_vcpu_set_actlr(hv_vcpu_t vcpu, uint64_t value);
26+
#endif
2627

28+
#if defined(__aarch64__)
2729
#define HV_VM_CONFIG_ISA_PRIVATE (3)
2830
#define ACTLR_EL1_TSO_ENABLE_MASK ((1 << 1) | (1 << 9))
2931
#endif

target/arm/hvf/hvf.c

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,33 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
911911
return r == HV_SUCCESS;
912912
}
913913

914+
static hv_return_t hvf_vcpu_get_actlr(hv_vcpu_t vcpu, uint64_t* value)
915+
{
916+
#if defined(CONFIG_HVF_PRIVATE)
917+
return _hv_vcpu_get_actlr(vcpu, value);
918+
#else
919+
if (__builtin_available(macOS 15, *)) {
920+
return hv_vcpu_get_sys_reg(vcpu, HV_SYS_REG_ACTLR_EL1, value);
921+
} else {
922+
return HV_UNSUPPORTED;
923+
}
924+
#endif
925+
}
926+
927+
928+
static hv_return_t hvf_vcpu_set_actlr(hv_vcpu_t vcpu, uint64_t value)
929+
{
930+
#if defined(CONFIG_HVF_PRIVATE)
931+
return _hv_vcpu_set_actlr(vcpu, value);
932+
#else
933+
if (__builtin_available(macOS 15, *)) {
934+
return hv_vcpu_set_sys_reg(vcpu, HV_SYS_REG_ACTLR_EL1, value);
935+
} else {
936+
return HV_UNSUPPORTED;
937+
}
938+
#endif
939+
}
940+
914941
void hvf_arm_set_cpu_features_from_host(ARMCPU *cpu)
915942
{
916943
if (!arm_host_cpu_features.dtb_compatible) {
@@ -1002,17 +1029,15 @@ int hvf_arch_init_vcpu(CPUState *cpu)
10021029
&arm_cpu->isar.id_aa64mmfr0);
10031030
assert_hvf_ok(ret);
10041031

1005-
#if defined(CONFIG_HVF_PRIVATE)
10061032
/* enable TSO mode */
10071033
if (hvf_tso_mode) {
10081034
uint64_t actlr;
1009-
ret = _hv_vcpu_get_actlr(cpu->accel->fd, &actlr);
1035+
ret = hvf_vcpu_get_actlr(cpu->accel->fd, &actlr);
10101036
assert_hvf_ok(ret);
10111037
actlr |= ACTLR_EL1_TSO_ENABLE_MASK;
1012-
ret = _hv_vcpu_set_actlr(cpu->accel->fd, actlr);
1038+
ret = hvf_vcpu_set_actlr(cpu->accel->fd, actlr);
10131039
assert_hvf_ok(ret);
10141040
}
1015-
#endif
10161041

10171042
return 0;
10181043
}

0 commit comments

Comments
 (0)