mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-02-26 08:06:55 +00:00
target/arm: support reading of CNT[VCT|FRQ]_EL0 from user-space
Since kernel commit a86bd139f2 (arm64: arch_timer: Enable CNTVCT_EL0 trap..), released in kernel version v4.12, user-space has been able to read these system registers. As we can't use QEMUTimer's in linux-user mode we just directly call cpu_get_clock(). Backports commit 26c4a83bd4707797868174332a540f7d61288d15 from qemu
This commit is contained in:
parent
a325de6685
commit
85512a5121
|
@ -1889,11 +1889,27 @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
#else
|
#else
|
||||||
/* In user-mode none of the generic timer registers are accessible,
|
/* In user-mode most of the generic timer registers are inaccessible
|
||||||
* and their implementation depends on QEMU_CLOCK_VIRTUAL and qdev gpio outputs,
|
* however modern kernels (4.12+) allow access to cntvct_el0
|
||||||
* so instead just don't register any of them.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static uint64_t gt_virt_cnt_read(CPUARMState *env, const ARMCPRegInfo *ri)
|
||||||
|
{
|
||||||
|
/* Currently we have no support for QEMUTimer in linux-user so we
|
||||||
|
* can't call gt_get_countervalue(env), instead we directly
|
||||||
|
* call the lower level functions.
|
||||||
|
*/
|
||||||
|
return cpu_get_clock() / GTIMER_SCALE;
|
||||||
|
}
|
||||||
|
|
||||||
static const ARMCPRegInfo generic_timer_cp_reginfo[] = {
|
static const ARMCPRegInfo generic_timer_cp_reginfo[] = {
|
||||||
|
{ "CNTFRQ_EL0", 0,14,0, 3,3,0, ARM_CP_STATE_AA64,
|
||||||
|
ARM_CP_CONST, PL0_R /* no PL1_RW in linux-user */, 0, NULL, NANOSECONDS_PER_SECOND / GTIMER_SCALE,
|
||||||
|
offsetof(CPUARMState, cp15.c14_cntfrq),
|
||||||
|
},
|
||||||
|
{ "CNTVCT_EL0", 0,14,0, 3,3,2, ARM_CP_STATE_AA64, ARM_CP_NO_RAW | ARM_CP_IO,
|
||||||
|
PL0_R, 0, NULL, 0, 0, 0, NULL, gt_virt_cnt_read,
|
||||||
|
},
|
||||||
REGINFO_SENTINEL
|
REGINFO_SENTINEL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue