-
Notifications
You must be signed in to change notification settings - Fork 369
Native sim support #10621
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
Native sim support #10621
Changes from 3 commits
4646eb0
b4acd7d
86ee176
9f1f68c
3282c00
dcd9bff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| CONFIG_ZEPHYR_POSIX=y | ||
| CONFIG_SYS_HEAP_BIG_ONLY=y | ||
| CONFIG_ZEPHYR_NATIVE_DRIVERS=y | ||
| CONFIG_ZEPHYR_LOG=y |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ SOF_DEFINE_REG_UUID(ipc_task_posix); | |
|
|
||
| static struct ipc *global_ipc; | ||
|
|
||
| #ifdef CONFIG_ARCH_POSIX_LIBFUZZER | ||
| // Not an ISR, called from the native_posix fuzz interrupt. Left | ||
| // alone for general hygiene. This is how a IPC interrupt would look | ||
| // if we had one. | ||
|
Comment on lines
+20
to
23
|
||
|
|
@@ -157,6 +158,7 @@ static void fuzz_isr(const void *arg) | |
|
|
||
| posix_ipc_isr(NULL); | ||
| } | ||
| #endif | ||
|
|
||
| // This API is... confounded by its history. With IPC3, the job of | ||
| // this function is to get a newly-received IPC message header (!) | ||
|
|
@@ -225,12 +227,14 @@ int ipc_platform_compact_read_msg(struct ipc_cmd_hdr *hdr, int words) | |
| // Re-raise the interrupt if there's still fuzz data to process | ||
| void ipc_platform_complete_cmd(struct ipc *ipc) | ||
| { | ||
| #ifdef CONFIG_ARCH_POSIX_LIBFUZZER | ||
| extern void posix_sw_set_pending_IRQ(unsigned int IRQn); | ||
|
|
||
| if (fuzz_in_sz > 0) { | ||
| posix_fuzz_sz = 0; | ||
| posix_sw_set_pending_IRQ(CONFIG_ZEPHYR_POSIX_FUZZ_IRQ); | ||
| } | ||
| #endif | ||
| } | ||
|
|
||
| int ipc_platform_send_msg(const struct ipc_msg *msg) | ||
|
|
@@ -253,8 +257,10 @@ void ipc_platform_send_msg_direct(const struct ipc_msg *msg) | |
|
|
||
| int platform_ipc_init(struct ipc *ipc) | ||
| { | ||
| #ifdef CONFIG_ARCH_POSIX_LIBFUZZER | ||
| IRQ_CONNECT(CONFIG_ZEPHYR_POSIX_FUZZ_IRQ, 0, fuzz_isr, NULL, 0); | ||
| irq_enable(CONFIG_ZEPHYR_POSIX_FUZZ_IRQ); | ||
| #endif | ||
|
|
||
| global_ipc = ipc; | ||
| schedule_task_init_edf(&ipc->ipc_task, SOF_UUID(ipc_task_posix_uuid), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,6 +54,23 @@ config SOF_ZEPHYR_HEAP_CACHED | |
| Enable cached heap by mapping cached SOF memory zones to different | ||
| Zephyr sys_heap objects and enable caching for non-shared zones. | ||
|
|
||
| config SOF_NATIVE_SIM_HOST_HEAP | ||
| bool "Use the host C library heap on native_sim" | ||
| depends on BOARD_NATIVE_SIM | ||
| default n | ||
|
Contributor
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. Thank you for dropping the default enabling. I checked the changes locally and had quite a few false positives from the leak sanitizer. The fuzzer has a significant problem with test case isolation and I'm not sure if it can be fully fixed. The long-term plan therefore is to keep the fuzzer with sys_heap, and the solution you are integrating here can be applied once I port the remaining unit tests, at that point it will be possible to take full advantage of the address, leak, and memory sanitizers. |
||
| help | ||
| When enabled on the native_sim board, SOF heap allocations | ||
| (rmalloc/rzalloc/rballoc/rfree etc.) are routed through the | ||
| host C library via the Zephyr native simulator host trampolines | ||
| (nsi_host_malloc/nsi_host_free). This makes tools like Valgrind | ||
| effective at finding heap errors in SOF code. | ||
|
|
||
| When disabled, the regular Zephyr sys_heap based implementation | ||
| is used, matching the behavior on real targets. This is the | ||
| default so that tooling relying on sys_heap (e.g. ASAN/fuzzer | ||
| setups) keeps working; enable it explicitly in memory-testing or | ||
| Valgrind-focused CI configurations. | ||
|
|
||
| config SOF_ZEPHYR_HEAP_SIZE | ||
| hex "Size of the Zephyr heap for SOF" | ||
| default 0x40000 if VIRTUAL_HEAP | ||
|
|
||
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.
can the second sentence be rephrased a bit like "Requesting registers from the QEMU Monitor?" I'm not sure I'd say "I'm going to interface with my neighbour to ask if they can borrow me 2 potatoes" :-)
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.
this reads fine.