qemu-riscv64_smode_defconfig with function tracing enables ends in an
endless loop in notify_dynamic. When iterating over state->spy_head,
list_for_each_entry_safe() does not discover the end of the list.

The reason is that the address of state->spy_head has been relocated but
state->spy_head.next and state>spy_head.prev still point to the unrelocated
address. Therefore list_for_entry_safe() does not discover the end of the
list.

We cannot start tracing before initr_reloc().

When placing INITCALL(initr_trace) directly after INITCALL(initr_reloc) the
timer driver panics with

    Could not initialize timer (err -11).

Tracing uses the timer driver to add timestamps. The driver model needs
to be initialized to use the timer driver.

INITCALL(initr_trace) needs to be placed after INITCALL(initr_dm) in
initcall_run_r() to let the timer driver work properly.

Signed-off-by: Heinrich Schuchardt <[email protected]>
---
 common/board_r.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/board_r.c b/common/board_r.c
index 76f9fc090fb..2b8f5a423a6 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -604,7 +604,6 @@ static void initcall_run_r(void)
         * Please do not add logic to this function (variables, if (), etc.).
         * For simplicity it should remain an ordered list of function calls.
         */
-       INITCALL(initr_trace);
        INITCALL(initr_reloc);
        INITCALL(event_init);
        /* TODO: could x86/PPC have this also perhaps? */
@@ -635,6 +634,7 @@ static void initcall_run_r(void)
 #if CONFIG_IS_ENABLED(DM)
        INITCALL(initr_dm);
 #endif
+       INITCALL(initr_trace);
 #if CONFIG_IS_ENABLED(ADDR_MAP)
        INITCALL(init_addr_map);
 #endif
-- 
2.51.0

Reply via email to