Commit graph

307 commits

Author SHA1 Message Date
bunnie
d7a8671e7e allow a process to identify itself
this makes debugging code a lot more ergonomic. I don't think
this impacts security...
2024-05-21 01:07:59 +08:00
bunnie
c412f44b51 quiet down debug in the irq routine 2024-05-18 00:24:25 +08:00
bunnie
c06612e43e lock down some key pages
- no swapping of kernel pages
- mark L1 PT's properly in the memory allocation table
  (was accidentally marking them with the VA of the first address
   allocated)
2024-05-16 03:53:07 +08:00
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
8824372101 make debug a little more compact for the renode swap target 2024-05-13 21:02:32 +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
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
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
a3e55834e9 checking in the corresponding kernel changes to the RPT type alias 2024-05-12 16:28:14 +08:00
bunnie
1f12a97b64 cleanup debug 2024-05-08 07:22:43 +08:00
bunnie
77cfc34f59 make panic outputs in hex
everything else is in hex, why should these be in decimal...
2024-05-06 18:47:11 +08:00
bunnie
f635917658 fix typo 2024-05-06 02:06:15 +08:00
bunnie
4db82e01d8 retrieve tid as well as pid when invoking swapper 2024-05-04 02:01:56 +08:00
bunnie
feefb57791 cleanup some debug output 2024-05-04 02:01:38 +08:00
bunnie
39a427e1b0 improve debug output 2024-05-01 14:27:31 +08:00
bunnie
5f425ebc56 expand flags scope and fix swap test 2024-05-01 14:27:06 +08:00
bunnie
88a9854e54 add swap flags to debug output 2024-04-30 18:35:54 +08:00
bunnie
863f17652d broaded scope of conditional compilation 2024-04-28 02:57:04 +08:00
bunnie
ecf2396d0c put debug prints behind debug flags 2024-04-28 02:41:29 +08:00
bunnie
73c834d067 start debugging of swap in kernel
switching contexts to bringing up hardware.
2024-04-22 10:58:37 +08:00
bunnie
cc75520bc2 fix missing commands in non-swap path 2024-04-01 18:11:35 +08:00
bunnie
7d38d1761e add missing config flags 2024-04-01 15:58:16 +08:00
bunnie
ec439a38d4 handle both cases in the irq return handler
differentiate between the case that we got here via
a page fault, or a syscall, and handle appropriately
2024-04-01 14:08:15 +08:00
bunnie
2f23225b9d update API for advise alloc 2024-04-01 14:07:43 +08:00
bunnie
0e756003a1 debugging around the swapper protected context calls 2024-03-31 17:25:47 +08:00
bunnie
504253a033 more tid recording 2024-03-31 17:25:05 +08:00
bunnie
28b415cb27 handle swapped pages and allocation advisories 2024-03-23 11:59:31 +08:00
bunnie
14364e09c6 ensure compliance with unsafe conditions on exit_blocking_call() 2024-03-23 11:59:31 +08:00
bunnie
47a16b6ce4 add RETURN_FROM_ISR magic address
this is picked to not conflict with other addresses used by
the ARM implementation. I think it should be OK?
2024-03-23 11:59:31 +08:00
bunnie
26047bf956 add the routine to evict a page 2024-03-23 11:59:31 +08:00
bunnie
6f18a0ed21 add trampoline to return from swapper 2024-03-23 11:59:31 +08:00
bunnie
daf4d9a93e make valid bit mapping symbolic instead of hard coded constant 2024-03-23 11:59:31 +08:00
bunnie
a1cffed9cd un-use the P bit in the page table
prep for re-allocating it to swap
2024-03-23 11:59:31 +08:00
Sean Cross
b4d6884cc4 kernel: use addr_of!() and addr_of_mut!()
DUe to https://github.com/rust-lang/rust/issues/114447 direct access to
static mut variables causes a warning which will be turned into an
error in the 2024 edition.

The workaround is to use `addr_of!()` and `addr_of_mut!()` macros and
then dereference that.

Signed-off-by: Sean Cross <sean@xobs.io>
2024-03-22 15:53:11 +08:00
Sean Cross
ed4ec01017 kernel: support riscv32imac-unknown-none-elf
With Rust 1.76.0, we no longer support building with `#![no_std]` or
`panic = "abort"`, both of which are required within the kernel. As a
workaround, go back to building the kernel under
`riscv32imac-unknown-none-elf`.

Signed-off-by: Sean Cross <sean@xobs.io>
2024-02-06 10:28:33 +08:00
bunnie
64f8285239 cleanup warning 2024-01-29 03:49:33 +08:00
bunnie
a79b134d14 add placeholder for v2p/PID mapping
We need the V2P feature, but don't need the ability to swap
PID spaces yet. Leave the alternate API as a todo!() item
in the kernel for riscv targets.
2024-01-19 23:23:28 +08:00
bunnie
607db9c573 remove trailing space in kernel 2024-01-14 23:40:30 +08:00
bunnie
f9fc3d0d4b ok, format the kernel now that all in-line assembly has been checked 2024-01-14 19:27:14 +08:00
bunnie
710c45969f Revert "format the kernel"
This reverts commit 1f69e6aa39.

this has in-line assembly, let's fix that before we format
2024-01-14 19:24:33 +08:00
bunnie
1f69e6aa39 format the kernel 2024-01-14 19:11:19 +08:00
bunnie
0750644e45
Merge pull request #479 from betrusted-io/process-arguments
Support process arguments
2024-01-07 23:39:45 +08:00
Sean Cross
60f2a17649 kernel: support receiving process arguments
Support passing process arguments in register 2 as part of arguments to
a process.

This requires updating the `InitialProcess` struct that is received from
the loader, and so requires modeifications to be made in tandem.

Signed-off-by: Sean Cross <sean@xobs.io>
2024-01-07 23:02:58 +08:00
bunnie
c3f3ef91b2 fix #474
dbf28fbd61 from 9 months ago
actually broke the resume path, but we didn't see it until now
because the .a files are checked into the tree.
2024-01-06 16:41:31 +08:00
bunnie
c9407a2d47 harmonize hosted mode to latest kernel API for get_pid() 2024-01-04 18:30:48 +08:00
Sean Cross
d5816b667a kernel: riscv: remove unsafe code from process
Remove transmutes from process.rs and replace them with ordinary casts.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-29 18:24:31 +08:00
Sean Cross
d4893c1c83 kernel: riscv: add phys_to_virt function
The phys_to_virt function can be used to determine what physical address
page is mapped to a virtual address page.

This throws an error when a page is mapped twice, which shouldn't
happen.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-29 18:23:19 +08:00
Sean Cross
124040bbb3 kernel: asm: align kernel stack to 16 bytes
The kernel stack offset should be aligned to 16 bytes. Previously it was
aligned to 8 bytes. It's unclear if this was the cause of any issues,
but it is best practice to keep things aligned to 16 bytes.

As part of this, key the atomic instructions off of the CPP macro
presence of atomic instructions.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-29 18:15:48 +08:00
bunnie
488d976f23 move original copy to new location, trying to preserve commit history 2023-12-27 15:04:27 +08:00