f4ba2ea5 | 23-May-2025 |
Jaroslav Kysela <perex@perex.cz> |
firmware: cs_dsp: Fix OOB memory read access in KUnit test (ctl cache)
KASAN reported out of bounds access - cs_dsp_ctl_cache_init_multiple_offsets(). The code uses mock_coeff_template.length_bytes
firmware: cs_dsp: Fix OOB memory read access in KUnit test (ctl cache)
KASAN reported out of bounds access - cs_dsp_ctl_cache_init_multiple_offsets(). The code uses mock_coeff_template.length_bytes (4 bytes) for register value allocations. But later, this length is set to 8 bytes which causes test code failures.
As fix, just remove the lenght override, keeping the original value 4 for all operations.
Cc: Simon Trimmer <simont@opensource.cirrus.com> Cc: Charles Keepax <ckeepax@opensource.cirrus.com> Cc: Richard Fitzgerald <rf@opensource.cirrus.com> Cc: patches@opensource.cirrus.com Cc: stable@vger.kernel.org Signed-off-by: Jaroslav Kysela <perex@perex.cz> Reviewed-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20250523154151.1252585-1-perex@perex.cz Signed-off-by: Mark Brown <broonie@kernel.org>
show more ...
|
d979b783 | 23-May-2025 |
Jaroslav Kysela <perex@perex.cz> |
firmware: cs_dsp: Fix OOB memory read access in KUnit test (wmfw info)
KASAN reported out of bounds access - cs_dsp_mock_wmfw_add_info(), because the source string length was rounded up to the alloc
firmware: cs_dsp: Fix OOB memory read access in KUnit test (wmfw info)
KASAN reported out of bounds access - cs_dsp_mock_wmfw_add_info(), because the source string length was rounded up to the allocation size.
Cc: Simon Trimmer <simont@opensource.cirrus.com> Cc: Charles Keepax <ckeepax@opensource.cirrus.com> Cc: Richard Fitzgerald <rf@opensource.cirrus.com> Cc: patches@opensource.cirrus.com Cc: stable@vger.kernel.org Signed-off-by: Jaroslav Kysela <perex@perex.cz> Reviewed-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20250523155814.1256762-1-perex@perex.cz Signed-off-by: Mark Brown <broonie@kernel.org>
show more ...
|
42ae6e25 | 11-Feb-2025 |
Thomas Weißschuh <thomas.weissschuh@linutronix.de> |
firmware: cs_dsp: test_control_parse: null-terminate test strings
The char pointers in 'struct cs_dsp_mock_coeff_def' are expected to point to C strings. They need to be terminated by a null byte. H
firmware: cs_dsp: test_control_parse: null-terminate test strings
The char pointers in 'struct cs_dsp_mock_coeff_def' are expected to point to C strings. They need to be terminated by a null byte. However the code does not allocate that trailing null byte and only works if by chance the allocation is followed by such a null byte.
Refactor the repeated string allocation logic into a new helper which makes sure the terminating null is always present. It also makes the code more readable.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de> Fixes: 83baecd92e7c ("firmware: cs_dsp: Add KUnit testing of control parsing") Cc: stable@vger.kernel.org Reviewed-by: Richard Fitzgerald <rf@opensource.cirrus.com> Tested-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20250211-cs_dsp-kunit-strings-v1-1-d9bc2035d154@linutronix.de Signed-off-by: Mark Brown <broonie@kernel.org>
show more ...
|
ee37bc7e | 19-Dec-2024 |
Richard Fitzgerald <rf@opensource.cirrus.com> |
firmware: cs_dsp: Delete redundant assignments in cs_dsp_test_bin.c
Delete two redundant assignments in cs_dsp_test_bin.c.
Unfortunately none of W=1 or the static analysis tools I ran flagged these
firmware: cs_dsp: Delete redundant assignments in cs_dsp_test_bin.c
Delete two redundant assignments in cs_dsp_test_bin.c.
Unfortunately none of W=1 or the static analysis tools I ran flagged these.
Fixes: dd0b6b1f29b9 ("firmware: cs_dsp: Add KUnit testing of bin file download") Reported-by: Dheeraj Reddy Jonnalagadda <dheeraj.linuxdev@gmail.com> Closes: https://scan7.scan.coverity.com/#/project-view/52337/11354?selectedIssue=1602511 Closes: https://scan7.scan.coverity.com/#/project-view/52337/11354?selectedIssue=1602490 Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20241219155719.84276-1-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
show more ...
|
644115e8 | 17-Dec-2024 |
Richard Fitzgerald <rf@opensource.cirrus.com> |
firmware: cs_dsp: Fix endianness conversion in cs_dsp_mock_wmfw.c
In cs_dsp_mock_wmfw_add_coeff_desc() the value stored in longstring->len needs a cpu_to_le16() conversion.
Fixes: 5cf1b7b47180 ("fi
firmware: cs_dsp: Fix endianness conversion in cs_dsp_mock_wmfw.c
In cs_dsp_mock_wmfw_add_coeff_desc() the value stored in longstring->len needs a cpu_to_le16() conversion.
Fixes: 5cf1b7b47180 ("firmware: cs_dsp: Add mock wmfw file generator for KUnit testing") Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202412170233.8DnsdtY6-lkp@intel.com/ Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20241217105624.139479-1-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
show more ...
|
b0e4e203 | 16-Dec-2024 |
Arnd Bergmann <arnd@arndb.de> |
firmware: cs_dsp: avoid large local variables
Having 1280 bytes of local variables on the stack exceeds the limit on 32-bit architectures:
drivers/firmware/cirrus/test/cs_dsp_test_bin.c: In functio
firmware: cs_dsp: avoid large local variables
Having 1280 bytes of local variables on the stack exceeds the limit on 32-bit architectures:
drivers/firmware/cirrus/test/cs_dsp_test_bin.c: In function 'bin_patch_mixed_packed_unpacked_random': drivers/firmware/cirrus/test/cs_dsp_test_bin.c:2097:1: error: the frame size of 1784 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]
Use dynamic allocation for the largest two here.
Fixes: dd0b6b1f29b9 ("firmware: cs_dsp: Add KUnit testing of bin file download") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20241216121541.3455880-1-arnd@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
show more ...
|
75a4a6ef | 12-Dec-2024 |
Richard Fitzgerald <rf@opensource.cirrus.com> |
firmware: cs_dsp: Add KUnit testing of client callbacks
Test that the cs_dsp_client_ops callbacks are called when expected.
pre_run, post_run - when cs_dsp_run() is called. pre_stop, post_stop - wh
firmware: cs_dsp: Add KUnit testing of client callbacks
Test that the cs_dsp_client_ops callbacks are called when expected.
pre_run, post_run - when cs_dsp_run() is called. pre_stop, post_stop - when cs_dsp_stop() is called control_add - when a WMFW is loaded control_remove - when cs_dsp_remove() is called
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20241212143725.1381013-13-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
show more ...
|
feb5fb06 | 12-Dec-2024 |
Richard Fitzgerald <rf@opensource.cirrus.com> |
firmware: cs_dsp: Add KUnit testing of wmfw error cases
Add tests for various types of errors and illegal values in wmfw files. This covers buffer overflows as well as general unsupported field valu
firmware: cs_dsp: Add KUnit testing of wmfw error cases
Add tests for various types of errors and illegal values in wmfw files. This covers buffer overflows as well as general unsupported field values.
There are several sets of test cases to cover various different versions of the wmfw file format.
V0 format was only used on the earlier ADSP2 devices. It does not have algorithm blocks.
V1 format is used on all ADSP2 versions. It added algorithm blocks and firmware coefficient descriptor blocks. Strings are stored in fixed-length arrays.
V2 format is used on all ADSP2 versions. It is similar to V1 but space for strings is variable-length with either an 8-bit or 16-bit length field.
V3 format is used on Halo Core DSPs and is mostly identical to the V3 format.
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20241212143725.1381013-12-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
show more ...
|
cd8c0584 | 12-Dec-2024 |
Richard Fitzgerald <rf@opensource.cirrus.com> |
firmware: cs_dsp: Add KUnit testing of bin error cases
Add tests for various types of errors and illegal values in bin files. This covers buffer overflows as well as general unsupported field values
firmware: cs_dsp: Add KUnit testing of bin error cases
Add tests for various types of errors and illegal values in bin files. This covers buffer overflows as well as general unsupported field values.
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20241212143725.1381013-11-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
show more ...
|
fe54fd54 | 12-Dec-2024 |
Richard Fitzgerald <rf@opensource.cirrus.com> |
firmware: cs_dsp: Add KUnit testing of control read/write
Add KUnit test cases for control read/write.
Tests cases cover general reading and writing of controls: 1) Read/write at offset position in
firmware: cs_dsp: Add KUnit testing of control read/write
Add KUnit test cases for control read/write.
Tests cases cover general reading and writing of controls: 1) Read/write at offset position in control. 2) Read/write of various lengths less than length of the control. 3) Rejecting illegal arguments.
The test cases are run for ADSP2 with 16-bit registers, ADSP2 with 32-bit registers and Halo Core with 32-bit registers. The ADSP2 cases are further divided into runs for V1 and V2 format WMFW files, because there are differences in how V1 and V2 defines controls.
The obsolete V0 format does not have controls, so no testing of that format is needed.
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20241212143725.1381013-10-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
show more ...
|
9b33a4fc | 12-Dec-2024 |
Richard Fitzgerald <rf@opensource.cirrus.com> |
firmware: cs_dsp: Add KUnit testing of control cache
Add KUnit test cases for the caching of control content.
The test cases can be divided into four groups: 1) The cache is correctly initialized w
firmware: cs_dsp: Add KUnit testing of control cache
Add KUnit test cases for the caching of control content.
The test cases can be divided into four groups: 1) The cache is correctly initialized when the firmware is first downloaded. 2) Reads return the correct data. 3) Writes update the registers and cache. 4) If a value has been written to the control it is retained in the cache and written out to the registers when the firmware is started.
There are multiple test suites to cover: - V1 and V2 format files on 16-bit and 32-bit ADSP2. - V3 format files on Halo Core DSPs.
V1 format files, and some V2 format files, didn't provide access flags for the controls. There are a couple of test cases for unspecified flags to ensure backwards compatibility with the original implementation of these older firmware versions.
The obsolete V0 format does not have controls, so no testing of that format is needed.
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20241212143725.1381013-9-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
show more ...
|