Skip to content

ipc: Safely aborting thread during SOF_IPC4_MOD_INIT_INSTANCE if module crashes - #11485

Draft
adityaganeshintel2k wants to merge 8 commits into
thesofproject:mainfrom
adityaganeshintel2k:ag-userspace-handler
Draft

adityaganeshintel2k wants to merge 8 commits into
thesofproject:mainfrom
adityaganeshintel2k:ag-userspace-handler

Conversation

@adityaganeshintel2k

Copy link
Copy Markdown

This adds capability of aborting a userspace thread if it crashes during SOF_IPC4_MOD_INIT_INSTANCE and reporting this back to host with a known error status instead of sending a panic notification to host for a dsp reboot

@sofci

sofci commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

reply test this please to run this test once

Signed-off-by: Ganesh, Aditya <aditya.ganesh@intel.com>
This enables aborting a userspace thread if an exception occurs
from userspace context on intel adsp ace platforms

Signed-off-by: Ganesh, Aditya <aditya.ganesh@intel.com>
This adds a syscall so that we can call k_thread_cpu_pin
from userspace

Signed-off-by: Ganesh, Aditya <aditya.ganesh@intel.com>
This adds capability of invoking a thread for module initialization
and is tied to the same core as the ipc_user thread invoking the
module initialization

Signed-off-by: Ganesh, Aditya <aditya.ganesh@intel.com>
This invokes a thread to complete the module initialization.
This is done so that if the module crashes during initialization
it can be safely reported back to host without crashing the adsp

Signed-off-by: Ganesh, Aditya <aditya.ganesh@intel.com>
Signed-off-by: adityaganeshintel2k <aditya.ganesh@intel.com>
This setups up the ipc user init thread required for
module initialization

Signed-off-by: Ganesh, Aditya <aditya.ganesh@intel.com>
…erified

This adds the capability of aborting a user thread if kernel oops is raised from
a syscall verifier

Signed-off-by: Ganesh, Aditya <aditya.ganesh@intel.com>

@kv2019i kv2019i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comment inline. Need to think more about the approach. Wrapping possible unsafe calls to a worker thread is clearly one option, but I'm concerned about the complexity.

/** @brief Per-core helper thread objects used for INIT_INSTANCE processing */
struct k_thread *init_thread[IPC_DSP_CORE_COUNT];
/** @brief Per-core stacks for the INIT_INSTANCE helper threads */
k_thread_stack_t *init_stack[IPC_DSP_CORE_COUNT];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit worried about the overhead of having additional threads. If we need a monitor thread for each thread, that is sizable memory usage and consumes precious local RAM we have. Ok for testing, but I wonder if we could use some kernel workqueue to monitor threads that should be running, or just have a sinlge watchdog thread.

thread = ipc_user->init_thread[core];
ipc_user->init_result = IPC4_MOD_NOT_INITIALIZED;

k_thread_create(thread, ipc_user->init_stack[core],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, need to think about this. This does clearly isolate the places where we can handle crashes, but given the IPC code is already complex, wrapping each call with jump to another thread, makes this even more complex.

I wonder should we take another look can we somehow make the IPC kernel-user forwarder function reliably detect if the thread it talks to, has crashed. We use semaphores now? Could we just use a timeout and report an error back that connection was lost fo IPC user thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants