Skip to content

Commit

Permalink
target/arm: Ensure icount is enabled when emulating INST_RETIRED
Browse files Browse the repository at this point in the history
pmu_init() register its event checking the pm_event::supported()
handler. For INST_RETIRED, the event is only registered and the
bit enabled in the PMU Common Event Identification register when
icount is enabled as ICOUNT_PRECISE.

PMU events are TCG-only, hardware accelerators handle them
directly. Unfortunately we register the events in non-TCG builds,
leading to linking error such:

  ld: Undefined symbols:
    _icount_to_ns, referenced from:
      _instructions_ns_per in target_arm_helper.c.o
  clang: error: linker command failed with exit code 1 (use -v to see invocation)

As a kludge, give a hint to the compiler by asserting the
pm_event::get_count() and pm_event::ns_per_count() handler will
only be called under this icount mode.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20231208113529.74067-5-philmd@linaro.org>
  • Loading branch information
philmd committed Jan 19, 2024
1 parent 8e98c27 commit 2412813
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions target/arm/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -954,11 +954,13 @@ static bool instructions_supported(CPUARMState *env)

static uint64_t instructions_get_count(CPUARMState *env)
{
assert(icount_enabled() == ICOUNT_PRECISE);
return (uint64_t)icount_get_raw();
}

static int64_t instructions_ns_per(uint64_t icount)
{
assert(icount_enabled() == ICOUNT_PRECISE);
return icount_to_ns((int64_t)icount);
}
#endif
Expand Down

0 comments on commit 2412813

Please sign in to comment.