[Userspace LL] zephyr: cpu: turn cpu_get_id() into a system call - #11079
Open
kv2019i wants to merge 1 commit into
Open
[Userspace LL] zephyr: cpu: turn cpu_get_id() into a system call#11079kv2019i wants to merge 1 commit into
kv2019i wants to merge 1 commit into
Conversation
cpu_get_id() ultimately reads a privileged special register via arch_proc_id() (e.g. the Xtensa PRID register). When low-atency pipelines run in user-space threads (CONFIG_SOF_USERSPACE_LL), this read is issued from user mode and faults. While many direct usages of cpu_get_id() have been removed from SOF codebase, multiple usages remain. As the remaining usages are mostly on less frequently used code paths (most via cpu_is_me() call, which is used in IPC handling), opt to keep the remaining cpu_get_id() calls and make the function available as a system call. The system call machinery is gated on CONFIG_SOF_FULL_ZEPHYR_APPLICATION so unit-test builds keep the plain inline definition. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
kv2019i
requested review from
abonislawski,
dbaluta,
iuliana-prodan and
lyakh
as code owners
August 10, 2026 15:33
Collaborator
Author
|
For context, this is part of #10558 |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR makes cpu_get_id() available as a Zephyr system call so user-mode threads (notably CONFIG_SOF_USERSPACE_LL low-latency pipelines) can safely read the current core ID without faulting on privileged register access, while keeping unit-test builds on the existing plain inline implementation via CONFIG_SOF_FULL_ZEPHYR_APPLICATION.
Changes:
- Adds a userspace verification/marshalling entrypoint for
cpu_get_id()(z_vrfy_cpu_get_id()+ mrsh include). - Updates the Zephyr-side
sof/lib/cpu.hto exposecpu_get_id()as__syscalland providez_impl_cpu_get_id()inline implementations. - Hooks the syscall header generation and syscall source into the Zephyr build.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| zephyr/syscall/cpu.c | Adds the syscall verification wrapper for cpu_get_id() and includes the generated marshalling code. |
| zephyr/include/sof/lib/cpu.h | Converts cpu_get_id() into a Zephyr syscall (when CONFIG_SOF_FULL_ZEPHYR_APPLICATION is enabled) and supplies z_impl_cpu_get_id() implementations. |
| zephyr/CMakeLists.txt | Registers the syscall header for generation and compiles the syscall handler when userspace is enabled. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
cpu_get_id() ultimately reads a privileged special register via arch_proc_id() (e.g. the Xtensa PRID register). When low-atency pipelines run in user-space threads (CONFIG_SOF_USERSPACE_LL), this read is issued from user mode and faults. While many direct usages of cpu_get_id() have been removed from SOF codebase, multiple usages remain. As the remaining usages are mostly on less frequently used code paths (most via cpu_is_me() call, which is used in IPC handling), opt to keep the remaining cpu_get_id() calls and make the function available as a system call.
The system call machinery is gated on CONFIG_SOF_FULL_ZEPHYR_APPLICATION so unit-test builds keep the plain inline definition.