Repository navigation
telemetry: performance_monitor: fix manifest module entry offset - #11482
Shrusti-pk wants to merge 1 commit into
Conversation
|
Can one of the admins verify this patch?
|
|
test this please |
lgirdwood
left a comment
There was a problem hiding this comment.
@Shrusti-pk pls make sure you add your SOB. You have several patches that are good enough to merge currently but are missing a SOB (and we cant merge without it).
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the manifest-addressing and const-qualification changes.
No open issues 🎉
What changed in this PR
Fixes manifest traversal in SOF’s performance monitor so re-enabling measurements reads the intended module entries when reinitializing component performance data.
Changes:
- Applies module offsets to a byte pointer, avoiding incorrect scaling by the descriptor size.
- Preserves const qualification when accessing module records.
| File | Description |
|---|---|
src/kernel/debug/telemetry/performance_monitor.c |
Corrects manifest module addressing and makes the module pointer const. |
Review effort: Balanced
enable_performance_counters() adds SOF_MAN_MODULE_OFFSET(mod_id), a byte offset, to a const struct sof_man_fw_desc pointer. The pointer arithmetic scales it by sizeof(struct sof_man_fw_desc), so module entry 0 is read 2704 bytes into the manifest instead of 52, and entry i at 52 * (52 + 116 * i). instance_max_count is then taken from unrelated memory past the manifest, which can fault or drive up to 65535 bogus ipc4_get_comp_dev() lookups per module, and the real instances are not reinitialized. It runs on every IPC4_PERF_MEASUREMENTS_STATE change to STOPPED, STARTED or PAUSED, for the base firmware manifest and every loaded library. Cast the descriptor to a byte pointer before adding the offset, as the other SOF_MAN_MODULE_OFFSET() users in lib_manager.c, llext_manager.c and helper-kernel.c already do. Signed-off-by: Shrushti P K <shrusthi@labs.digiscrypt.com>
970ee70 to
c2866e5
Compare
|
Done, amended the commit with my sign-off and pushed; the code change itself is unchanged. I'll go through the other open ones and add the SOB there as well. |
enable_performance_counters()reads the wrong memory for every manifest module entry:descis aconst struct sof_man_fw_desc *, sodesc + SOF_MAN_MODULE_OFFSET(mod_id)scales the byte offset bysizeof(*desc)(52). Entry 0 is read atdesc + 2704instead ofdesc + 52, and entry i atdesc + 52 * (52 + 116 * i)instance_max_countcomes from that memory, so each module either faults or runs up to 65535ipc4_get_comp_dev()lookups on unrelated IDs, and the real instances never get their perf data reinitializedIPC4_PERF_MEASUREMENTS_STATEset to STOPPED, STARTED or PAUSED (set_perf_meas_state()), for the base FW manifest and every loaded librarySOF_MAN_MODULE_OFFSET()users (lib_manager.c, llext_manager.c, helper-kernel.c, base_fw_intel.c) already cast to a byte pointer firstChecked by building the function verbatim against a 3-module manifest laid out as rimage writes it: under ASan the old code is a heap-buffer-overflow READ 2380 bytes past the 400-byte manifest, and the fixed code reads entries at +52/+168/+284 and does the expected 15 lookups. I could not run it on hardware here.