Repository navigation
Conversation
tmleman
requested review from
abonislawski,
dbaluta,
iuliana-prodan,
kv2019i,
lbetlej,
lgirdwood,
lyakh,
mmaka1 and
plbossart
as code owners
November 19, 2026 10:54
tmleman
force-pushed
the
topic/upstream/pr/posix/add_virtual_dai
branch
from
November 19, 2026 10:57
af62a32 to
d75abe4
Compare
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Comments in dai_virtual.c overstate truncated-message detection because reads into zero-filled allocation padding remain valid to sanitizers, so the claims need to be limited to allocation bounds.
1 open issue
What changed in this PR
Adds a configuration-only virtual DAI backend so the native_sim IPC fuzzer can reach SOF’s generic DAI setup paths without audio hardware.
Changes:
- Defines virtual SSP, DMIC, HDA, ALH, and UAOL devices through devicetree.
- Implements configuration, property, lifecycle, trigger, and timestamp callbacks without moving audio.
- Integrates the backend with fuzz configuration, build rules, and standard DAI lookup.
| File | Description |
|---|---|
zephyr/CMakeLists.txt |
Builds the virtual driver when enabled. |
src/kernel/platform/posix/dai_virtual.c |
Implements the configuration-only virtual DAI backend. |
src/kernel/platform/Kconfig |
Adds the fuzz-scoped DAI_POSIX option. |
src/kernel/lib/dai-kernel.c |
Includes virtual devices in standard DAI enumeration. |
app/dts/bindings/dai/zephyr,posix-dai.yaml |
Defines device type, index, and FIFO-depth properties. |
app/configs/fuzz_features.conf |
Enables virtual DAIs for fuzz builds. |
app/boards/native_sim.overlay |
Declares 16 virtual DAI instances across five types. |
Review effort: Balanced
PR 11493: test resultsRun date: 2026-11-20 13:17 UTC Tested commit: dca35b691a4789b186dd2316cbb043610ad5b690 |
lgirdwood
approved these changes
Nov 19, 2026
Member
|
@tmleman can you resolve the copilot comment and check the CI thanks ! |
tmleman
force-pushed
the
topic/upstream/pr/posix/add_virtual_dai
branch
from
November 20, 2026 11:52
d75abe4 to
dca35b6
Compare
native_sim has no audio hardware and no registered Zephyr DAI device, so zephyr_dev[] is empty and dai_get_device() can never match. Every DAI gateway request therefore failed at copier_dai_create -> dai_common_new -> dai_get -> dai_get_device which hid the whole generic SOF DAI construction, configuration and property layer from the IPC fuzzer. Add a devicetree-described virtual DAI backend for the POSIX platform and include it in the native DAI enumeration behind the new CONFIG_DAI_POSIX, enabled only by the fuzz feature configuration. The overlay declares SSP 0-3, DMIC 0-1, HDA 0-3, ALH 0-3 and UAOL 0-1, so a gateway node id carrying a realistic index resolves to a device. The model is deliberately configuration-only: probe/remove, config set/get, trigger, the timestamping ops and the properties SOF queries (FIFO address and depth, handshake id, stream id) are implemented, the type-specific blob is read through but never parsed, and no data is moved. Reading every byte of the host supplied blob lets the sanitizers validate the (pointer, size) pair the IPC layer hands down, which memcpy_s() cannot do because it only guards the destination. Reporting a rate and channel count of zero keeps dai_verify_params() from rejecting otherwise valid streams, and prepare still stops cleanly in the POSIX DMA model, which does not implement the transfer contract yet. The driver is placed under the kernel tier (src/kernel/platform/posix/) and hooked into zephyr_dev[] in src/kernel/lib/dai-kernel.c, following the user/kernel split introduced after the original change. Using the devicetree device model means the production dai_get_device() lookup is exercised unmodified, with no fuzz specific branching in shared firmware code. Verified on IPC3 and IPC4 builds under both ASan and UBSan. Crafted copier INIT_INSTANCE seeds covering nine gateway classes hit copier_dai_create() 36 times, dai_get_device() 20 times, dai_common_new() 20 times, posix_dai_probe() 18 times, posix_dai_config_set() 18 times and dai_set_config() 18 times. Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
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.

native_sim has no audio hardware and no registered Zephyr DAI device, so zephyr_dev[] is empty and dai_get_device() can never match. Every DAI gateway request therefore failed at
copier_dai_create -> dai_common_new -> dai_get -> dai_get_device
which hid the whole generic SOF DAI construction, configuration and property layer from the IPC fuzzer.
Add a devicetree-described virtual DAI backend for the POSIX platform and include it in the native DAI enumeration behind the new CONFIG_DAI_POSIX, enabled only by the fuzz feature configuration. The overlay declares SSP 0-3, DMIC 0-1, HDA 0-3, ALH 0-3 and UAOL 0-1, so a gateway node id carrying a realistic index resolves to a device.
The model is deliberately configuration-only: probe/remove, config set/get, trigger, the timestamping ops and the properties SOF queries (FIFO address and depth, handshake id, stream id) are implemented, the type-specific blob is read through but never parsed, and no data is moved. Reading every byte of the host supplied blob lets the sanitizers validate the (pointer, size) pair the IPC layer hands down, which memcpy_s() cannot do because it only guards the destination. Reporting a rate and channel count of zero keeps dai_verify_params() from rejecting otherwise valid streams, and prepare still stops cleanly in the POSIX DMA model, which does not implement the transfer contract yet.
The driver is placed under the kernel tier (src/kernel/platform/posix/) and hooked into zephyr_dev[] in src/kernel/lib/dai-kernel.c, following the user/kernel split introduced after the original change. Using the devicetree device model means the production dai_get_device() lookup is exercised unmodified, with no fuzz specific branching in shared firmware code.
Verified on IPC3 and IPC4 builds under both ASan and UBSan. Crafted copier INIT_INSTANCE seeds covering nine gateway classes hit copier_dai_create() 36 times, dai_get_device() 20 times, dai_common_new() 20 times, posix_dai_probe() 18 times, posix_dai_config_set() 18 times and dai_set_config() 18 times.