return ret;
}
+static uint64_t get_cntfrq_el0(void)
+{
+ uint64_t freq_hz = 0;
+ asm volatile("mrs %0, cntfrq_el0" : "=r"(freq_hz));
+ return freq_hz;
+}
+
int hvf_arch_init_vcpu(CPUState *cpu)
{
ARMCPU *arm_cpu = ARM_CPU(cpu);
int i;
env->aarch64 = true;
- asm volatile("mrs %0, cntfrq_el0" : "=r"(arm_cpu->gt_cntfrq_hz));
+
+ /* system count frequency sanity check */
+ assert(arm_cpu->gt_cntfrq_hz == get_cntfrq_el0());
/* Allocate enough space for our sysreg sync */
arm_cpu->cpreg_indexes = g_renew(uint64_t, arm_cpu->cpreg_indexes,
bool hvf_arch_cpu_realize(CPUState *cs, Error **errp)
{
+ ARMCPU *cpu = ARM_CPU(cs);
+
+ /*
+ * We must set the counter frequency HVF will be using
+ * early, before arm_cpu_realizefn initializes the timers
+ * with it.
+ */
+ cpu->gt_cntfrq_hz = get_cntfrq_el0();
+
return true;
}