Commit graph

930 commits

Author SHA1 Message Date
bunnie
e2379821e6 republish xous-rs to fix cargo test 2025-05-11 15:36:17 +08:00
bunnie
8a4959056b bump version for xous crate update - commit so we can publish crates 2025-05-11 14:45:24 +08:00
bunnie
7af009be78 migrations for moving constants out of xous-rs/kernel and into board/platform
this is a fairly major re-org of where key constants go that
define platform features. things that were in xous-rs that were
platform specific (namely precursor) were moved into a boards file,
and things that are generic to the system (like PAGE_SIZE) are moved
to a public location in xous-rs::arch.
2025-05-11 12:50:02 +08:00
bunnie
63e4319314 add partial support for memory mapped flash (alloc virt without phys backing) 2025-05-11 12:49:23 +08:00
bunnie
f5315dc014 incorporate partial support for virtual-only alloc swap into kernel
also has migrations for constant locations
2025-05-11 12:46:56 +08:00
bunnie
e2f5892e29 add a target for the kernel specifically on the boards
this allows us to map the spinor values in for the swapper
without having to break other abstractions
2025-05-06 19:09:37 +08:00
bunnie
1dcf7b191b adjust kernel dependencies to match new tree 2025-02-20 13:32:21 +08:00
bunnie
4f14a67504 formatting changes due to changes in nightly rust
needed to get a clean check on gh
2025-02-01 22:26:40 +08:00
bunnie
d40463da28 fixup bitrot in feature flags 2025-01-01 22:51:16 +08:00
bunnie
c8cb5cda47 ignore dead code in shell.rs
when the debug stuff is commented out, a bunch of unused code
warnings happen in the shell interface
2025-01-01 22:48:52 +08:00
bunnie
03d67de1f6 kernel in -fpga variant uses duart 2025-01-01 22:48:32 +08:00
bunnie
4f21bf3c3e raw pointer dance for memory allocations and extra allocations
this is probably the most significant source of consternation but
also this code path has been fairly well-trodden.

That being said it might be worth considering if there is any
way to use some of the new Rust const based reasoning logic
to see if we can't tighten this up someday, but today is not
that day.
2024-12-02 19:10:39 +08:00
bunnie
b59177176b raw pointer dance for the SWITCHTO_CALLER 2024-12-02 19:06:25 +08:00
bunnie
8876f6e7f5 raw pointer dance for IRQ handlers 2024-12-02 19:05:56 +08:00
bunnie
9662f13d31 raw pointer dance for kernel TRNG 2024-12-02 19:05:24 +08:00
bunnie
64612352d3 raw pointer dance for debug UART 2024-12-02 19:04:37 +08:00
bunnie
95611d9598 This begins a series of commits to cleanup a static_mut warning
So in Rust 1.83, we now get a strongly worded warning telling
us to really, really don't use static muts. They aren't wrong,
except that in some places like the kernel we have few options:
we are conjuring pointers out of thin air, creating memory mappings,
and then doing things with them that are hard for the compiler
to reason about.

I think the newly minted warning was made because the intention
is that we could use the new fancy `const` semantics to take
the place of static mut usage by wrapping things in UnsafeCell,
and I think maaaaybe in some
cases this could apply here, but as a simple example a dive
into the kernel debug UART indicates that to initialize the
shared variable we have to allocate pages in the page table,
which involves calling the memory manager and doing some
decidedly non-const type of things. So one option is we could
just push the debug UART initialization into the loader and
paper over the whole thing by pretending it's static.

Instead of that, we adopt a pattern of casting all our static
muts to a raw pointer, and then back into what we want. The
cast to raw pointer is like an "uber unsafe" marker that says
"no we really mean that this pointer is where it is and we
conjured it out of thin air and we promise that the behavior
is defined and values are representable, etc.".

In general we're fairly judicious about the use of static
mut in the kernel, and when in the kernel there's no thread
pre-emption (although we could take an interrupt or page
fault) so generally we are single-threaded. The trickiest
spots are when we have to take a page fault while handling
a page fault (for example, allocating a new L1 page table
entry would require something like this) but this code path
is fairly carefully vetted.

So instead of just doing a global lint silence, we use an
`&raw` idiom to call out the fact that we're doing something
naughty wherever we do it, which makes the compiler "happy"
(for now) while still making the code ugly enough that it
looks sufficiently scary and you have to apply some
cognitive burden to even reason about what's going on,
which I *think* is the intention of Rust in this case.

Basically you get a get out of jail free card but you can't
simply wear it on a lanyard and pass through the gate -- every
time we need to use it, we have to do a little dance and
wash ourselves in the waters of unsafety and recite the
mantras about defined behavior, representable numbers, thread
safety, etc.
2024-12-02 18:55:18 +08:00
bunnie
bee7be762f pass the verilator-only flag on to the cramium-hal dependency in kernel 2024-11-30 02:22:01 +08:00
bunnie
6961bb3e54 fix a bug in debug-print when swap is not specified
a field doesn't exist that is accesed by a debug-print resource
in the case of swap being inactivated
2024-11-30 02:21:20 +08:00
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