Mellanox / bfscripts

Collection of scripts used for BlueField SoC system management.
BSD 2-Clause "Simplified" License
19 stars 27 forks source link

Parse out unintended bytes in build ID string #227

Closed cbabroski closed 4 months ago

cbabroski commented 4 months ago

Recent changes to our bl33 binary have resulted in some data getting rearranged in the binary's data section. The bfver script uses the Linux "strings" utility to parse the "BId" string from the raw binary and, depending on the data that is next to that string in the binary, can sometimes include unexpected bytes as part of the located string.

For example, the following shows how there is an "a" character prepended before the expected build ID string:

root@bu-lab102:~/cbabroski/tmp# strings -el dump-bl33-v0
aBId13164
...

And this results in the BSP version displayed by bfver to have a corrupted build ID:

svc-soc-ver@bu-lab40v-oob:~$ sudo bfver
...
BlueField BSP version: 4.8.0.aBId13156

The fix is to update the sed regex used to cut out the build ID number which should never contain letters or special characters. The new regex will cut out all characters before and after the actual build ID number.

Note that using "strings" to search for these versions in the binary is prone to errors. In the future we may want to put these values in an EFI variable that bfver can read instead.

RM #3948954