Skip to content

Commit ae545eb

Browse files
kv2019ilgirdwood
authored andcommitted
docs: AGENTS.md: document the user/kernel boundary rules
Add a "User/kernel boundary" subsection under Development Standards that points contributors to src/include/sof/userspace/README.md and states the requirements for new code: place it in the correct directory tier, cross the boundary only via a validated syscall, and mark any globals shared with user threads with a partition marker. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
1 parent 3bc876e commit ae545eb

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

‎AGENTS.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,23 @@ This document outlines the rules AI agents must follow when checking out branche
2020
### Codestyle and Linting
2121
* **Standard:** Use `clangd` instead of `checkpatch` for codestyle verification.
2222
* **Rationale:** `checkpatch` is prone to confusion with assembly and non-standard C; `clangd` provides better integration with IDEs and AI tools and is easier to maintain.
23+
24+
### User/kernel boundary
25+
On PTL and other userspace configurations, audio application logic runs in Zephyr user-space
26+
while the OS/HAL stays in the kernel. The authoritative model, directory taxonomy, syscall map,
27+
memory-partition markers and Kconfig hierarchy are documented in
28+
[`src/include/sof/userspace/README.md`](src/include/sof/userspace/README.md). When adding or
29+
moving code, follow it:
30+
31+
* **Place code in the right tier.** OS/HAL/boot/inter-core → a kernel-only directory
32+
(`arch/`, `drivers/`, `idc/`, `init/`, `platform/`, `probe/`, `logging/`, `trace/`); audio
33+
application logic → `audio/`; reusable pure code → a shared-library directory (`lib/`,
34+
`math/`, `module/`) kept free of privileged operations. Each top-level directory's
35+
`README.md` states its tier in a "Runs in:" banner — keep it accurate.
36+
* **Cross the boundary only via a syscall.** Add a `__syscall` declaration, put the `z_vrfy_`
37+
validator in the boundary tier (preferably `zephyr/syscall/<subsystem>.c`), validate every
38+
user-supplied argument, and add the call to
39+
[`src/include/sof/userspace/syscalls.h`](src/include/sof/userspace/syscalls.h).
40+
* **Mark shared globals.** Any global a user thread reads or writes must carry a partition
41+
marker (`APP_TASK_*`, `APP_SYSUSER_*`, or a `K_APP_*` partition) at its declaration site, and
42+
kernel code must re-validate such data because it is user-writable.

0 commit comments

Comments
 (0)