Repository navigation
audio: aria: fix over-read of the internal ring buffer #11499
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -69,7 +69,7 @@ static void aria_algo_get_data(struct processing_module *mod, | |
| while (samples) { | ||
| m = cir_buf_samples_without_wrap_s32(out, sink->buf_end); | ||
| n = MIN(m, samples); | ||
| m = cir_buf_samples_without_wrap_s32(cd->data_ptr, cd->data_end); | ||
| m = cir_buf_samples_without_wrap_s32(in, cd->data_end); | ||
| n = MIN(m, n); | ||
| for (i = 0; i < n; i += ch_n) { | ||
| for (ch = 0; ch < ch_n; ch++) { | ||
|
Comment on lines
70
to
75
Member
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. While For Either keep
Contributor
Author
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. Went with rejecting it at prepare: aria_prepare() now checks that the source and sink buffers hold a whole number of frames and fails with -EINVAL otherwise. Handling a partial frame at the sink wrap would have meant restructuring all three get_data loops, and the HiFi5 circular addressing needs frame sized buffers anyway. It's its own commit, with a ztest case that connects a sink of 70 frames plus one sample and a source of 94 frames plus one sample and expects prepare to fail. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,10 +65,8 @@ static void aria_algo_get_data_odd_channel(struct processing_module *mod, | |
| /* do linear approximation between points gain_begin and gain_end */ | ||
| int32_t gain_end = cd->gains[sof_aria_index_tab[gain_state_add_3]]; | ||
| size_t samples = frames * cd->chan_cnt; | ||
| ae_int32x2 *out = sink->ptr; | ||
| const ae_int32x2 *in = (const ae_int32x2 *)cd->data_ptr; | ||
| ae_valign inu = AE_ZALIGN64(); | ||
| ae_valign outu = AE_ZALIGN64(); | ||
| ae_int32 *out = sink->ptr; | ||
| const ae_int32 *in = (const ae_int32 *)cd->data_ptr; | ||
| ae_int32x2 in_sample, out_sample; | ||
| const int inc = sizeof(ae_int32); | ||
| ae_int32x2 gain; | ||
|
|
@@ -90,22 +88,20 @@ static void aria_algo_get_data_odd_channel(struct processing_module *mod, | |
| while (samples) { | ||
| m = cir_buf_samples_without_wrap_s32(out, sink->buf_end); | ||
| n = MIN(m, samples); | ||
| m = cir_buf_samples_without_wrap_s32(cd->data_ptr, cd->data_end); | ||
| m = cir_buf_samples_without_wrap_s32(in, cd->data_end); | ||
| n = MIN(m, n); | ||
| inu = AE_LA64_PP(in); | ||
| for (i = 0; i < n; i += ch_n) { | ||
|
Comment on lines
+91
to
93
Member
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. Bug on HiFi3/HiFi4 when
However,
Also note that typing
Contributor
Author
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. AE_LA64_PP takes the pointer by value, so it can't move in; the prime and the AE_SA64POS_FP flush were dead code left over from the even channel path. The casts on the AE_L32_XP and AE_S32_L_XP operands are a real problem for clang though, so the odd channel path now uses ae_int32 pointers like the HiFi5 one and drops the align registers. It's a separate commit since it's a cleanup with no behaviour change. I still can't build the HiFi3 file here. |
||
| /*process data one by one if ch_n is odd*/ | ||
| for (ch = 0; ch < ch_n; ch++) { | ||
| AE_L32_XP(in_sample, (ae_int32 *)in, inc); | ||
| AE_L32_XP(in_sample, in, inc); | ||
| in_sample = AE_SRAI32(AE_SLAI32(in_sample, 8), 8); | ||
| out1 = AE_MUL32_HH(in_sample, gain); | ||
| out1 = AE_SRAA64(out1, shift_bits); | ||
| out_sample = AE_ROUND24X2F48SSYM(out1, out1); | ||
| AE_S32_L_XP(out_sample, (ae_int32 *)out, inc); | ||
| AE_S32_L_XP(out_sample, out, inc); | ||
| } | ||
| gain = AE_ADD32S(gain, step); | ||
| } | ||
| AE_SA64POS_FP(outu, out); | ||
| samples -= n; | ||
| in = cir_buf_wrap(in, cd->data_addr, cd->data_end); | ||
| out = cir_buf_wrap(out, sink->buf_start, sink->buf_end); | ||
|
|
@@ -150,7 +146,7 @@ static void aria_algo_get_data_even_channel(struct processing_module *mod, | |
| while (samples) { | ||
| m = cir_buf_samples_without_wrap_s32(out, sink->buf_end); | ||
| n = MIN(m, samples); | ||
| m = cir_buf_samples_without_wrap_s32(cd->data_ptr, cd->data_end); | ||
| m = cir_buf_samples_without_wrap_s32(in, cd->data_end); | ||
| n = MIN(m, n); | ||
| inu = AE_LA64_PP(in); | ||
| for (i = 0; i < n; i += ch_n) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| cmake_minimum_required(VERSION 3.20.0) | ||
|
|
||
| find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
| project(sof_unit_audio_aria) | ||
|
|
||
| set(SOF_ROOT "${PROJECT_SOURCE_DIR}/../../../../../") | ||
| set(sof_top_dir ${SOF_ROOT}) | ||
|
|
||
| include(${SOF_ROOT}/scripts/cmake/misc.cmake) | ||
| include(${SOF_ROOT}/scripts/cmake/uuid-registry.cmake) | ||
|
|
||
| target_include_directories(app PRIVATE | ||
| ${SOF_ROOT}/zephyr/include | ||
| ${SOF_ROOT}/src/include | ||
| ${SOF_ROOT}/src/kernel/platform/posix/include | ||
| ${SOF_ROOT}/src/platform/posix/include | ||
| ${SOF_ROOT}/src/audio/aria | ||
| ${SOF_ROOT}/tools/rimage/src/include | ||
| ${PROJECT_BINARY_DIR}/include/generated | ||
| ) | ||
|
|
||
| target_compile_definitions(app PRIVATE | ||
| -DCONFIG_ZEPHYR_POSIX=1 | ||
| -DCONFIG_LIBRARY=1 | ||
| -DUNIT_TEST=1 | ||
| ) | ||
|
|
||
| target_sources(app PRIVATE | ||
| aria_ztest.c | ||
| ${SOF_ROOT}/test/ztest/unit/common/alloc.c | ||
| ${SOF_ROOT}/test/ztest/unit/common/sof_context.c | ||
| ${SOF_ROOT}/src/audio/aria/aria.c | ||
| ${SOF_ROOT}/src/audio/aria/aria_generic.c | ||
| ${SOF_ROOT}/src/audio/module_adapter/module_adapter.c | ||
| ${SOF_ROOT}/src/audio/module_adapter/module_adapter_ipc4.c | ||
| ${SOF_ROOT}/src/audio/module_adapter/module/generic.c | ||
| ${SOF_ROOT}/src/audio/buffers/comp_buffer.c | ||
| ${SOF_ROOT}/src/audio/buffers/audio_buffer.c | ||
| ${SOF_ROOT}/src/audio/source_api_helper.c | ||
| ${SOF_ROOT}/src/audio/sink_api_helper.c | ||
| ${SOF_ROOT}/src/audio/sink_source_utils.c | ||
| ${SOF_ROOT}/src/audio/audio_stream.c | ||
| ${SOF_ROOT}/src/audio/component.c | ||
| ${SOF_ROOT}/src/audio/data_blob.c | ||
| ${SOF_ROOT}/src/module/audio/source_api.c | ||
| ${SOF_ROOT}/src/module/audio/sink_api.c | ||
| ${SOF_ROOT}/src/ipc/ipc4/helper.c | ||
| ${SOF_ROOT}/src/ipc/ipc-common.c | ||
| ${SOF_ROOT}/src/ipc/ipc-helper.c | ||
| ${SOF_ROOT}/src/lib/objpool.c | ||
| ${SOF_ROOT}/src/math/numbers.c | ||
| ) | ||
|
|
||
| target_link_libraries(app PRIVATE | ||
| "-Wl,--wrap=rzalloc,--wrap=rfree,--wrap=sof_heap_alloc,--wrap=sof_heap_free,--wrap=sof_sys_user_heap_get" | ||
| ) | ||
|
|
||
| # The standalone target compiles the full IPC4 helper translation unit while | ||
| # linking only its format helpers; other helper paths leave one local ID unused. | ||
| set_source_files_properties( | ||
| ${SOF_ROOT}/src/ipc/ipc4/helper.c | ||
| PROPERTIES COMPILE_OPTIONS "-Wno-unused-variable" | ||
| ) | ||
|
|
||
| sof_append_relative_path_definitions(app) |
Uh oh!
There was an error while loading. Please reload this page.