hw/timer/armv7m_systick: assert that board code set system_clock_scale
PATCH 1/1 hw/timer/armv7m_systick: assert that board code set system_clock_scale
It is the responsibility of board code for an armv7m system to set system_clock_scale appropriately for the CPU speed of the core. If it forgets to do this, then QEMU will hang if the guest tries to use the systick timer in the "tick at the CPU clock frequency" mode.
We forgot that in a couple of our boards (see commits ce4f70e81ed23c93f, e7e5a9595ab1136). Add an assertion in the systick reset method so we don't let any new boards in with the same bug.
---
In the longer term we should make this a clocktree input and plumb it through the armv7m container and so on, but for the moment this assert() improves the current situation.
--- hw/timer/armv7m_systick.c | 8 ++++++++ 1 file changed, 8 insertions(+)
hw/timer/armv7m_systick.c +8 -0
@@ -202,6 +202,14 @@ static void systick_reset(DeviceState *dev) {SysTickState *s =SYSTICK (dev); +/* +* Forgetting to set system_clock_scale is always a board code +* bug. We can't check this earlier because for some boards +* (like stellaris) it is not yet configured at the point where +* the systick device is realized. +*/ +assert (system_clock_scale !=0 ); + s->control =0 ; s->reload =0 ; s->tick =0 ;
Signature · 1 line
2.20.1
Le mar. 25 août 2020 18:09, Peter Maydell <[email protected]> a écrit :
Quoted 11 lines
It is the responsibility of board code for an armv7m system to set
system_clock_scaleappropriately for the CPU speed of the core. If it forgets to do this, then QEMU will hang if the guest tries to use the systick timer in the "tick at the CPU clock frequency" mode.We forgot that in a couple of our boards (see commits
ce4f70e81ed23c93f,e7e5a9595ab1136). Add an assertion in the systick reset method so we don't let any new boards in with the same bug.Signed-off-by Peter Maydell <[email protected]>
---
Quoted 31 lines
In the longer term we should make this a clocktree input and plumb it through the armv7m container and so on, but for the moment this
assert()improves the current situation.--- hw/timer/armv7m_systick.c | 8 ++++++++ 1 file changed, 8 insertions(+)hw/timer/armv7m_systick.c +8
-1@@ -202,6 +202,14 @@ static void systick_reset(DeviceState *dev) {SysTickState *s =SYSTICK (dev); +/* +* Forgetting to set system_clock_scale is always a board code +* bug. We can't check this earlier because for some boards +* (like stellaris) it is not yet configured at the point where +* the systick device is realized. +*/ +assert (system_clock_scale !=0 ); + s->control =0 ; s->reload =0 ; s->tick =0 ; --2.20.1