From 0b431a8e89d5a1d7d09b8da7bcb726769d734759 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Wed, 13 Oct 2021 23:19:45 +0000 Subject: [PATCH 01/11] installer: comment fix: hsw and sue are not SIGNED Pure comments, no code change. Signed-off-by: Marc Herbert --- installer/GNUmakefile | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/installer/GNUmakefile b/installer/GNUmakefile index b8d85ecc8059..098f82a4cd47 100644 --- a/installer/GNUmakefile +++ b/installer/GNUmakefile @@ -11,20 +11,26 @@ # Override ?= variables in config.mk -include config.mk +# List of /lib/firmware/sof/ images and symbolic links currently +# released by Intel. + +# See rimage/config/*.toml UNSIGNED_list ?= bdw byt cht SIGNED_list ?= apl cnl icl jsl tgl tgl-h -# older SOF versions -# SIGNED_list += hsw kbl skl sue # To find aliases, try in a Linux kernel git clone: # # git grep 'sof-.*\.ri' -- sound/soc/ - ALIAS_SAME_KEY_list := glk cfl cml ALIAS_OTHER_KEY_list := ehl adl adl-s ALIAS_list ?= ${ALIAS_SAME_KEY_list} ${ALIAS_OTHER_KEY_list} + +# Older platforms not released anymore +# UNSIGNED_list += hsw sue +# SIGNED_list += kbl skl + $(info UNSIGNED_list = ${UNSIGNED_list} ) $(info SIGNED_list = ${SIGNED_list} ) $(info ALIAS_list = ${ALIAS_list} ) From c1c13e6a4a60a56be0d4236cadf2074a0249a72d Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Wed, 13 Oct 2021 23:23:25 +0000 Subject: [PATCH 02/11] test-repro-build.sh: exclude two more .ninja_ files Also convert 'differ' to all caps 'DIFFER' to highlight different files. No other functional change. Signed-off-by: Marc Herbert --- scripts/test-repro-build.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/test-repro-build.sh b/scripts/test-repro-build.sh index 3ef72e498a24..0c1c34f70594 100755 --- a/scripts/test-repro-build.sh +++ b/scripts/test-repro-build.sh @@ -64,12 +64,14 @@ hexdiff () init() { + # -E(xtended) regex local excluded_endings=( '\.log' /deps '\.c?make' '\.ninja' /TargetDirectories.txt /CMakeCache.txt /progress.marks /CMakeRulesHashes.txt /Makefile /CMakeRuleHashes.txt /Makefile2 '/depend\.internal' /link.txt '\.includecache' + '/.ninja_deps' '/.ninja_log' '.*\.c\.o\.d' '/rimage_ep.*' '/smex_ep.*' @@ -109,7 +111,8 @@ diff_some_files() for p in "${PLATFS[@]}"; do - # look at the smallest .c.o first + # Compare some ELF section headers. Look at the smallest .c.o + # first for f in CMakeFiles/sof.dir/src/arch/xtensa/init.c.o sof; do diff --report-identical-files \ @@ -127,7 +130,7 @@ diff_some_files() done true - ) + ) | sed -e 's/differ/DIFFER/g' } main() From 85f07733ecf9800159c9d292107024ccccbfc6a8 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Mon, 18 Oct 2021 23:31:18 +0000 Subject: [PATCH 03/11] sof_ri_info: fix wrong begin_off in parse_mft_extension() This broke parsing any extension past the first one. Signed-off-by: Marc Herbert --- tools/sof_ri_info/sof_ri_info.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/sof_ri_info/sof_ri_info.py b/tools/sof_ri_info/sof_ri_info.py index 92666a2a6d42..dc44ccc63bb5 100755 --- a/tools/sof_ri_info/sof_ri_info.py +++ b/tools/sof_ri_info/sof_ri_info.py @@ -614,15 +614,17 @@ def parse_css_manifest_4(css_mft, reader, size_limit): css_mft.add_comp(parse_mft_extension(reader, ext_idx)) ext_idx += 1 + assert reader.get_offset() == size_limit # wrong extension length + return css_mft def parse_mft_extension(reader, ext_id): """ Parses mft extension from sof binary """ + begin_off = reader.get_offset() ext_type = reader.read_dw() ext_len = reader.read_dw() if ext_type == 15: - begin_off = reader.get_offset() ext = PlatFwAuthExtension(ext_id, reader.get_offset()-8) ext.add_a(Astring('name', reader.read_string(4))) ext.add_a(Auint('vcn', reader.read_dw())) From 689d8367bf2b253dd906cb4e27f224d2c0453f8b Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Tue, 19 Oct 2021 17:56:04 +0000 Subject: [PATCH 04/11] sof_ri_info: fix adsp_mft_cse_entry.entry_file_offset Fixes the adsp_mft_cse_entry Component added by commit 8885b465df53 ("tools: sof-ri-info: move parsing adsp mft outside cse mft"). `adsp_mft_cse_entry.entry_file_offset` did not account for the extended manifest. Also fix the large `reader.ext_mft_length + entry_offset` copy/paste/diverge That variable did not seem to be used anywhere yet but it's wrong value was confusing and time-consuming when debugging. Signed-off-by: Marc Herbert --- tools/sof_ri_info/sof_ri_info.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tools/sof_ri_info/sof_ri_info.py b/tools/sof_ri_info/sof_ri_info.py index dc44ccc63bb5..a7f2cbff9e57 100755 --- a/tools/sof_ri_info/sof_ri_info.py +++ b/tools/sof_ri_info/sof_ri_info.py @@ -524,24 +524,25 @@ def parse_cse_manifest(reader): hdr_entry.add_a(Ahex('entry_length', entry_length)) hdr.add_comp(hdr_entry) - reader.info('CSE Entry name {} length {}'.format(entry_name, - entry_length)) + assert cse_mft.file_offset == reader.ext_mft_length + entry_file_offset = reader.ext_mft_length + entry_offset + reader.info('... CSE Entry name {} file offset 0x{:x} length {}'.format(entry_name, + entry_file_offset, entry_length)) if '.man' in entry_name: - entry = CssManifest(entry_name, - reader.ext_mft_length + entry_offset) - cur_off = reader.set_offset(reader.ext_mft_length + entry_offset) + entry = CssManifest(entry_name, entry_file_offset) + cur_off = reader.set_offset(entry_file_offset) parse_css_manifest(entry, reader, - reader.ext_mft_length + entry_offset + entry_length) + entry_file_offset + entry_length) reader.set_offset(cur_off) elif '.met' in entry_name: - cur_off = reader.set_offset(reader.ext_mft_length + entry_offset) + cur_off = reader.set_offset(entry_file_offset) entry = parse_mft_extension(reader, 0) entry.name = '{} ({})'.format(entry_name, entry.name) reader.set_offset(cur_off) else: # indicate the place, the entry is enumerated. mft parsed later - entry = Component('adsp_mft_cse_entry', entry_name, entry_offset) + entry = Component('adsp_mft_cse_entry', entry_name, entry_file_offset) cse_mft.add_comp(entry) nb_index += 1 From 382c5140a78194561474e071878e63d3a72dc629 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Tue, 19 Oct 2021 18:18:08 +0000 Subject: [PATCH 05/11] sof_ri_info: show file offsets for most components + some lengths File offsets were critical in finding the serious begin_off bug fixed in the same series. The information is already there so just show it. Signed-off-by: Marc Herbert --- tools/sof_ri_info/sof_ri_info.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tools/sof_ri_info/sof_ri_info.py b/tools/sof_ri_info/sof_ri_info.py index a7f2cbff9e57..6be10d54bc7f 100755 --- a/tools/sof_ri_info/sof_ri_info.py +++ b/tools/sof_ri_info/sof_ri_info.py @@ -1108,6 +1108,9 @@ def dump_info(self, pref, comp_filter): hdr = self.cdir['css_mft_hdr'] out = '{}{} (CSS Manifest)'.format(pref, self.name) out += ' type {}'.format(hdr.adir['type']) + out += ' file offset {:#x} hdr_len {}'.format( + self.file_offset, hdr.adir['header_len_dw'].val * 4 + ) out += ' ver {}'.format(hdr.adir['header_version']) out += ' date {}'.format(hdr.adir['date']) print(out) @@ -1133,9 +1136,9 @@ def __init__(self, ext_id, name, offset): offset) def dump_info(self, pref, comp_filter): - print('{}{} type {} length {}'. + print('{}{} type {} file offset 0x{:x} length {}'. format(pref, self.name, - self.adir['type'], self.adir['length'])) + self.adir['type'], self.file_offset, self.adir['length'])) class PlatFwAuthExtension(MftExtension): """ Platform FW Auth Extension @@ -1145,7 +1148,8 @@ def __init__(self, ext_id, offset): self).__init__(ext_id, 'Plat Fw Auth Extension', offset) def dump_info(self, pref, comp_filter): - out = '{}{}'.format(pref, self.name) + super().dump_info(pref, comp_filter) + out = '{}'.format(pref) out += ' name {}'.format(self.adir['name']) out += ' vcn {}'.format(self.adir['vcn']) out += ' bitmap {}'.format(self.adir['bitmap']) @@ -1161,7 +1165,8 @@ def __init__(self, ext_id, offset): offset) def dump_info(self, pref, comp_filter): - out = '{}{}'.format(pref, self.name) + super().dump_info(pref, comp_filter) + out = '{}'.format(pref) out += ' ver {}'.format(self.adir['version']) out += ' base offset {}'.format(self.adir['base_offset']) out += ' limit offset {}'.format(self.adir['limit_offset']) @@ -1178,7 +1183,7 @@ def __init__(self, name, offset): def dump_info(self, pref, comp_filter): hdr = self.cdir['adsp_mft_hdr'] - out = '{}{} (ADSP Manifest)'.format(pref, self.name) + out = '{}{} (ADSP Manifest) file offset 0x{:x}'.format(pref, self.name, self.file_offset) out += ' name {}'.format(hdr.adir['name']) out += ' build ver {}'.format(hdr.adir['build_version']) out += ' feature mask {}'.format(hdr.adir['feature_mask']) From dd061b0ca0ee9aee59b17bedbd528b56bc5a9414 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Wed, 13 Oct 2021 23:39:57 +0000 Subject: [PATCH 06/11] sof_ri_info: print error messages on stderr stderr is often highlighted with a different color. This also makes the usual >/dev/null redirection possible. Signed-off-by: Marc Herbert --- tools/sof_ri_info/sof_ri_info.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/sof_ri_info/sof_ri_info.py b/tools/sof_ri_info/sof_ri_info.py index 6be10d54bc7f..0c7b4e4208b9 100755 --- a/tools/sof_ri_info/sof_ri_info.py +++ b/tools/sof_ri_info/sof_ri_info.py @@ -859,7 +859,8 @@ def info(self, loginfo, off_delta=0, verb_info=True, show_offset=True): def error(self, logerror, off_delta=0): """ Prints 'error' log to the output """ - print(self.offset_to_string(off_delta) + '\terror: ' + logerror) + print(self.offset_to_string(off_delta) + '\terror: ' + logerror, + file=sys.stderr) # Data Model From f431a2eb87db1d75ac3fd4df1a92de7194a797b7 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Tue, 19 Oct 2021 17:42:12 +0000 Subject: [PATCH 07/11] sof_ri_info: minor reader.info() additions and tweaks These changes are visible only in -v mode. Signed-off-by: Marc Herbert --- tools/sof_ri_info/sof_ri_info.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/sof_ri_info/sof_ri_info.py b/tools/sof_ri_info/sof_ri_info.py index 0c7b4e4208b9..f3b53a181db8 100755 --- a/tools/sof_ri_info/sof_ri_info.py +++ b/tools/sof_ri_info/sof_ri_info.py @@ -487,7 +487,8 @@ def parse_cse_manifest(reader): # Try to detect signature first sig = reader.read_string(4) if sig != '$CPD': - reader.error('CSE Manifest NOT found ' + sig + ')', -4) + reader.error('CSE Manifest magic number NOT found, instead: (' + + sig + ')', -4) sys.exit(1) reader.info('CSE Manifest (' + sig + ')', -4) @@ -511,7 +512,7 @@ def parse_cse_manifest(reader): # Read entries nb_index = 0 while nb_index < nb_entries: - reader.info('Looking for CSE Manifest entry') + reader.info('Reading CSE Manifest entry %d...' % nb_index) entry_name = reader.read_string(12) entry_offset = reader.read_dw() entry_length = reader.read_dw() @@ -604,11 +605,11 @@ def parse_css_manifest_4(css_mft, reader, size_limit): # that could be parsed if extension type is recognized # # or series of 0xffffffff that should be skipped - reader.info('Parsing CSS Manifest extensions end 0x{:x}'.format(size_limit)) + reader.info('Parsing CSS Manifest extensions, end at 0x{:x}'.format(size_limit)) ext_idx = 0 while reader.get_offset() < size_limit: ext_type = reader.read_dw() - reader.info('Reading extension type 0x{:x}'.format(ext_type)) + reader.info('Reading CSS extension type 0x{:x}:'.format(ext_type)) if ext_type == 0xffffffff: continue reader.set_offset(reader.get_offset() - 4) @@ -626,6 +627,7 @@ def parse_mft_extension(reader, ext_id): ext_type = reader.read_dw() ext_len = reader.read_dw() if ext_type == 15: + reader.info("Plat Fw Auth extension") ext = PlatFwAuthExtension(ext_id, reader.get_offset()-8) ext.add_a(Astring('name', reader.read_string(4))) ext.add_a(Auint('vcn', reader.read_dw())) @@ -634,6 +636,7 @@ def parse_mft_extension(reader, ext_id): read_len = reader.get_offset() - begin_off reader.ff_data(ext_len - read_len) elif ext_type == 17: + reader.info("ADSP metadata file extension") ext = AdspMetadataFileExt(ext_id, reader.get_offset()-8) ext.add_a(Auint('adsp_imr_type', reader.read_dw(), 'red')) # skip reserved part @@ -647,10 +650,12 @@ def parse_mft_extension(reader, ext_id): ext.add_a(Auint('limit_offset', reader.read_dw())) ext.add_a(Abytes('attributes', reader.read_bytes(16))) else: + reader.info("Other extension") ext = MftExtension(ext_id, 'Other Extension', reader.get_offset()-8) reader.ff_data(ext_len-8) ext.add_a(Auint('type', ext_type)) ext.add_a(Auint('length', ext_len)) + reader.info("... end of extension") return ext def parse_adsp_manifest_hdr(reader): From 9e3a2ae4d6ef965a20aef1eb33317828c25ed92d Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Tue, 19 Oct 2021 18:31:41 +0000 Subject: [PATCH 08/11] sof_ri_info: pylint: disable=invalid-name, missing-function-docstring Add: ... to reduce pylint warnings to a usable amount. Signed-off-by: Marc Herbert --- tools/sof_ri_info/sof_ri_info.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/sof_ri_info/sof_ri_info.py b/tools/sof_ri_info/sof_ri_info.py index f3b53a181db8..d76d74e7c661 100755 --- a/tools/sof_ri_info/sof_ri_info.py +++ b/tools/sof_ri_info/sof_ri_info.py @@ -12,6 +12,8 @@ # pylint: disable=too-few-public-methods # pylint: disable=too-many-arguments # pylint: disable=too-many-instance-attributes +# pylint: disable=invalid-name +# pylint: disable=missing-function-docstring import sys import argparse From d2fcdadfb9cc08ce508a2bb57132802363d7ee29 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Wed, 13 Oct 2021 23:43:42 +0000 Subject: [PATCH 09/11] sof_ri_info: new attributes signature and date start and length Signature and date are (for now) the only variable fields when re-signing with the same tool so their locations matter. Signed-off-by: Marc Herbert --- tools/sof_ri_info/sof_ri_info.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/sof_ri_info/sof_ri_info.py b/tools/sof_ri_info/sof_ri_info.py index d76d74e7c661..e5610933b3e9 100755 --- a/tools/sof_ri_info/sof_ri_info.py +++ b/tools/sof_ri_info/sof_ri_info.py @@ -579,7 +579,10 @@ def parse_css_manifest_4(css_mft, reader, size_limit): hdr.add_a(Auint('header_version', reader.read_dw())) hdr.add_a(Auint('reserved0', reader.read_dw(), 'red')) hdr.add_a(Ahex('mod_vendor', reader.read_dw())) + date_start = reader.get_offset() + hdr.add_a(Auint('date_start', date_start)) hdr.add_a(Adate('date', hex(reader.read_dw()))) + hdr.add_a(Auint('date_length', reader.get_offset() - date_start)) size = reader.read_dw() hdr.add_a(Auint('size', size)) hdr.add_a(Astring('header_id', reader.read_string(4))) @@ -595,7 +598,11 @@ def parse_css_manifest_4(css_mft, reader, size_limit): modulus = reader.read_bytes(modulus_size * 4) hdr.add_a(Amodulus('modulus', modulus, KNOWN_KEYS.get(modulus, 'Other'))) hdr.add_a(Abytes('exponent', reader.read_bytes(exponent_size * 4))) + + sig_start = reader.get_offset() + hdr.add_a(Auint('signature_start', sig_start)) hdr.add_a(Abytes('signature', reader.read_bytes(modulus_size * 4))) + hdr.add_a(Auint('signature_length', reader.get_offset() - sig_start)) # Move right after the header reader.set_offset(css_mft.file_offset + header_len_dw*4) @@ -1131,7 +1138,8 @@ def dump_info(self, pref, comp_filter): format(pref, hdr.adir['exponent_size'])) print('{} {}'.format(pref, hdr.adir['exponent'])) - print('{} Signature'.format(pref)) + print('{} Signature (file offset {}, length {})'.format( + pref, hdr.adir['signature_start'], hdr.adir['signature_length'])) print('{} {}'.format(pref, hdr.adir['signature'])) # super().dump_info(pref) self.dump_comp_info(pref, comp_filter + ['Header']) From 34b65ce43c3cf8fd5cf888dc7a19ee8bac9eec73 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Wed, 13 Oct 2021 23:45:28 +0000 Subject: [PATCH 10/11] sof_ri_info: add new --erase_vars feature for reproducible builds sof_ri_info.py --erase_vars reproducible.ri sof.ri replaces variable fields (signature and date right now) by constants. Signed-off-by: Marc Herbert --- tools/sof_ri_info/sof_ri_info.py | 118 +++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) diff --git a/tools/sof_ri_info/sof_ri_info.py b/tools/sof_ri_info/sof_ri_info.py index e5610933b3e9..f023d3f3edfd 100755 --- a/tools/sof_ri_info/sof_ri_info.py +++ b/tools/sof_ri_info/sof_ri_info.py @@ -18,6 +18,10 @@ import sys import argparse import struct +import io +import pathlib +import hashlib + # To extend the DSP memory layout list scroll down to DSP_MEM_SPACE_EXT @@ -332,6 +336,9 @@ def parse_params(): action='store_true') parser.add_argument('--no_memory', help='skip information about memory', action='store_true') + parser.add_argument('--erase_vars', help=''' + Replace the variable signature and any other variable element with constants + ''', type=pathlib.Path, dest='erased_vars_image') parser.add_argument('sof_ri_path', help='path to fw binary file to parse') parsed_args = parser.parse_args() @@ -627,6 +634,7 @@ def parse_css_manifest_4(css_mft, reader, size_limit): assert reader.get_offset() == size_limit # wrong extension length + css_mft.length = reader.get_offset() - css_mft.file_offset return css_mft def parse_mft_extension(reader, ext_id): @@ -1410,6 +1418,112 @@ def dump_info(self): 'ehl' : TGL_LP_MEMORY_SPACE, } + +def getCssManifest(parsed_fw): + "Also known as 'ADSP.man'" + cse_mft = parsed_fw.cdir['cse_mft'] + return cse_mft.cdir['css_mft'] + + +def Erase(input_reader, start, length, padding): + + padding = padding * (length // len(padding) + 1) + output_bytes = input_reader.read(start) + + # Skip and replace with padding + input_reader.seek(length, 1) + output_bytes += padding[:length] + + output_bytes += input_reader.read() + + input_reader.seek(0) + return io.BytesIO(output_bytes) + + +def EraseSignature(signed_input, parsed_fw): + + hdr = getCssManifest(parsed_fw).cdir['css_mft_hdr'] + + return Erase(signed_input, + hdr.adir['signature_start'].val, + hdr.adir['signature_length'].val, + b'Erased signature. ') + + +def EraseCssManifestDate(dated_input, parsed_fw): + + hdr = getCssManifest(parsed_fw).cdir['css_mft_hdr'] + + return Erase(dated_input, + hdr.adir['date_start'].val, + hdr.adir['date_length'].val, + b'\x11' * 6) # = 1111/11/11 + + +def EraseCssManifest(image_input, parsed_fw): + + css_man = getCssManifest(parsed_fw) + + return Erase(image_input, css_man.file_offset, + css_man.length, b"Erased CSS manifest. ") + + +def EraseImrType(image_input, parsed_fw): + + cse_mft = parsed_fw.cdir['cse_mft'] + adsp_meta_ext = cse_mft.cdir['mft_ext0'] + + # IMR type is the very first field after extension type and length + imr_start = adsp_meta_ext.file_offset + 4 + 4 + + # Health check: re-read the imr_type to make sure the offset is + # still correct, no copy/paste/diverge. + true_imr_type = adsp_meta_ext.adir['adsp_imr_type'].val + image_input.seek(imr_start) + imr_type, = struct.unpack(" Date: Wed, 13 Oct 2021 23:30:48 +0000 Subject: [PATCH 11/11] cmake: use new --erase_vars feature and test new 'reproducible.ri' Update the scripts/test-repro-build.sh test accordingly. Finally, different people and CI systems can make sure they're building the same firmware. reproducible.ri is sof.ri with variable parts removed. Signed-off-by: Marc Herbert --- scripts/test-repro-build.sh | 21 ++++++++------ src/arch/xtensa/CMakeLists.txt | 51 +++++++++++++++++++++++++++++++++- 2 files changed, 63 insertions(+), 9 deletions(-) diff --git a/scripts/test-repro-build.sh b/scripts/test-repro-build.sh index 0c1c34f70594..74ae0fb525f5 100755 --- a/scripts/test-repro-build.sh +++ b/scripts/test-repro-build.sh @@ -40,9 +40,9 @@ SOF2="$SOF_PARENT"/sof-bind-mount-DO-NOT-DELETE # SOF2="$SOF_PARENT"/sog -# Test with one of each: CSS signature v1.5, v1.8 and v2.5 +# Test with one of each: unsigned, CSS signature v1.5, v1.8 and v2.5 # This also provides some C code coverage diversity. -PLATFS=(skl apl tgl) +PLATFS=(byt skl apl tgl) # diffoscope is great but it has hundreds of dependencies, too long to # install for CI so we don't use it here. This is just an alias @@ -77,9 +77,10 @@ init() '/smex_ep.*' ) - # Hack to avoid CSS 2.5 salt. See caveats above. - excluded_endings+=('/sof-tgl.ri') - excluded_endings+=('tgl_.cc/sof.ri') + # The signing process is not deterministic. + # Keep 'reproducible.ri' INCLUDED! + excluded_endings+=('/sof-[a-z-]{,6}\.rix?') + excluded_endings+=('/sof\.ri' '/sof-no-xman\.ri' ) GREP_EXCLUDE_ARGS=() for fpath in "${excluded_endings[@]}"; do @@ -123,9 +124,13 @@ diff_some_files() done - for f in generated/include/version.h sof.ri; do + for f in generated/include/version.h sof.ri \ + src/arch/xtensa/reproducible.ri; do diff -u --report-identical-files \ {b0,b1}/build_"$p"_?cc/"$f" + # report unsupported reproducible.ri + test -s b0/build_"$p"_?cc/"$f" || + printf '\t%s is EMPTY\n' b0/build_"$p"_?cc/"$f" done done @@ -165,7 +170,7 @@ main() # Use this to "break" rimage that makes the date (in local time! # BIOS fans?) part of the CSS signature. See caveats above. # +14:00 - -11:00 = +25:00 = always on a different date - # export TZ='Pacific/Kiritimati' # +14:00 + export TZ='Pacific/Kiritimati' # +14:00 "$SOF2"/scripts/xtensa-build-all.sh "${PLATFS[@]}" mv build_*_?cc reprobld/b1/ @@ -179,7 +184,7 @@ main() diff -qr b0 b1/ | grep -E -v "${GREP_EXCLUDE_ARGS[@]}" || { printf \ - "\n\n ---- PASS: no difference found between %s/b0/ and b1/ --- \n\n" "$(pwd)" + "\n\n ---- PASS: no unexpected difference found between %s/b0/ and b1/ --- \n\n" "$(pwd)" exit 0 } diff --git a/src/arch/xtensa/CMakeLists.txt b/src/arch/xtensa/CMakeLists.txt index b855376679aa..0f40dd0c0396 100644 --- a/src/arch/xtensa/CMakeLists.txt +++ b/src/arch/xtensa/CMakeLists.txt @@ -529,8 +529,57 @@ add_custom_target( DEPENDS run_meu VERBATIM USES_TERMINAL + BYPRODUCTS sof-${fw_name}.ri # almost like a proper add_custom_command() ) + +# Keep lists below in sync with rimage/config/*.toml + +# .ri not signed: nothing variable in it to erase. +set(UNSIGNED_RI byt cht hsw bdw sue) +# NXP +list(APPEND UNSIGNED_RI imx8 imx8x imx8m) +# AMD +list(APPEND UNSIGNED_RI rn) +# Mediatek +list(APPEND UNSIGNED_RI mt8195) + +# Signed and non-deterministic but sof_ri_info.py is not compatible with +# manifest v1.5? "CSE manifest magic number not found" +set(UNSUPPORTED_RI skl kbl) + +if(${fw_name} IN_LIST UNSIGNED_RI) # mere copy + add_custom_command(OUTPUT reproducible.ri + COMMENT "Copying sof.ri to reproducible.ri as is" + # TODO: drop the glue_binary_files dependency once the + # edit-in-place and add_custom_target() messes are all fixed + DEPENDS glue_binary_files sof-${fw_name}.ri + COMMAND cmake -E copy sof-${fw_name}.ri reproducible.ri + VERBATIM + ) +elseif(${fw_name} IN_LIST UNSUPPORTED_RI) + add_custom_command(OUTPUT reproducible.ri + COMMENT "WARNING: sof-${fw_name}.ri is NOT reproducible, reproducible.ri is fake" + DEPENDS glue_binary_files sof-${fw_name}.ri + COMMAND cmake -E touch reproducible.ri + VERBATIM + ) +else() # strip variables + add_custom_command(OUTPUT reproducible.ri + COMMENT "Creating reproducible.ri" + DEPENDS glue_binary_files sof-${fw_name}.ri + COMMAND ${PROJECT_SOURCE_DIR}/tools/sof_ri_info/sof_ri_info.py + --no_headers --no_modules --no_memory # could use a -q option... + --erase_vars reproducible.ri sof-${fw_name}.ri + VERBATIM + ) +endif() + + +# Top-level 'bin' target collecting all dependencies. Copies final .ri +# file from current subdirectory to top level build directory +# ${PROJECT_BINARY_DIR}. + # TODO: get rid of ${fw_output_name} and ${fw_name} below. Different # platforms are already built in different build directories, we will # never support building multiple platforms in the same build directory. @@ -551,7 +600,7 @@ else() bin ALL COMMAND ${CMAKE_COMMAND} -E copy sof-${fw_name}.ri ${PROJECT_BINARY_DIR}/sof-${fw_output_name}.ri COMMAND ${CMAKE_COMMAND} -E copy sof-${fw_name}.ri ${PROJECT_BINARY_DIR}/sof.ri - DEPENDS run_meu bin_extras glue_binary_files sof_dump + DEPENDS run_meu bin_extras glue_binary_files sof_dump reproducible.ri VERBATIM USES_TERMINAL )