Commit graph

214 commits

Author SHA1 Message Date
bunnie
37d35b8e27 add small memory option for fonts to loader 2024-01-29 03:34:03 +08:00
bunnie
e4b0362024 make space for fonts in loader + sig verification code 2024-01-28 16:02:12 +08:00
bunnie
f432968678 add fonts back into the loader for the cramium target 2024-01-28 02:15:48 +08:00
bunnie
474d42ff87 pull in improved API to loader 2024-01-27 16:53:15 +08:00
bunnie
1e93171575 turn of rkyv derives in kernel and loader, as these are no-std 2024-01-23 03:59:49 +08:00
bunnie
d981bbe550 add more features to the loader for the cramium target
this *shouldn't* break other builds because the loader has
its arguments set by xtask for every target explicitly.
2024-01-21 01:14:51 +08:00
bunnie
6786efbb01 add PL230/PIO test to bringup section 2024-01-20 21:32:20 +08:00
bunnie
47dbecfd0b print trng status on bringup boot 2024-01-20 16:17:02 +08:00
bunnie
798183fe95 add TRNG output to board bring-up test 2024-01-20 01:26:30 +08:00
bunnie
0e14761641 cleanup loader code path
- print a banner on boot even without bringup
- stylistic improvements
2024-01-19 23:21:40 +08:00
bunnie
f12ddb09cb uart Rx in loader now seems to work. 2024-01-18 19:09:49 +08:00
bunnie
6f81024c77 refactor loader to use cramium-hal primitives
this is instead of the raw bitbang stuff we were doing before.
2024-01-18 18:02:23 +08:00
bunnie
659796916a chore: cleanup typos in docs, comments 2024-01-15 02:16:43 +08:00
bunnie
0267a56989 format Cargo.tomls
because apparently cargo fmt doesn't format Cargo.toml files???
2024-01-15 00:14:39 +08:00
bunnie
221972e955 remove trailing whitespace on loader 2024-01-14 23:59:20 +08:00
bunnie
454ecac95a fix rustfmt::skip warning
turns out, stackoverflow has out of date info. woohoo!
2024-01-14 23:12:52 +08:00
bunnie
a6a28b9d9e format loader 2024-01-14 22:02:55 +08:00
bunnie
3d6ba05c95 ok...@generated is useless, let's try a different approach.
@generated "marker" needs to be a naked comment on a line by
itself. I'm not quite sure how this is meant to be used, tbh.
2024-01-14 22:01:03 +08:00
bunnie
ee6190a12a prepare for format 2024-01-14 21:51:11 +08:00
bunnie
a5137e69b1 remove legacy script 2024-01-14 21:50:54 +08:00
bunnie
0692a25323 fix cramium build targets 2024-01-08 02:33:27 +08:00
bunnie
3da1ed181e set hash default value to 0x30 ("0")
this makes it much easier to detect if a loader failed to set
a hash in other routines.
2024-01-08 00:21:06 +08:00
bunnie
7b8a598020 wire up the hash computation to the hash consumption 2024-01-08 00:17:54 +08:00
bunnie
7719dbcb69 write hash into the environment variable
Convert the fs_prehash into a hex ascii string, suitable for environment variables
The initial loader environment is hard-coded, so we use a hard-coded offset for the string
destination. It was a deliberate decision to not include a generic environment variable
handler in the loader because we want to keep the loader compact and with a small attack
surface; a generic environment handling routine would add significant size without much
benefit.

Note that the main purpose for environment variables is for test & debug tooling, where
single programs are run in hosted or emulated environments with arguments passed for fast
debugging. The sole purpose for the environment variable in the loader's context is to
this computed hash onto the userspace environments.
2024-01-08 00:16:48 +08:00
bunnie
8f3229c9ea convert secboot to have an argument for returning the hash
also compute the hash and return the value as part of this patch
2024-01-08 00:16:20 +08:00
bunnie
2f47a9d4f2 more rework of pre-hash argument
While ideally we'd be as light-fingered as possible on the cryptographic
APIs, unfortunately the reality is we have exactly one hardware
hash engine and we can't just leave the context laying around.

Given that the verification routine would consume the hash, that
would make it unavailable for use later on to pass to the system.
So, this patch set causes the pre-hash algorithm to take a simple
slice-u8 instead of a whole hash context.

The downside of this is it erases the type information about
needing a 64-bit hash to go into the context. This is partially
mitigated with an assert that gives us a run-time check of this
property.
2024-01-08 00:13:35 +08:00
bunnie
4b002c34f5 Merge branch 'main' into prehash 2024-01-07 23:42:22 +08:00
Sean Cross
d8c6881554 loader: pass environment to processes via stack
Load environment variables to processes by placing the value onto the
stack. This will support additional data in the future such as command
line arguments.

Note this is a breaking change and requires a kernel modification.

Signed-off-by: Sean Cross <sean@xobs.io>
2024-01-07 22:36:34 +08:00
bunnie
1454637915 add sha as a depedency of the loader
this is exposed now that we have to explicitly pre-compute a hash
as part of boot.
2024-01-05 16:09:03 +08:00
bunnie
5894e71095 convert bootloader to use prehash method
This applies to the *kernel* image.

The loader itself is still signed with the conventional signature.

Version number of the loader is also incremented.
2024-01-05 16:08:22 +08:00
bunnie
d88e446a33 finalize pre-hash before initializing a new hash
we only have one hash engine in hardware, and we want to use
hardware hashing at boot to speed things up as much as possible
and reduce code size of the bootloader.

This patch causes the pre-hash to finalize before a new hash
is initialized which folds in all the other key parameters.
2024-01-05 16:07:23 +08:00
bunnie
8ec08c9c76 fix rust v1.75.0 warnings that are probably benign
a lot of re-import warnings have cropped up. While I appreciate
their studiousness on this, the problem is that removing some
of these exports in the API crate could mean that future users
who want access to some API features that aren't used in this
configuration are now unaccessible.

I think it's not a huge problem at the moment, just spam-cleaning
the warnings because there are too many to deal with carefully
at the moment.
2024-01-04 19:15:28 +08:00
Sean Cross
88020c99e0 loader: add pid to map_page() call
Add the pid as the page owner to `map_page()` calls. This ensures pages
are owned by their respective processes, and removes a lot of
`change_owner()` calls that immediately follow page mapping.

It also allows for superpages to be owned by their respective processes.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-29 18:42:16 +08:00
Sean Cross
e0c62e5480 loader: don't reserve the "susres" page
The "susres" page should be owned by the "susres" server and not the
kernel. Avoid mapping this page to the kernel to prevent it from getting
double-mapped.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-29 18:42:16 +08:00
Sean Cross
aee07683b7 loader: run cargo fmt
There are no changes to this project.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-27 14:12:26 +08:00
bunnie
e2ba706f4b modify loader to setup the console UART
this avoids a bunch of nasty pinmux stuff that would have to
go into the console logger at early boot
2023-09-15 16:25:44 +08:00
bunnie
07303dccc2 add FPGA target to loader clock settings
this might want to get a more graceful feature option wrapped
around it but i'm hoping the unpleasantness of developing on
the FPGA board is...temporary??
2023-09-15 11:25:35 +08:00
bunnie
53469a68d0 publish package updates, sync to release tag 2023-08-08 14:35:49 +08:00
bunnie
b127cd093f bump version pins for change to xous-rs 2023-08-03 13:29:39 +08:00
bunnie
51278451a0 update version pins to pull in cramium target 2023-07-19 21:07:56 +08:00
bunnie
ca14ed78d2 fix renode build 2023-07-18 13:58:14 +08:00
bunnie
8155c0cc8b loader fixes for cramium target 2023-07-18 03:56:09 +08:00
bunnie
a118cdaa6d fix link file integration 2023-07-17 18:52:28 +08:00
bunnie
3a32e3e7a0 fix visibility of cramium module 2023-07-17 18:49:54 +08:00
bunnie
e0c8cc1da4 add cramium to loader target 2023-07-17 18:23:17 +08:00
Sean Cross
b23f6717ef loader: remove unneeded muts
Rust 1.71.0 reports more cases of unneeded mutability. Remove these from
the loader.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-07-16 15:30:23 +08:00
bunnie
4454dffe4e generate loader files for the new font
also sort the font files in alphabetical order now,
instead of relying on arbitrary ordering of os.listdir() :P
2023-07-05 14:44:30 +08:00
bunnie
30c752db75 bump the loader's font tables 2023-07-05 13:38:28 +08:00
bunnie
952ba18fba commit vesrion pin bumps 2023-06-16 01:30:18 +08:00
bunnie
5a2df4432c technical debt: cleanup UTRA package
- make the "base" field no longer public. It is accessible, but only
through an `unsafe` method, because, it is unsafe.
- add accessors to offest/mask fields. Because, it's not at all
unsafe to access these, and it can be useful for bit-ops that are
not part of the generic set of UTRA.
- add Arc to AtomicCSR, and require `std` for AtomicCSR types.
This should not break anything, I checked inside @foundation-devices
keyOS and they don't seem to be using AtomicCSR anywhere.

The Arc makes it a bit safer to clone the AtomicCSR base pointer
and share it between threads, but it will have an impact on performance.
The USB stack (which requires AtomicCSR) was regression testing and the
impact seems minimal.

Recall that the main purpose of AtomicCSR is to provide a CSR accessor
that does not require a mutable reference to the base object. This
can make certain Rust idioms a bit cleaner. We wrap the base accessor
in Arc+Atomic to try and improve the safety of throwing the borrow
checker under the bus, but it's still not perfect because hardware
mutable state can have side-effects within hardware itself that cannot
be modeled or checked by Rust's borrow checker.
2023-05-23 18:11:24 +08:00