-
Notifications
You must be signed in to change notification settings - Fork 366
ipc4: helper: unlock module instance verbs on native_sim #11062
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tmleman
wants to merge
1
commit into
thesofproject:main
Choose a base branch
from
tmleman:topic/upstream/pr/fuzzing/enhancement/part8
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+47
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1361,6 +1361,53 @@ __cold const struct comp_driver *ipc4_get_comp_drv(uint32_t module_id) | |
|
|
||
| #ifdef RIMAGE_MANIFEST | ||
| desc = (const struct sof_man_fw_desc *)IMR_BOOT_LDR_MANIFEST_BASE; | ||
| #elif defined(CONFIG_ARCH_POSIX_LIBFUZZER) | ||
| /* | ||
| * native_sim fuzz builds have no rimage manifest so ipc4_get_comp_drv() | ||
| * would always return NULL, making every module instance verb | ||
| * (INIT_INSTANCE, CONFIG_GET/SET, LARGE_CONFIG, BIND, UNBIND, | ||
| * DELETE_INSTANCE) unreachable from the fuzzer. | ||
| * | ||
| * Mirror the IPC3 whitebox hack in posix/ipc.c: treat module_id as a | ||
| * 1-based index into the runtime comp_driver list. module_id 0 (BaseFW) | ||
| * has no comp_driver entry and is handled separately above via | ||
| * ipc4_get_drv(); non-zero ids map to registered drivers so the fuzzer | ||
| * can create real module instances with valid driver UUIDs. | ||
| */ | ||
|
Comment on lines
+1365
to
+1376
|
||
| if (module_id) { | ||
| struct comp_driver_list *dlist = comp_drivers_get(); | ||
| struct list_item *iter; | ||
| uint32_t idx = 0; | ||
|
|
||
| list_for_item(iter, &dlist->list) { | ||
| struct comp_driver_info *inf = | ||
| container_of(iter, struct comp_driver_info, list); | ||
|
|
||
| /* Only count drivers that can be instantiated — | ||
| * skip BaseFW and other query-only entries that | ||
| * have no create op. | ||
| */ | ||
| if (!inf->drv->ops.create) | ||
| continue; | ||
|
|
||
| /* | ||
| * A real signed manifest only lists module-adapter | ||
| * modules. The internal gateway drivers (SOF_COMP_HOST, | ||
| * SOF_COMP_DAI) are registered for IPC3 but are never | ||
| * IPC4 modules: on the IPC4 path they receive no params() | ||
| * pass and cannot be configured (e.g. their DMA buffer is | ||
| * never allocated). Skip non-module-adapter drivers here | ||
| * so the fuzzer's module_id space matches a real manifest | ||
| * and cannot map to an unconfigurable component. | ||
| */ | ||
| if (inf->drv->type != SOF_COMP_MODULE_ADAPTER) | ||
| continue; | ||
|
|
||
| if (++idx == module_id) | ||
| return inf->drv; | ||
| } | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. may be useful to log that fall through if nothing found to assist developers/agents here. |
||
| return NULL; | ||
| #else | ||
| /* Non-rimage platforms have no component facility yet. | ||
| * This needs to move to the platform layer. | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
helper.c is a rather intensely used file, so cutting a large chunk of code that is only needed for the fuzzer in the middle of a function looks a bit suboptimal to me. Can we make it a separate function and just do
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be better for readability indeed.