Commit Graph

190 Commits

Author SHA1 Message Date
Keyon Jie 44b37d19a2 config: sue: change image_size to the real SRAM size
We have 47 bank HP and 1 bank LP SRAM on Suecreek, change the toml config file
to reflect that.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2021-07-21 11:58:20 +01:00
Rander Wang 580e4d674e config: tgl-cavs: change image_size to the real SRAM size
Apply "config: tgl: change image_size to the real SRAM size"
(9e50a02f1b) to tgl-cavs

Signed-off-by: Rander Wang <rander.wang@intel.com>
2021-07-21 18:03:59 +08:00
Keyon Jie 9a26e45580 config: apl: change image_size to the real SRAM size
We have 8 bank HP and 2 bank LP SRAM on APL, change to toml config file
to reflect that.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2021-07-02 12:51:46 +01:00
Keyon Jie 8a2ea0044d config: cnl: change image_size to the real SRAM size
We have 47 bank HP and 1 bank LP SRAM on CNL, change to toml config file
to reflect that.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2021-07-02 12:51:46 +01:00
Keyon Jie 1de9ccca33 config: jsl: change image_size to the real SRAM size
We have 16 bank HP and 1 bank LP SRAM on JSL, change to toml config file
to reflect that.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2021-07-02 12:51:46 +01:00
Keyon Jie f52a078aad config: icl: change image_size to the real SRAM size
We have 47 bank HP and 1 bank LP SRAM on ICL, change to toml config file
to reflect that.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2021-07-02 12:51:46 +01:00
Keyon Jie 8073ea3ef9 config: tgl-h: change image_size to the real SRAM size
We have 30 bank HP and 1 bank LP SRAM on TGL-H, change to toml config file
to reflect that.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2021-07-02 12:51:46 +01:00
Keyon Jie 9e50a02f1b config: tgl: change image_size to the real SRAM size
We have 46 bank HP and 1 bank LP SRAM on TGL, change to toml config file
to reflect that.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2021-07-02 12:51:46 +01:00
Slawomir Blauciak 5aeb95b19b sanity check allocated memory
Issue detected by Klocwork

Signed-off-by: Slawomir Blauciak <slawomir.blauciak@linux.intel.com>
2021-05-26 13:22:32 +01:00
Curtis Malainey 6f45b61921 actions: add cppcheck and yamllint
CI saves lives

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
2021-05-19 11:12:14 +01:00
Curtis Malainey 7764a8bd31 manifest: close file on error
found via cppcheck

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
2021-05-19 11:12:14 +01:00
Curtis Malainey 1cca9bf01d ext_manifest: cppcheck: refactor to silence false positive
memory clearly has exit path through argument, factor out temporary
variable to silence cppcheck

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
2021-05-19 11:12:14 +01:00
Curtis Malainey 8f42ee88cc adsp_config: fix out of bounds error
cppcheck find

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
2021-05-19 11:12:14 +01:00
Karol Trzcinski 0297c671fc config: Fix 'module' parsing error messages
'key' argument must describe 'key' which triggered error message
to keep stderr output helpful.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2021-05-05 12:26:10 +01:00
Karol Trzcinski 994ee247e1 ext_man: Fix code formating
Function parameters should be separated by ', '.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2021-04-27 11:08:40 +01:00
Karol Trzcinski 6c44aefb1f ext_man: Fix memory leak after manifest build
sec_buffer allocated inside elf_read_section()
was not being freed before and is freed now.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2021-04-27 11:08:40 +01:00
Rander Wang dbb49e03b9 rimage: add cavs fw layout support
Add support of cavs extended manifest and modules. Now
we will have another config tgl-cavs for tgl.

Signed-off-by: Rander Wang <rander.wang@intel.com>
2021-04-21 09:13:28 +01:00
Marc Herbert 0d641a7b05 minor -h fix: -s meu_offset disables rimage signing
It wasn't exactly obvious who does what.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-03-09 20:15:02 +00:00
Marc Herbert 0dba230832 pkcs_v1_5_sign_man_v2_5(): add "salt length" comment
This comment is meant for "git grep salt", that's its main purpose.

Much more obvious timestamps aside, this new code is the only
non-deterministic part of rimage - learned the very hard way
(OpenSSL "documentation" calls it "sLen"...)

A/B testing of build system changes is much, much easier when
locally and temporarily making the build 100% deterministic.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-01-06 11:05:07 +00:00
Pan Xiuli d1f91efdc1 config: add tgl-h toml file to support tglh build
Add tgl-h toml file to support sof-tgl-h.ri binary build

Signed-off-by: Pan Xiuli <xiuli.pan@linux.intel.com>
2020-12-07 09:54:14 +00:00
Pan Xiuli 2e29db4523 config: merge icl and jsl toml file
ICL and JSL is same DSP with differnt HW config.
They can share same toml file

Signed-off-by: Pan Xiuli <xiuli.pan@linux.intel.com>
2020-12-07 09:54:14 +00:00
Liam Girdwood 7b7c192e70 verify: add signature verification support
Add support to verify signatures of cavs firmware binaries.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2020-11-16 11:56:58 +00:00
Liam Girdwood 1c1c09ce7e manifest: cavs25: Add support for ext data type 0x16
This type was used by early versions of meu, but the hash is not
used in later versions. Leave the code in in case it has to come back.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2020-11-16 11:56:58 +00:00
Liam Girdwood db40934e57 cavs: add support for cavs2.5 code signing
cavs 2.5 uses a larger key and the RSA signing PSS mode.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2020-11-16 11:56:58 +00:00
Liam Girdwood 68b3693de1 plat_auth: use cavs 2.5 plat auth offsets
cavs2.5 has different offsets for plat auth data.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2020-11-16 11:56:58 +00:00
Liam Girdwood f84676f5d9 hash: make module_sha384_create non static.
Used by other clients now.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2020-11-16 11:56:58 +00:00
Liam Girdwood df204853b9 pkcs: Add PSS signing mechanism for CAVS2.5
Add RSA PSS signing support for CAVS 2.5 platforms.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2020-11-16 11:56:58 +00:00
Liam Girdwood 0c3f8e29c5 user: manifest: add macros for SHA385 modulus length
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2020-11-16 11:56:58 +00:00
Liam Girdwood 7e9952f2c8 manifest: Add cavs2.5 structures and offsets
cavs2.5 has different offsets and structures.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2020-11-16 11:56:58 +00:00
Jaska Uimonen 8478c03483 cse: add simple crc32 function to calculate the v2.5 header checksum
Add simple crc32 function to calculate the checksum for v2.5 headers.
Implementation is very simple using shift register as we don't require
speed. Calculate the v2.5 header checksum with crc-32/iso-hdlc
parameters.

Signed-off-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2020-11-16 11:56:58 +00:00
Liam Girdwood 48ba01ec45 css: add css header for cavs v2.5
Header contests are the same but with bigger key.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2020-11-16 11:56:58 +00:00
Liam Girdwood d6cf696066 config: tgl: fix CSE offsets for TGL
Now aligns with actual offsets.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2020-11-16 11:56:58 +00:00
Marc Herbert f0fa6616ea README: install is optional and missed "sudo". CMake 3.13 -B option.
Also show useful "make help" that lists all targets.

Show -B option of CMake that avoids changing the current directory to
the build directory: especially inconvenient considering the
recommended, CMake way to clean is to delete this directory and the
recommended way to build multiple configurations is to use multiple
build directories.

-B was introduced in CMake 3.13 which has been released two years ago
now and CMake spoils its users with a choice of ways to upgrade:

https://cmake.org/download/
 https://apt.kitware.com/
 https://pypi.org/project/cmake/

This does _not_ imply CMakeLists.txt should drop backward compatibility
with CMake < 3.13. I only think a README.md file should not keep the
majority of users in the dark only for the convenience of a minority of
obsolete CMake users.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2020-11-16 10:40:31 +00:00
Karol Trzcinski 0d2af68a9e gitignore: Add checkpatch temporary file to gitignore
Any generated file should be tracked by git to keep repositiry clean.
Such an file should be added to .gitignore to reduce possibility of
accidentally pushig this file to remote branches, eg. after typing
`git add *` before pushing changes.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-10-22 16:03:54 +01:00
Karol Trzcinski 8249abfa11 toml: Keep available manifest parsers in list
This approach allows to easily expand parsers list in future,
without harming code readability.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-10-19 14:40:04 +01:00
Karol Trzcinski c98a29da14 toml: Extract version parsing to separate function
This task is fully separatable from adsp_parse_config_fd(),
so should be done in separate function, to improve code readability.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-10-19 14:40:04 +01:00
Marc Herbert b9cf1aeb3b pkcs1_5.c: don't pretend everything is fine when failing to sign
Found by chance and reproduced by making a typo in the key's filename.

Note there is already an (unchanged) error message:

 pkcs: signing with key sof/keys/otc_private_key_3k.pemX
 error: can't open file sof/keys/otc_private_key_3k.pemX -2
 Firmware manifest and signing completed !

But now rimage does not pretend success and the build does not keep
going with an unsigned image like nothing happened.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2020-10-19 13:17:20 +01:00
Marc Herbert e87db0f080 pkcs1_5.c: intermediate named constants in ri_manifest_sign_v1_x()
As suggested by Karol in the review of the next commit. Makes the
function call shorter and naming the parameters makes the code much more
readable. Can help for debugging too.

Absolutely zero change: the two CMAKE_BUILD_TYPE=Release rimage binaries
before and after this commit are actually identical.

In passing, replace void * arithmetic in that function
with char *. void * arithmetic is an actually illegal gcc
extension (not just "undefined").

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2020-10-19 13:17:20 +01:00
Karol Trzcinski 86754c1389 hash: Assert memory overflow during hash calculation
ri_sha*() functions are often called with arguments calculated on
the fly, so at list basic assertion here may save debugging time
in the future.
Cast size to uint64_t to properly handle nagative sizes, casted to
uint32_t in argument list. Otherwise, sum size and offset may
overflow uint32_t and don't trigger assert.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-10-19 13:03:28 +01:00
Marc 37323face2
Merge pull request #28 from marc-hb/copy-sram-overflow
manifest.c: assert buffer overflow in man_copy_sram()
2020-10-15 10:18:04 -07:00
Marc Herbert 7322c02349 manifest.c: assert buffer overflow in man_copy_sram()
Does not solve https://github.com/thesofproject/sof/issues/3423 but
converts a buffer overflow and crash into a more usable assert.

Buffer overflow found by running rimage with valgrind and the binaries
provided by @singalsu

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2020-10-15 07:19:43 +00:00
Karol Trzcinski fccf521331 travis: Scan patch codestyle
Checkpatch is a tool which checks patch code style
alignment with Linux kernel code.
By the way print short graphs of used commits, to
show whats under test.
Checkpatch call is precede by `set -x`, to show used
arguments values, especially checked commits range.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-09-24 09:23:12 +01:00
Karol Trzcinski e29baaa8b9 travis: Use $(...) instead `...` in bash scripts
It's encouraged to use version with $(...).
    Backtick command substitution `...` is legacy
    syntax with several issues.

   1. It has a series of undefined behaviors related to quoting in POSIX.
   2. It imposes a custom escaping mode with surprising results.
   3. It's exceptionally hard to nest.

   ~https://github.com/koalaman/shellcheck/wiki/SC2006

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-09-24 09:23:12 +01:00
Marc Herbert e67d68e8e1 adsp_config.c: actually check error when parsing "version" array elements
Caveat: this was just reported by valgrind. I did not test any actual
toml parsing error either (who tests error handling?) but this code
can't be worse than the previous one.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2020-09-23 19:11:48 +01:00
Marc Herbert 75f96956e0 elf.c: check ELF32-LE magic number instead of crashing
Passing a 64 bits ELF file by accident (for instance: '/usr/bin/openssl'
while messing up the command line options) caused an interesting cascade
of errors and memory corruption which are all caught in this commit.

This doesn't make rimage fuzz-proof far from it; only fool-proof which
is still useful.

In passing add some quotes so the error message when failing to find the
SHT_NULL section with an empty name is a little bit more readable.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2020-09-23 19:11:48 +01:00
Marc Herbert 91bd4fe796 rimage.c: print an error instead of crashing when zero ELF argument
Also rename elf_argc to first_non_opt because it's a position, not a
count.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2020-09-23 19:11:48 +01:00
Marc Herbert 82d4767ca5 Stop silently discarding -l option
Commit https://github.com/thesofproject/soft/commits/59d81995f6828 added
an -l option (for --liam? :-) which was never implemented. Remove it
because silently discarding user input is really not nice no matter how
wrong it is.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2020-09-23 19:11:48 +01:00
Karol Trzcinski f4e01789f0 travis: Treat warnings as errors
Then each warning message should be addressed.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-09-22 19:24:22 +01:00
Karol Trzcinski 3b2398a97d travis: Add more warnings to make command
Warnings may point some fatal error in source code.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-09-22 19:24:22 +01:00
Karol Trzcinski 6dcf1b6ae8 toml: Use only standard error codes
Error codes like ENOKEY and EBADE are not provide for all windows
toolchains, so to immit possible build errors, some more standard
error codes should be used.
Detailed error message is printed in stderr, so end user still
will be well informed about error source.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-09-22 12:34:40 +01:00