fix(hftest): recover from UTF-8 errors in logs

Strings logged by `dlog` may contain arbitrary bytes, which may not be
valid UTF-8. This can cause `hftest` to crash when reading the log
files.

Change `read_file` to open files with the `backslashreplace` error
handler, so that bytes that are invalid UTF-8 will be replaced with
backslash escape sequences.

Example:
```c
HFTEST_LOG("Hello, world \x80");
```

Before:
```
  File "/Users/karmea01/git/work/spm/./test/hftest/hftest.py", line 73, in read_file
    return f.read()
           ^^^^^^^^
  File "<frozen codecs>", line 322, in decode
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 2350: invalid start byte
```

After:
```
[1 0] [hftest] hello world \x80
```

Change-Id: I8d729846d27c94d5f227bbcebb764a2d0a8659de
Signed-off-by: Karl Meakin <karl.meakin@arm.com>
1 file changed
tree: 4f1ca181b7e81555beab7972996cd43d060fa167
  1. .vscode/
  2. build/
  3. docs/
  4. inc/
  5. kokoro/
  6. project/
  7. src/
  8. test/
  9. third_party/
  10. vmlib/
  11. .clang-format
  12. .clang-tidy
  13. .gitignore
  14. .gitmodules
  15. .gn
  16. .readthedocs.yaml
  17. AUTHORS
  18. BUILD.gn
  19. CONTRIBUTING.md
  20. dco.txt
  21. LICENSE
  22. Makefile
  23. navbar.md
  24. pyproject.toml
  25. README.md
README.md

Hafnium

Hafnium is the Secure Partition Manager(SPM) reference implementation, following the Arm's Firmware Framework specification.

It leverages Arm's virtualization extensions in the secure world of Arm's A class of devices (feature introduced with Armv8.4 FEAT_SEL2) to allow multiple Trusted OSes or Applications to run concurrently, inside the Trusted Execution Environment, each running as a Secure Partition (SP). Its main goal is to control the system access given to Trusted OSes, and serve as a mediator to the rest of the system.

For example, it limits the memory use, and handles all system calls from Trusted OS. Thus the SPM can enforce spacial isolation, and enforce some level of access control, protecting other critical system resources such as: the secure monitor, the normal world software stack, the SPM itself and other SPs/Trusted Applications. Other important features are: secure interrupt handling, device assignment, inter-partition communication and with the Normal World Software stack, also known as Rich Execution Environment (REE).

The following diagram shows an overview of a typical aarch64-based system, and where Hafnium fits:

Hafnium Architecture

Get in touch and keep up-to-date at:

See feature requests and bugs through github.

Documentation

To find more about Hafnium, view the full documentation. It includes valuable resources such as: Getting Started guide, Threat Model, and other documentation.