Hi Mohamed,
On 21/7/25 17:29, Mohamed Mediouni wrote:
On Apple M3 and later, the timer frequency within apps and VM guests are
different from each other.
Also M1/M2, so all Apple Silicon chipsets IMO.
This might be the issue I fixed here:
https://lore.kernel.org/qemu-devel/20250620130709.31073-18-phi...@linaro.org/
Note that app binaries compiled with older SDKs continue to retain a non-1 GHz
timer frequency on Apple M3/M4.
Signed-off-by: Mohamed Mediouni <moha...@unpredictable.fr>
---
target/arm/hvf/hvf.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index c9cfcdc08b..4331a3386a 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -1018,6 +1018,13 @@ int hvf_arch_init_vcpu(CPUState *cpu)
int i;
env->aarch64 = true;
+ /*
+ * TODO: This does not correspond to the exposed generic
+ * timer frequency to the guest on Apple M3/M4.
+ * This is due to a scaled 1GHz counter being exposed
+ * to applications built with newer SDKs when running
+ * on that silicon, while VMs get an unscaled counter.
+ */
asm volatile("mrs %0, cntfrq_el0" : "=r"(arm_cpu->gt_cntfrq_hz));