Commit graph

911 commits

Author SHA1 Message Date
bunnie
820acfa2e6 make sure that swapper pages are marked as wired once allocated
also improve debug output, it was a little nonsensical previously
(some bit rot on meaning of fields)
2024-11-07 16:10:27 +08:00
bunnie
a854ad53ea fix broken code in deep debug option 2024-11-07 16:10:07 +08:00
bunnie
b3de92aabc add option to dump kernel pages in panic dumps 2024-11-07 16:09:49 +08:00
bunnie
735c4bfedd add debug options for sussing out IRQ problems in the kernel 2024-11-07 16:05:47 +08:00
bunnie
843d928126 update manifests to point to board descriptions 2024-10-04 13:05:59 +08:00
bunnie
75954de8d6 commit the version bump 2024-09-23 01:46:25 +08:00
bunnie
bb7209508b update formatting on the published crates
not doing a reformat of the entire project to match
nightly formatting changes, but capturing the published
crates so we can maybe save a version bump later on to get
the project clean.
2024-09-23 01:43:02 +08:00
bunnie
89f92c28a2
Merge branch 'main' into nto-work 2024-08-19 02:30:35 +08:00
bunnie
6eab1c48bb patches to clean up warnings in rust-1.80 2024-08-19 02:24:24 +08:00
bunnie
6ddc8bc79a
Merge branch 'main' into nto-work 2024-06-27 00:41:07 +08:00
bunnie
311154e231 absorb version bump 2024-06-27 00:26:12 +08:00
bunnie
a9b0ba2666 improve documentation on how the CSPRNG is reseeded from the TRNG. 2024-06-22 21:18:24 +08:00
bunnie
3ae4fde572 fix comment 2024-06-21 18:20:10 +08:00
bunnie
3e8cfab6b0 fix hosted mode 2024-06-20 01:56:36 +08:00
bunnie
32893b9b4c fix build option 2024-06-19 22:04:42 +08:00
bunnie
474343c24e deprecate SID assignment
We no longer send messages to the swapper via the server interface.

All calls go through the blocking handler; in general, there are
no scenarios where it makes sense to have a swapper operation
pre-emptable. We always want our swapper ops to complete quickly,
deterministically, and atomically.
2024-06-19 21:39:54 +08:00
bunnie
96630a11ee handle the case of a failed PTE allocation gracefully
instead of hard crashing, we return an appropriate error.

Also add some debug instrumentation.
2024-06-19 21:39:17 +08:00
bunnie
c5aee47861 update comment to reflect current policy on OOM
I think it's more Xous-y to punt to userland in the case that
no consecutive memory is found, rather than trying to implement
an evictor in the kernel itself.

For now, the blunt hammer we use is to simply request some
blocks be freed and we retry; this works well enough to find
blocks of a few pages in sequence. If we needed larger blocks,
we may want to consider modifying the swapper userland algorithm
to have some API for finding consecutive runs of non-wired
memory to swap out.
2024-06-19 21:37:00 +08:00
bunnie
6ba57774cf add "device RAM" allocation mode to kernel
"Device RAM" is a block of RAM whose physical address is not
important, but the block must be consecutively allocated in
physical address space.

This is used to allocate blocks of memory that are intended
for hardware DMA targets and other peripheral shared-memory
applications.

Note that this also marks the allocated block as "wired", so
it can't be swapped out.
2024-06-19 21:34:42 +08:00
bunnie
7a821a836f cleanup comments 2024-06-18 00:07:43 +08:00
bunnie
ec41c73aa9 harden kernel TRNG
apply the same techniques in the loader key generator to
the kernel TRNG. Every pull of data from the kernel reseeds
the TRNG state as well. This makes server ID creation somewhat
more expensive, but should greatly improve the security of
the system in the case of a TRNG with occassional drop-outs.
2024-06-15 00:40:04 +08:00
bunnie
7743d96e91
Merge branch 'main' into trng-test 2024-06-14 19:17:11 +08:00
bunnie
0fd6ad7c0e
Merge branch 'main' into new-rust-warnings 2024-06-14 19:14:02 +08:00
bunnie
0036c46ea1 clean up warnings in the latest rust 2024-06-14 19:10:18 +08:00
bunnie
53f8a9f1d6 apply entropy hardening on boot to kernel as well
Shoot for 256 bits minimum entropy in the seed pool, gives us
some safety margin over our required 128.

note that the pool only gets more entropy over time, as every
call to the pool folds more entropy in (roughly 2 bits per call).
2024-06-14 16:12:17 +08:00
bunnie
223e1995ef fix the fix :P 2024-06-13 15:56:37 +08:00
bunnie
242c682a74 cleanup warning that snuck in 2024-06-13 15:54:32 +08:00
bunnie
a360f3ee52 bump xous pins for RawTrng API 2024-06-13 15:49:35 +08:00
bunnie
6b9955c30e add raw-trng feature 2024-06-13 15:42:34 +08:00
bunnie
40651a37ea add RawTrng syscall implementation 2024-06-13 15:42:18 +08:00
bunnie
a5322eaa7a add sampling countermeasures to the kernel
this evolves the TRNG state further after reporting any raw samples
for QC to make it harder to reason about the TRNG state after QC.
2024-06-13 15:41:30 +08:00
bunnie
ff3138b72b bump stack limit
we did encounter a panic in testing
2024-05-31 20:39:18 +08:00
bunnie
1761b38b23 prevent formatting of assembly 2024-05-31 03:34:21 +08:00
bunnie
d92a8dd00d tweak backup stack space allocation in kernel now that we've tested on hw 2024-05-29 14:05:16 +08:00
bunnie
35e7cf3a5b bump xous dep revs 2024-05-29 02:07:06 +08:00
bunnie
755265d290 quiet down debug on syscalls 2024-05-28 20:28:55 +08:00
bunnie
c569fa528c handle corner case of OOM during move or lend
In this situation, we enter the OOM with the hardware address
space vs the process space inconsistent (the hardware address
space was transitioned in anticipation of mapping a block into it).

This patch reverts our address space to the original space then
runs the OOM routine, and then puts us back where we were.
2024-05-28 20:27:38 +08:00
bunnie
ec9a2be9cc reduce warnings when debug is turned off 2024-05-28 20:27:13 +08:00
bunnie
3cf79dbbd4 fix typos, adjust debug 2024-05-28 20:26:57 +08:00
bunnie
bed9252614 suppress warning when debug is turned off 2024-05-28 16:54:18 +08:00
bunnie
ed73dfb401 make retrievepage a re-entrant syscall: syscall abi 2024-05-28 02:49:00 +08:00
bunnie
747e07c90f remove code bits now that all syscalls are re-entrant
previously we could re-enter into a process through a divergent
call into the swapper. Now, we only ever re-enter as a syscall
through the syscall interface.

in order to make this happen we had to store all the thread and
stack state for the handler so we can do a re-entrant syscall, but
I think this is worth it. makes the code so much better.
2024-05-28 02:47:19 +08:00
bunnie
8ce2ac566a make swapper syscall API re-entrant (map/retrieve page)
we no longer diverge at the swapper call, so execution flows
intuitively here. this feels so much nicer.
2024-05-28 02:45:27 +08:00
bunnie
62eb233db1 make swapper api generic for re-entrant kernel calls (alloc element) 2024-05-28 02:44:36 +08:00
bunnie
0e135b0e4c refactor retrieve_page to use re-entrant syscall
- makes retrieve_page in-lineable into existing kernel routines
without a divergence issue on the call return
- reduces code duplication
- fixes a hairy bug on interrupt restore timing. With the previous
method, the interrupts would have to un-gate just before the
syscall executes its return to normalcy; this can cause a race
condition between a hardware interrupt and that return context
switch which can lead to the return context being corrupted.

By making this re-entrant, we can make the IRQ pause/restore
point happen outside of any fancy system context footwork, which
makes the interrupt via hardware source work again.
2024-05-28 02:41:08 +08:00
bunnie
fa777b6198 cleanup the original alloc_page now that all are oomable 2024-05-26 23:00:20 +08:00
bunnie
a799e4b09d make all other allocs possibly oomable 2024-05-26 22:57:53 +08:00
bunnie
fb502a8073 debug cleanup 2024-05-26 12:12:58 +08:00
bunnie
f1d5a015cc remove oom-doom path handler
in practice the hard-OOM only seems to happen, and oom-doom
takes up precious memory that could be used for preventing
OOMs. Just leave one path in, but make it a bit smarter.

The smarts are still in userland, so the kernel is minimal
dependencies.
2024-05-25 02:10:55 +08:00
bunnie
bd696e5a62 make the backing stack extent easier to configure 2024-05-25 01:34:11 +08:00