Commit graph

10340 commits

Author SHA1 Message Date
bunnie
1b0fc181a5 ensure process state is correct on errors; remove excess mmu flushes 2024-05-15 02:41:15 +08:00
bunnie
b86ee4b036 move irq-renable as late as possible; add helper function to access irq state 2024-05-15 02:40:31 +08:00
bunnie
27d7fb414c add debug on evictpage 2024-05-15 02:39:58 +08:00
bunnie
ff42e1ab20 better handling of oom_doom; wired page handling; fix bugs 2024-05-15 02:39:06 +08:00
bunnie
ef5388a30e ensure that process descriptors aren't swapped out 2024-05-15 02:38:24 +08:00
bunnie
f66debdd01 make susres page ownership not hard coded; mark PTs as wired
also marks the ProcessImpl page as wired too
2024-05-15 02:31:40 +08:00
bunnie
ad9ef3dedc cleanup comments and fix ordering of events 2024-05-13 21:05:46 +08:00
bunnie
cec4a06174 debugging eviction
currently able to trigger an eviction and it seems like some of
the pages actually go out, but there is some imprecision in the
syscall implementation for eviction that is causing the userspace
code to re-enter in a bad state after a few iterations of
the call.

checking code in as an intermediate checkpoint.
2024-05-13 21:04:30 +08:00
bunnie
b5f0c262e7 add some debug for the precursor target 2024-05-13 21:03:56 +08:00
bunnie
8824372101 make debug a little more compact for the renode swap target 2024-05-13 21:02:32 +08:00
bunnie
327205edb5 release page relies on a physical address, not a virtual address. 2024-05-13 21:00:17 +08:00
bunnie
235806025c clarify api names; add evict target pages; more error checking on eviction 2024-05-13 19:20:59 +08:00
bunnie
0847f99433 swapper abi fixes
- evict error checking - reject requests to swap kernel or swapper
- add target amount of pages to evict on oom handler
2024-05-13 19:19:50 +08:00
bunnie
b138f63f93 fix swapalloc ordering
we want a max-heap, because pops are cheaper on the sorted vec.
2024-05-13 19:19:15 +08:00
bunnie
0fca04f14e swapper needs write privs to the lent page
encryption is in-place to save on memory
2024-05-13 19:18:49 +08:00
bunnie
b2b31a2713 cleanup and re-org code 2024-05-13 17:26:38 +08:00
bunnie
74f75e1ef5 re-org swap code for readability, add oom_doom routine
some thought needs to go into when and how we call oom_doom
but let's test more core functionality of the swapper before we
worry about that. I can think of several places where we could
use that call, the main tricky bit is that oom_doom diverges
and so wherever we patch it has to be able to resume. If we put
it into e.g. somewhere in the main memory alloc loop, the trouble
is we would have to track all of the multiple places that we
could have arrived there...ideally we can find a single spot
to patch this, with a clean entry and exit path.
2024-05-13 17:24:35 +08:00
bunnie
258fa8c1c3 heavily refactored swapper core 2024-05-13 14:23:48 +08:00
bunnie
a07ab0e121 update comments and add license headers 2024-05-13 14:21:53 +08:00
bunnie
dcef549099 move SwapAlloc to the swap module 2024-05-13 14:15:38 +08:00
bunnie
c6d4d8ebc8 reflect dependency change in lockfile 2024-05-13 14:05:14 +08:00
bunnie
1bd07d7657 remove dependencies that we decided not to use 2024-05-13 14:04:54 +08:00
bunnie
c41889b22f update comments 2024-05-13 14:04:33 +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
9b89bde46a refactor alloc API
instead of sending scalar messages on every page alloc/free, which
is a lot of traffic, introduce an API where the swapper can request
a snapshot of the alloc status by mapping the kernel's alloc
table as a read-only structure into the swapper's memory space,
and then invoking the swapper in its interrupt context to read that out.

The structure is unmapped on return from the context.

additionally, a running tally of free space is now maintained
and this can be queried with a fast syscall.

Thus, the normal workflow is the swapper would have a timer that
periodically queries the kernel's free space level, and when it
falls below a critical amount, it will invoke the expensive snapshot.

this can also be extended so that the kernel can call into
the swapper's interrupt context with a "help, OOM imminent"
message down the road.
2024-05-13 13:59:17 +08:00
bunnie
8606d0ae83 add some more tracking to the loader
this will give us some more pages to swap out beyond the initial
set of free pages.
2024-05-12 22:29:50 +08:00
bunnie
a519bb2fa5 add resume to swap testing for completeness 2024-05-12 21:51:27 +08:00
bunnie
9101abf2c4 make swap resume-compatible 2024-05-12 21:51:14 +08:00
bunnie
6bef111bf2 fix RPT/XPT alloc in swap; make swap resume-compatible 2024-05-12 21:50:53 +08:00
bunnie
2ff46c4b8f this was not supposed to be checked in. 2024-05-12 21:21:36 +08:00
bunnie
84d42460eb correspending kernel changes for run time page tracker split
memory alloc table split into RAM region and everything else ("extra")
2024-05-12 20:23:29 +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
f657caa176 changes to atsama5d27 target for new kernel boot args
@eupn this could use a review, I have no way to test this
2024-05-12 20:22:07 +08:00
bunnie
a3e55834e9 checking in the corresponding kernel changes to the RPT type alias 2024-05-12 16:28:14 +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
b52e81a406
Merge pull request #540 from betrusted-io/deprecate-old-sha2
attempt to remove the last hold-out legacy sha2 dependency
2024-05-12 11:44:30 +05:30
bunnie
ceb89c64e6 attempt to remove the last hold-out legacy sha2 dependency 2024-05-12 14:12:28 +08:00
bunnie
4f30067244
Merge pull request #539 from betrusted-io/issue-538
patches for #538
2024-05-12 10:06:27 +05:30
bunnie
65caa55407 bump to minifb 0.26.0
solves #538
2024-05-12 12:32:45 +08:00
bunnie
f6bfddcf20 add swap usage tracking via offset flags and fix bugs in RPT init
also optimize amount of memory used in RPT copy by just tracking
the data that is swappable,i.e. main RAM
2024-05-10 13:32:58 +08:00
bunnie
64071661a5 clarify variable roles 2024-05-10 13:32:19 +08:00
bunnie
90108f266e allow this trait to be unused
it's not used in all configs but it's not a bad thing to have
it around.
2024-05-10 00:38:41 +08:00
bunnie
f1ee38cf6a remove unused feature flag that is triggering a warning 2024-05-10 00:38:29 +08:00
bunnie
d4a306172f reflect minifb version change in lockfile 2024-05-10 00:35:16 +08:00
bunnie
52e5d21e6f work around white screen issue on Windows 11 (#538)
This is the work-around suggested at

https://github.com/emoon/rust_minifb/issues/351

until a new release is tagged.
2024-05-10 00:33:59 +08:00
bunnie
12891d6af1 cleanup dangling server reference
i think this actually didn't break hosted mode because
sha2 emulation doesn't use hardware, but this cleans up
a warning at least
2024-05-10 00:08:04 +08:00
bunnie
87b53e77a4 map offset tracker into swapper state
this is allocated by the loader for the swapper. This should
be the last big piece of state we need to get the swapper to work...
honestly, it's already a pretty heavy bit of code :( we should
probably optimize out the RPT hand-off to not include all of
the non-swappable memory pages, which is quite substantial in
the case of some SoCs.

also refactor to use the loader's computation function for
the MAC offset in swap, instead of copying this hairy bit of
logic like....8 times over throughout the code base, yeaaach!
2024-05-09 02:09:43 +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
933a9a342d start to bring in more LRU; put shared state in Box 2024-05-08 07:23:27 +08:00
bunnie
3d98b28055 don't start EC during swap debug 2024-05-08 07:22:58 +08:00