Commit graph

17 commits

Author SHA1 Message Date
bunnie
7ff1e438ff make decrypt_page_at fallible
previously we just panic'd (which is actually the right behavior
for this type of error) but because we now have a reason for it
to fail (e.g. testing the encryption key) we make this fallible.

in all other places we just unwrap() - there is no fallback if
decryption fails, boot should just halt.

but this allows us to check which decryption key is deployed
in phase 1.
2025-10-04 18:54:15 +08:00
bunnie
75fbcd5be8 fix some bit-rotted constant locations in the precursor target 2025-05-15 11:54:02 +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
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
82be129df1 fix typo 2024-05-05 03:26:21 +08:00
bunnie
228558a722 add platform specific hw inits & key retrieval
- swap session key has to be stored so we can pass it on to
the kernel to access swap

- setup all PT maps necessary for swapper to be functional
before the swapper is started.

This is to break circular dependencies mapping pages inside the
swapper, especially during boot.

We might also need to statically map the LRU swap count structure,
not sure. We'll burn that bridge when we get there, right now,
let's just get a non count-managed swap even working...
2024-05-03 18:43:57 +08:00
bunnie
cd43157d1e refactor loader mac accessor interfaces
traits are kind of awful in Rust...it's true, they don't
know how big they are at compile time, so they have to be dyn,
reference, lifetimes, etc...

lot of baggage for a static structure. I guess there's probably
some idk bounds I could put on the traits to make it less poopy
but also just as easy to make it a static structure and not deal
with traits.
2024-05-02 22:13:11 +08:00
bunnie
03c3f61ba3 fixes to encrypt/decrypt routines to adjust offsets etc. 2024-04-08 23:54:36 +08:00
bunnie
30b5be7a79 remove superfluous import 2024-04-08 12:39:07 +08:00
bunnie
26efde0a71 track address of the decrypt buffer 2024-04-07 22:36:54 +08:00
bunnie
bd54417e44 add routines for shuttling encrypted data to/from swap RAM region
RAM is assumed to be off-chip, and thus the data is encrypted
in the region. We also encrypt it in the Precursor case, even
though it's on-chip, because we want to capture this as a test case
in a known working environment.

Also incorporate some routines to generate the per-boot random
key for swap encryption.
2024-04-07 18:58:54 +08:00
bunnie
999cb320ed add a function to nab the decrypt buffer
HIGHLY unsafe, but saves us a decryption operation as we
interleave between the various states of the loader.
2024-04-07 14:28:31 +08:00
bunnie
c7e1f22cfa fix pointer issue in resolving swap config
also a bunch of latent debug in case we need to muck around again
2024-04-07 00:39:34 +08:00
bunnie
32857a70b0 add platform-dependent drivers for swap
precursor does direct memory mapping
cramium uses a qspi interface
2024-04-06 22:59:43 +08:00
bunnie
8155c0cc8b loader fixes for cramium target 2023-07-18 03:56:09 +08:00