elfloader: major overhaul to support non-seL4 images

Overhaul the ELF loader support to handle loading ELF images unlike seL4
(e.g. many ELF load segments, no capdl-loader) and cleanup some code.
With these changes CHERIoT firmware images load.

- add support for loading multiple ELF load segments
- handle a missing capdl-loader; e.g. when starting the SMC do not
  post the boot message to the mailbox
- improve loading unaligned ELF segments; still does not handle all cases
  but it's unclear if they matter (will panic)
- handle running out of space for ELF phdrs more gracefully
- change SEL4State to have only one instance of "offset" & "headers"
  to save memory, especially when we grow the "headers" array to handle
  more complex ELF images
- combine the FindFile, LoadElfHeaders, and LoadElf tasks into a
  single LoadElf task; this better safeguards SEL4State that was shared
  between the tasks and clobbered if the old tasks were mis-ordered
- reduce the task array size after combining FindFile & co
- add a Noop task for initializing/padding the task array
- cleanup SEL4State handling; e.g. move calculations derived from the
  ELF phdrs to immediately after the full set of headers are read;
  this safeguards against clobbering shared state between task phases
- change ELF segment log msgs to include the segment # and to only
  log non-zero size segments (file-data, bss)
- use the tar magic marker to identify EOF (when present)
- remove a bunch of dead code
- replace panic(<line-number>) by unreachable! calls since the line
  numbers were (wrong and) unmtaintable
- increase the tock app memory layout for the changes (we were right
  on the edge)

Fix: 331955054
Change-Id: Iecb00e5545c9cf5e603d49e3f2c7669ed36581e3
2 files changed
tree: 0811aaf969a6d6d7deba1e087ca7c89089005164
  1. app/
  2. blob_fs/
  3. capsules/
  4. config/
  5. hal/
  6. platform/
  7. utils/
  8. .gitignore
  9. CONTRIBUTING.md
  10. LICENSE
  11. matcha.code-workspace
  12. README.md
README.md

Matcha SW Repository

This project contains the support needed to build a TockOS artifact that can run on the Matcha security core, and integrated as part of the Shodan repository.

Prerequisite

If you get this project from Project Shodan manifest, you are all set.

This project needs to be at <dir>/sw/matcha.

Code structure

  • app: TockOS applications (including the boot loader)
  • blob_fs: prototype implementation of a Blob filesystem (unused)
  • capsules: TockOS capsules
  • config: TockOS configuration for Matcha
  • hal: TockOS hal crates
  • platform: TockOS Matcha platform support
  • utils: utility code for apps & capsules