Commit graph

96 commits

Author SHA1 Message Date
bunnie
c8b3fa9aad if swap is turned on bodge a extra page buffer on the memory clear
this prevents some key loader constants from being zeroed out
2025-05-15 11:54:26 +08:00
bunnie
cb60120bb2 add some prelim coreuser test routines
these currently only make sense in a simulation environment,
but they allow us to work the significant configuration test
cases for practical execution to make sure we haven't missed
something in the coreuser spec.
2025-01-12 00:55:43 +08:00
bunnie
f3517603e9 cleanup some feature flag bitrot 2025-01-01 22:47:19 +08:00
bunnie
189611f3c4 add updates, verilator-only, and simulation-only feature gates
- updates enables or disables updates in the loader
- verilator-only will turn off routines that access hardware not
present in verilator (e.g. leads to a bus lockup)
- simulation-only turns of features that take a long amount of time
and aren't necessary in simulation, such as bulk clearing of
all RAM - in simulation, we can configure the simulator to do this
for us prior to boot; but in HW, of course, RAM is just random,
or worse, has the previous session's secrets in it.
2024-11-30 02:27:35 +08:00
bunnie
391fb84f00 update api to inclued perclk_freq 2024-11-20 01:43:25 +08:00
bunnie
9867a3e488 cleanup loader path to use dynamically derived perclk 2024-10-04 22:52:25 +08:00
bunnie
59b15541f3 add stubs for lifecycle management and update checking in loader
this is just a reminder to me on how i was planning to implement
this after going through a big side-quest to change other things.
2024-10-01 23:15:54 +08:00
bunnie
043dfd84ae update formatting to latest nightly rules 2024-09-24 01:49:45 +08:00
bunnie
e705dba13f quite down swap debug in loader 2024-05-21 17:57:41 +08:00
bunnie
2e1ad6e1a4 remove T:Copy bounds on bzero
not quite sure why it is even there, might just be a thing from
really old code we never removed. Removing this allows us to
specify pointer types to non-copy elements, making Rust do
the hard work of figuring out how big of a block we need to zero.
2024-05-21 16:02:59 +08:00
bunnie
b7becf27e7 quiet down warnings when debug-print is off
because the print! macro becomes a dummy when debug printing is
off, we get a bunch of warnings about unused variables because
the print! arguments aren't used. Add _ before variable names
to quiet these warnings.
2024-05-21 01:52:30 +08:00
bunnie
a94dce11f7 add loader support for rpt tracking/mapping
trying to condense most of the RPT API into the loader so
that the userspace can use a single dependency for this.

We can't condense the kernel API into the loader unfortunately,
because the kernel actually uses a different type for representing
a process. This is probably a mistake, and is something that
may be fixed later so we can merge the representations.
2024-05-13 14:03:00 +08:00
bunnie
6bef111bf2 fix RPT/XPT alloc in swap; make swap resume-compatible 2024-05-12 21:50:53 +08:00
bunnie
903c903b2f split memory allocs into RAM and peripheral tables
RAM allocs can be augmented with more tracking data in the case of
swap.
2024-05-12 20:22:51 +08:00
bunnie
6080bc45d8 attempt to re-type the runtime page tracker to something we can use for swap
This is too expensive to use generically - we're going to have
to split the RPT, but checking in this change as a checkpoint
2024-05-12 16:27:30 +08:00
bunnie
95c27c765e refactor loader to use a single function to swap MAC offset in swap
also pre-map some pages to handle offset increment in swapper
2024-05-09 02:08:51 +08:00
bunnie
5ab014e715 cleanup the offsets for decrypt_src_page_at()
We had a "coincidence" before that allowed things to work,
where we had some data line up that we happened to think
was some other header data, so we "fixed" it by
subtracting the offset of the header data.

Actually, it wasn't.

Clarify that decrypt_src_page_at() offsets are relative
to the beginning of encrypted data, and not relative
to the absolute beginning of the disk.

Image creation is now fixed so that stuff lines up to what
this routine expects, and some asserts added to try and
save ourselves in the future as we try to fix other bugs
we discover over time.

loaders are hard.
2024-05-06 18:55:11 +08:00
bunnie
4ace363abc this resolves comments from @xobs' code review 2024-04-09 18:23:09 +08:00
bunnie
a66e4f5901 modify stack smash check to detect if non-PID is written
this is more robust, and should work across all architectures.

Note that the reliability of the check is slightly impacted
since we're now checking for a subset of valid numbers, so
the number of bytes checked is doubled.
2024-04-09 15:24:22 +08:00
bunnie
d6e7f7ce16 add debugging and asserts to detect stack smash in loader
In swap configuration, the loader does a lot more: it has
to decrypt full pages of RAM and hold them temporarily;
up to two pages at once, once for the decrypt of the source
swap image, and one for the encrypt to swap memory.

This causes a lot more stack to be used than the original loader.

Add some debugging for this, and an assert based on a heuristic
that the RPT (runtime page tracker) last few entries ought to
be 0. This I think is probably true on most platforms. If this
fails to be true, then, we can probably modify the assert to
fail if any number in the RPT is greater than the number of
processes: this should be true in *all* cases, but a stack smash
is very likely to write something in there that's larger than
the number of allowable processes in the system.
2024-04-09 15:17:49 +08:00
bunnie
d6a9c85acb extended debugging; make check_load aware of swap 2024-04-08 23:58:19 +08:00
bunnie
63a8b51fe9 gate SDBG behind feature flag 2024-04-08 12:38:02 +08:00
bunnie
8aa20e65f6 match new API for accessing swap 2024-04-07 19:00:18 +08:00
bunnie
c53515fc63 coalesce swap hal into boot config object; read initial swap args
this worked, so it validates the encryption/decryption of the swap
at least!
2024-04-07 00:41:18 +08:00
bunnie
903b2219db gate loader features behind flag 2024-04-06 23:01:04 +08:00
bunnie
a6696aaf77 add structure to differentiate image type
we now have three image types: inie, inif, inis; migrate
away from a simple "xip" flag to something that can differentiate
between all three options.
2024-04-01 15:28:04 +08:00
bunnie
a6a28b9d9e format loader 2024-01-14 22:02:55 +08:00
bunnie
0692a25323 fix cramium build targets 2024-01-08 02:33:27 +08:00
bunnie
7b8a598020 wire up the hash computation to the hash consumption 2024-01-08 00:17:54 +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
8155c0cc8b loader fixes for cramium target 2023-07-18 03:56:09 +08:00
bunnie
57cea9b3ca cleanup a warning when debug is not turned on 2023-03-22 02:47:41 +08:00
eupn
899351214b
loader: split hw specific details with feature gates in common modules 2023-03-14 17:15:17 +04:00
eupn
a0b9868068
loader: split panic handlers 2023-03-14 17:15:17 +04:00
eupn
3caf8dedd0
loader: split debug and asm modules between arm and riscv 2023-03-14 17:15:17 +04:00
eupn
787312bf82
loader: split consts between riscv and arm 2023-03-14 17:15:17 +04:00
Sean Cross
ab353c1bee loader: move the kernel stack to kernel region
The kernel stack previously was located at the same relative offset as
all other programs. While this worked, it is poor form.

Move the kernel stack into the kernel memory region (located in the last
4 megabytes of virtual address).

Signed-off-by: Sean Cross <sean@xobs.io>
2023-02-27 20:21:16 +08:00
bunnie
dfd4c1ab40 fix precursor platform test
the precursor platform test is a RAM stress test. This patch
improves the test slightly by making it more parameterizeable,
and having it run a bit longer.
2023-02-27 01:30:20 +08:00
bunnie
039de0bfe9 split loader into modules 2023-02-22 00:36:16 +08:00
bunnie
3437b94807 clean up a warning 2023-02-21 23:38:40 +08:00
bunnie
e34d740bc6 some final tweaks for cross-platform integration 2023-02-21 23:19:02 +08:00
bunnie
032bd864db parameterize the loader so it can work with multiple targets 2023-02-21 22:51:53 +08:00
bunnie
bdc0b79906 move assembly header into in-line assembly 2023-02-21 22:17:10 +08:00
bunnie
0c9f8c57c2 remove warning on unused murmur lib when no resume is enabled 2023-02-21 18:24:39 +08:00
bunnie
c4a55a3cb5 fix multiplatform details; bump version number printed 2023-02-21 18:19:12 +08:00
bunnie
0c6ee68a3b make secboot optional 2023-02-21 18:11:32 +08:00
bunnie
3d88a7b3de add platform option files to loader 2023-02-21 17:43:48 +08:00
bunnie
08ae66a264 fix: #320
this commit adds the facilities to extract eh_frame[_header]
sections and pass it to each process.

A bump is required to `std` to extract the passed parameters.
2023-02-15 19:55:08 +08:00
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