Commit graph

78 commits

Author SHA1 Message Date
bunnie
ffe697b8c8 CHORE: cleanup some build warnings
put the load checker code behind the debug-print feature gate
2023-02-12 13:15:02 +08:00
bunnie
a6b46c6275 add check function to loader
This is very helpful for debugging loader errors. Basically
it prints out the first and last 20 bytes of each section
based on the source as specified in the MiniElf format, and
then it prints the corresponding data as loaded after walking
the page tables.

Loader errors really stand out with this debugging tool.
2023-02-12 01:12:20 +08:00
bunnie
4a2234f539 XIP works with some processes, but not others
it works with e.g. shellchat, but not vault.

still scratching my head on what's gone wrong -- it's
crashing in the pre-boot, which means something is not
mapped right for some case that wasn't caught in the
earlier testing.
2023-02-11 01:42:04 +08:00
bunnie
11c987c5f6 this loader commit was accidentally pulled into a previous mass-commit 2023-01-31 15:14:47 +08:00
bunnie
e5fdd0fec7 commit new versions to verifiers 2023-01-31 15:12:19 +08:00
Sean Cross
b35d65c3e1 loader: skip zeroing when we hit a page boundary
Previously, we would unconditionally zero out the remainder of a page
when finished copying. We wrapped to PAGE_SIZE in order to avoid
corrupting another process' memory.

However, an issue was discovered under the following circumstances:

    1. There are fewer than 4096 bytes of `.bss`
    2. The `.bss` ends on a page boundary

Under these conditions, the loader would load the section before the
`.bss` into the page, then clear out the `.bss`, and finally clear the
entire page, overwriting the previous section.

Skip the remainder-of-page clearout when the `.bss` ends on a page
boundary, rather than clearing the entire page.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-10-20 11:27:48 +08:00
Sean Cross
af501c4303 loader: print process IDs as debug data
Print out the current process ID when looping through values. This will
make it easier to identify which process is getting loaded when reading
through the tea leaves.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-10-20 11:27:48 +08:00
bunnie
18e1d6e867 switch over to the log uart on boot
this helps minimal configurations to be more useful without pulling
in com/llio crates. The trade-off is that KP's early in boot
(or during resume) are not visible, but, these are (thankfully??)
less rare these days.
2022-10-02 21:45:36 +08:00
Sean Cross
a70aee7bad loader: move loader into main workspace
Add the loader into the main workspace, removing it from its own
sub-workspace. We can do this now that we can specify the linker script
in `build.rs`.

This improves IDE support, and should shrink disk storage requirements.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-03-22 02:09:18 +08:00
bunnie
4f65fe522f fix debug print locations for loader 2022-03-14 01:19:38 +08:00
bunnie
e7efb14bdf add a bypass for Renode to skip the signature check
- bypass causes warnings to be emitted in compilation
- stark visual change on boot screen ("jail bars" instead of gray on bottom half)
- root keys are locked out permanently from readout
- devboot canary set
2022-03-02 19:51:16 +08:00
bunnie
f2eb466965 bump loader version string 2022-02-04 03:22:35 +08:00
bunnie
6d6b62ae60 add routine to lock keys if loader cannot verify kernel
Doesn't do enough to protect against glitch attacks but at least
it narrows the window where the keys are trivially readable if
code exec is achieved.
2022-02-03 22:01:24 +08:00
bunnie
afd525002d initial attempt to move the font resources into the loader 2022-01-23 03:23:06 +08:00
bunnie
797e5bd7c4 follow-on set of commits related to the previous revert 2022-01-17 23:52:58 +08:00
bunnie
0d4ab0eb47 Revert "loader: move loader into main workspace"
This reverts commit 0d72454776.
2022-01-17 22:55:39 +08:00
bunnie
80bf673731 massage the loader to work
however -- it is now very slow
2022-01-17 01:10:41 +08:00
Sean Cross
0d72454776 loader: move loader into main workspace
Add the loader into the main workspace, removing it from its own
sub-workspace. We can do this now that we can specify the linker script
in `build.rs`.

This improves IDE support, and should shrink disk storage requirements.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-01-14 17:32:04 +08:00
bunnie
3f4fea1274 clean up some easy warnings 2022-01-07 22:19:39 +08:00
bunnie
fe04f5684f fix a critical bug that prevents root key initialization
This is going to require users to update their devices before
doing a key initialization.

The problem is that we can't trust the length of data presented
to us to self-sign, so we sign the whole area. In v0.9.2 of the
loader, a check was introduced to check the putative length of
the signed area against the actual length of the signed area,
by encoding the length of the signed area within the signed
region.

This would require the rootkeys algorithm to also encode that
new length at the end of the signed area, but this was never
done. However, this bug was never found during testing probably
because I failed to completely erase the original key provisioning
(I was more fixated on checking that existing keys were not damaged by
firmware updates at the time), and thus did not trigger a full
rootkey provisioning cycle when I did the test. I had only just
caught it now while porting the PDDB from simulation to real
hardware.
2022-01-03 19:06:21 +08:00
bunnie
337afbbe47 bump loader version number 2021-11-02 03:26:16 +08:00
bunnie
8d501cfcc6 add a check that the detached signature metadata matches signed data
the unsigned metadata in the signature header is used to compute
the signature, which contains a copy of the key metadata. We forgot
to make sure these match, which means the signed copy was worthless.

Until now.
2021-11-02 03:16:40 +08:00
bunnie
010856406d fix permissions 2021-10-27 23:06:13 +08:00
bunnie
3a4bbdd71a fix permissions. windows likes to make all files executable! world writeable! 2021-10-23 18:37:39 +08:00
bunnie
dc527a3619 Rust 1.56 results in a bigger loader. Presumably because "optimization".
This causes the font maps to shift down. Allocate some "room to grow"
as Rust gets more "optimal".
2021-10-23 18:36:31 +08:00
bunnie
e2ce3cad2c make sure that the power states get set correctly early in the resume process 2021-08-27 15:47:27 +08:00
bunnie
98afa19264 fix kernel uart going dead after suspend/resume 2021-08-24 03:46:02 +08:00
bunnie
abd8eadfd8 modify the console behavior to better capture panics on resume
switches to kernel console on suspend, keeps it in kernel
console on resume for a few hundred ms before switching back
to our original setting
2021-08-22 14:28:06 +08:00
bunnie
c0ce66ee51 fix permissions. windows is sort of stupid and makes everything +x 2021-08-19 23:34:29 +08:00
Sean Cross
0c372263ff loader: mark sections as +X
It is unclear why this is required. More investigation
is needed.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-15 21:59:19 +08:00
Sean Cross
4700275b93 loader: handle sections on page boundaries
Handle a section that ends exactly at a page boundary.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-15 21:54:59 +08:00
bunnie
a59e4f995c initial take at converting loader to do fallback instead of fail-hard 2021-08-12 03:48:11 +08:00
Sean Cross
6d7660b76a loader: debug: fix minor clippy warning
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 11:55:56 +08:00
Sean Cross
f7f7ac2ee0 loader: add small comment
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-04 12:50:20 +08:00
Sean Cross
c5445da5d2 loader: only pre-allocate the first stack page
For each program, only allocate the first stack page. This will ensure
we don't use too much stack.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-04 12:48:14 +08:00
bunnie
4c777976ac clear RAM on a cold boot
since the RAM is battery backed and persistent, it's probably
a good idea just to zero-ize it before using it on a cold boot.
2021-07-22 03:03:27 +08:00
Sean Cross
7c0e6ba81d loader: print an error on invalid public key
Instead of silently panicking, print an error to the screen and /then/
panic.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-07-13 20:07:11 +08:00
bunnie
a4f8346c34 reflect the latest fixes to the secure boot process
also patch up some issues with sha512 reset and loose
ends on docs and updates
2021-07-13 00:46:31 +08:00
bunnie
5d62af49a5 simple signature checks in the bootloader now
checks xous.img as a single blob before accepting it.
2021-07-12 17:16:22 +08:00
bunnie
2b19f31da9 set the stage for simple signature validation on the kernel 2021-07-12 02:26:50 +08:00
bunnie
8007eabd54 Merge branch 'main' of github.com:betrusted-io/xous-core into main 2021-07-11 04:15:26 +08:00
bunnie
1949c1bbc9 a semblance of sanity, finally 2021-07-09 23:01:50 +08:00
Sean Cross
d96b6c15c8 loader: ensure stack is 16-byte aligned
The stack must be 16-byte aligned in order for `u32` to work properly,
as the compiler assumes these values are aligned.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-07-07 14:32:08 +08:00
bunnie
6c697de512 add l2 cache support (suspend/resume flushing)
also noted some performance benchmark improvements
2021-07-05 17:05:10 +08:00
bunnie
a70b858812 convert to using the urandom interface 2021-06-11 16:29:25 +08:00
Sean Cross
ff46015127 loader: increase stack size to main process
The graphics server has been observed to explode stack. This increases
the start size of the stack to prevent this from happening.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-10 15:08:46 +08:00
Sean Cross
e43f333faa loader: don't map the stack into the kernel
This prevents the stack from getting claimed by the kernel, or handed
out to another process.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-10 14:37:33 +08:00
bunnie
46fe3885dc cleanup more turds left over during the bringup of suspend/resume 2021-05-01 00:35:32 +08:00
bunnie
260b154741 clean up some boot process holdovers 2021-04-30 23:28:31 +08:00
bunnie
640ddb48e8 suspend/resume now works to hardware 2021-04-30 19:29:36 +08:00