Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/audio/microwakeword/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ set(FLATBUFFERS_PATH ${sof_top_dir}/../flatbuffers)
set(GEMMLOWP_PATH ${sof_top_dir}/../gemmlowp)
set(RUY_PATH ${sof_top_dir}/../ruy)

# Zephyr's -fmacro-prefix-map options don't reach the plain add_library()
# targets below, so TFLM's __FILE__ strings would embed the absolute host
# path and make the firmware differ between build machines.
get_filename_component(MWW_TOPDIR ${sof_top_dir}/.. ABSOLUTE)
set(MWW_PREFIX_MAP -fmacro-prefix-map=${MWW_TOPDIR}=WEST_TOPDIR)

set(MWW_TOOLCHAIN_LIBC_ARCHIVE "")
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
execute_process(
Expand Down Expand Up @@ -204,6 +210,7 @@ target_compile_options(mww_tflm_lib PRIVATE
-fno-tree-slp-vectorize
-ffunction-sections
-fdata-sections
${MWW_PREFIX_MAP}
-imacros ${AUTOCONF_H}
)

Expand Down Expand Up @@ -292,6 +299,7 @@ if(CONFIG_COMP_MWW_HIFI_NNLIB AND ZEPHYR_TOOLCHAIN_VARIANT STREQUAL "xt-clang")
-Dgcd=xa_nn_gcd
-ffunction-sections
-fdata-sections
${MWW_PREFIX_MAP}
)
set(MWW_NN_HIFI_LIB mww_nn_hifi_lib)
else()
Expand Down
5 changes: 5 additions & 0 deletions src/audio/microwakeword/llext/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ set(GEMMLOWP_PATH ${sof_top_dir}/../gemmlowp)
set(RUY_PATH ${sof_top_dir}/../ruy)
set(NN_HIFI_PATH ${sof_top_dir}/../nnlib-hifi4/xa_nnlib)

# Keep absolute host paths out of TFLM's __FILE__ strings, see
# ../CMakeLists.txt.
get_filename_component(MWW_TOPDIR ${sof_top_dir}/.. ABSOLUTE)

set(MWW_TOOLCHAIN_ROOT "")
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
execute_process(
Expand Down Expand Up @@ -191,6 +195,7 @@ target_compile_options(mww_tflm_lib PRIVATE
# ET_DYN/PIC LLEXT.
-DTF_LITE_STRIP_ERROR_STRINGS
-DNDEBUG
-fmacro-prefix-map=${MWW_TOPDIR}=WEST_TOPDIR
-imacros ${AUTOCONF_H}
)

Expand Down
26 changes: 25 additions & 1 deletion src/platform/posix/ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ extern size_t posix_fuzz_sz;
static uint8_t fuzz_in[65536];
static size_t fuzz_in_sz;

/* Set on the driver thread by posix_fuzz_case_begin(), consumed on the EDF
* workqueue thread by ipc_platform_do_cmd(). See posix_fuzz_case_begin().
*/
static bool posix_fuzz_teardown_pending;

/*
* posix_ipc_teardown - drop all IPC-tracked objects left over from the
* previous fuzz testcase so the next one starts from a clean topology.
Expand Down Expand Up @@ -194,7 +199,15 @@ static void posix_ipc_teardown(void)
*/
void posix_fuzz_case_begin(void)
{
posix_ipc_teardown();
/*
* Defer the teardown to the EDF workqueue thread (ipc_platform_do_cmd()).
* This runs on the libFuzzer driver thread, where native_sim treats the
* CPU as halted; posix_ipc_teardown() releases spinlocks/mutexes, and
* releasing a spinlock while the system-tick IRQ is pending makes
* native_sim deliver it synchronously and abort ("called from a HW model
* thread").
*/
posix_fuzz_teardown_pending = true;
fuzz_in_sz = 0;
}

Expand Down Expand Up @@ -362,6 +375,17 @@ enum task_state ipc_platform_do_cmd(struct ipc *ipc)
{
struct ipc_cmd_hdr *hdr;

#ifdef CONFIG_ARCH_POSIX_LIBFUZZER
/*
* Reclaim the previous testcase's topology in thread context, before
* this testcase's first command. See posix_fuzz_case_begin().
*/
if (posix_fuzz_teardown_pending) {
posix_fuzz_teardown_pending = false;
posix_ipc_teardown();
}
#endif

#ifdef CONFIG_IPC_MAJOR_4
memset(posix_hostbox, 0, SOF_IPC_MSG_MAX_SIZE);
memcpy(posix_hostbox,
Expand Down
Loading