Commit graph

591 commits

Author SHA1 Message Date
bunnie
d699ddf998 also move utralib change into kernel, update cargo.lock 2022-10-02 02:21:27 +08:00
bunnie
df96605531 update utralib reference 2022-09-29 22:22:33 +08:00
bunnie
96300db925 add license to kernel Cargo.toml 2022-09-27 18:43:39 +08:00
bunnie
c9f3d6a3d5 bump utralib ref in kernel so it works with the renode target 2022-09-27 18:32:04 +08:00
bunnie
ab940e18db fixup warnings 2022-09-27 17:27:21 +08:00
bunnie
755556611c prep kernel for packaging
- strip out gdb-stub. Per xobs, the feature never worked, and it
depends upon a branch of a git repo which is not allowed by crates.io
Since the feature hasn't been developed, and crates.io will not
allow even an optional feature that points to a git repo, the feature
was stripped out.

- rename "kernel" to "xous-kernel", so that we can live in a crates.io
package namespace that is specific to Xous.

still have to figure out the riscv package issue.
2022-09-27 17:02:20 +08:00
bunnie
57673052bf pass the v2p dependency onto xous-rs when it's activated in the kernel 2022-09-15 19:17:00 +08:00
bunnie
ea37ce2ea1 add feature gate on v2p per xobs' request 2022-09-15 14:06:07 +08:00
bunnie
6d9848c239 add virt_to_phys syscall
this will help speed up performance profiling as we can
resolve the physical address of the performance buffer allocated
in RAM and use a USB command to read it out, instead of streaming
it over serial.
2022-09-14 18:09:13 +08:00
Sean Cross
c9d5074dd2 kernel: riscv: use pointers for pagetable entries
Instead of passing a constructed mutable ref from the pagetable entry,
pass a raw pointer and use `read_volatile()` / `write_volatile(x)` on
this pointer.

This should remove a little bit of UB from the kernel.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-06-30 19:46:54 +08:00
Sean Cross
426fe4b91f kernel: riscv: don't crash when mapping invalid memory
Previously, the kernel would dutifully try to map memory that was in the
kernel space. It did this by investigating the kernel memory offset,
which immediately causes a double-fault.

Check to make sure a userspace process is not trying to map kernel
memory before checking the valid page.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-06-30 19:45:08 +08:00
Sean Cross
dcc964c3c1 kernel: riscv: use klog for memory exception printing
Signed-off-by: Sean Cross <sean@xobs.io>
2022-06-30 19:44:06 +08:00
Sean Cross
748d4ce87d Merge remote-tracking branch 'origin/main' into libstd-fs 2022-06-27 09:14:04 +08:00
Sean Cross
581603b205 kernel: services: fix compile error when debugging enabled
Signed-off-by: Sean Cross <sean@xobs.io>
2022-06-26 16:45:41 +08:00
Sean Cross
08958745ba kernel: implement AdjustProcessLimit syscall
Implement the syscall to adjust a process' limit. Currently this
only supports adjusting the heap maximum and the heap size.

In order to adjust a limit, you must first present the current limit.
This can be obtained by requesting a bogus value. The current limit is
returned as part of the result.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-06-24 00:09:35 +08:00
bunnie
6793f9c5da return non-0 heap size in case of increaseheap of 0
this allows hosted mode to work, as it always reports a 0
heap size.
2022-06-17 02:00:52 +08:00
bunnie
7456158fa9 remove custom ditherpunk flag from kernel
we can now do per-process stack size adjustment
2022-06-16 03:39:25 +08:00
Sean Cross
c6c9a26bf9 kernel: syscall: return heap size for DecreaseHeap
Return the heap size and offset when decreasing the heap. Additionally,
return the heap size when increasing the heap by 0 bytes.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-06-15 12:35:34 +08:00
bunnie
c687f7dc02 add a kernel feature flag so we can adjust stack size for ditherpunk
Don't want to make the stack size adjustment across the board
because it's helpful for managing/checking bloat as it happens.
2022-06-14 17:08:32 +08:00
bunnie
e32ea4d3f5 fix #174 2022-06-10 21:36:53 +08:00
Sean Cross
a1474b3e40
Merge pull request #166 from codemaster138/patch-1
chore: fix typo in build.rs
2022-06-10 19:42:39 +08:00
bunnie
2f096c1435 remove kernel Cargo.lock file
This is no longer  used since we moved to a monorepo. This also
removes some stale dependencies.
2022-06-07 14:10:54 +08:00
bunnie
aad8391a3e remove stale crossbeam-utils entry from Cargo.lock
unused lock dependency refers to a vulnerable version of
crossbeam-utils.
2022-06-07 14:06:01 +08:00
bunnie
09a968ef09 remove debug-here dependency
this contains a dependency to `failure` two levels down that has a critical
vulnerability. Unfortunately no new versions of debug-here have been
published in a while. It's no longer used, so just stripping it out
altogether.
2022-06-07 14:00:25 +08:00
Sean Cross
8edf03a243 kernel: fix warning in hosted mode
Signed-off-by: Sean Cross <sean@xobs.io>
2022-05-31 11:18:43 +08:00
Sean Cross
75e855cc4d hosted: fix hosted mode after CreateProcess addition
Hosted mode spawns processes very differently, and this difference was
not reflected after changes were made to native mode.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-05-30 13:41:05 +08:00
Sean Cross
a241d89b5b kernel: ignore "ppid unused" warning for now
Signed-off-by: Sean Cross <sean@xobs.io>
2022-05-29 19:41:13 +08:00
Sean Cross
4250d5bb10 kernel: re-disable verbose kernel messages
Signed-off-by: Sean Cross <sean@xobs.io>
2022-05-29 19:39:45 +08:00
Sean Cross
9aa83bbfb5 kernel: unmap child process pages after setup
Unmap the pages from the child process after we're done setting them up.
This ensures they're not still aliased by our process, despite being
marked as "owned" by the other process.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-05-29 19:38:22 +08:00
Sean Cross
a2e57195ba kernel: implement CreateProcess for riscv
Implement a functioning CreateProcess syscall on riscv. This call
creates a server in the child process, and connects the server to the
parent. The parent can communicate with the child process using this
server.

The Server ID is passed as four `u32` values to the entrypoint function.
This can be reassembled into something that can then be passed to the
`ReceiveMessage` syscall.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-05-29 18:47:37 +08:00
Sean Cross
2e69ae8a12 spawn: compiles, but does not work yet
Signed-off-by: Sean Cross <sean@xobs.io>
2022-05-28 05:10:48 +08:00
Jake
ac8b3acbd7
chore: fix ypo in build.rs 2022-05-26 17:53:33 +02:00
Sean Cross
d8eb7be352 process: finish implementing ProcessStartup as return
We now us `ProcessStartup` as the return type. This builds in tset
mode, hosted mode, and RISC-V mode.

Process Startup is still not implemented for RISC-V mode.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-04-28 22:43:42 -04:00
Sean Cross
6d294c97c5 kernel: print connection count on per-process output
Signed-off-by: Sean Cross <sean@xobs.io>
2022-04-05 15:11:47 +08:00
Sean Cross
ab512c8996 kernel: services: fix recursion warning in Process
The `Process::defualt()` implementation started getting a recursion
warning in 1.60.0.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-04-05 13:32:48 +08:00
Sean Cross
6f4b58c47d kernel: add process name to server output
Signed-off-by: Sean Cross <sean@xobs.io>
2022-04-05 10:41:22 +08:00
Sean Cross
ce4e40b28a kernel: add s command to print servers
This will print all allocated servers on the system.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-04-05 10:36:00 +08:00
Aaron Bieber
6f98940189 Switch to using env to find the path to bash.
Systems like OpenBSD and NixOS have bash in different locations. This
allows the various scripts to be run on those systems.
2022-03-28 16:43:47 -06:00
Sean Cross
5fddf7c230 kernel: implement UpdateMemoryFlags syscall
This call is used to strip flags from a chunk of memory.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-02-07 13:36:48 +08:00
bunnie
002e098538 Fix issue #90
Turns out we didn't end up needing this capability, so, commenting it
out because it is a shy too powerful and is like packing a live
mortar shell in a storage unit: eventually, someone is going to
get hurt, even though it seems mostly harmless at the moment.

Code just commented out in case we need this feature in the future,
but, the main reason it was asked for (the PDDB) was accomplished
without it.
2022-02-02 00:37:57 +08:00
bunnie
a4a7f4af69 fix hosted build 2022-01-18 00:32:12 +08:00
bunnie
e8e389552f add map generation to the loaders 2022-01-17 00:04:03 +08:00
Sean Cross
7cd86b4fcf Merge branch 'main' of github.com:betrusted-io/xous-core into kernel-monorepo
Signed-off-by: Sean Cross <sean@xobs.io>
2022-01-14 15:33:10 +08:00
Sean Cross
35af35381a kernel: integrate kernel into main monorepo
This moves the kernel into the main monorepo, allowing it to share
packages with the rest of the system. This change will allow us to
reduce the number of rebuilds that take place, as well as reducing disk
usage.

Note that the loader is still an indepenent project, and the integration
of that into the monorepo is pending.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-01-14 15:31:36 +08:00
bunnie
4561336ebd try to fix the CI test routine 2022-01-10 19:03:20 +08:00
bunnie
eb0c1c4377 fix some hosted mode brokeness that came with pinning crates
the rand api was downgraded to be in line with the ed25519 crate
which removed some "modern" conveniences. Small price to pay for
less code to review.
2022-01-10 17:13:00 +08:00
bunnie
b3788a54af clarify the dependency policy 2022-01-10 16:50:10 +08:00
bunnie
995915ed4e nail down a couple more dependencies, and add a policy note to Cargo.toml
Each Cargo.toml now includes a comment which remnids maintainers
of the dependency policy for Xous (that is, nail down every dependency
to the minor number).
2022-01-10 15:54:27 +08:00
bunnie
d06d58b132 harmonize rand crate to 0.7.4 (version used by ed25519-dalek) 2022-01-10 15:03:23 +08:00
bunnie
4819703d20 trim unnecessary sha3 dependency 2022-01-10 14:59:41 +08:00
bunnie
19f95e6bab fix kernel test build 2022-01-08 01:00:20 +08:00
bunnie
9fcd7e17ae warning-clean. need to clean up the hosted mode flow a bit. 2022-01-07 23:22:12 +08:00
bunnie
dd14dfc4c6 retrofit the seed into an atomicu64 so we can set it elsewhere 2021-12-27 02:49:08 +08:00
bunnie
0bd110c163 determinism achieved for testing. now to squash some bugs. 2021-12-26 01:50:30 +08:00
bunnie
66606ed3e0 initial attempt to make hosted mode more deterministic
replace all threadRng with a seeded Rng
2021-12-25 15:58:27 +08:00
Sean Cross
75116d36cd kernel: add debug command to print interrupts
This can be used to ensure the interrupt handlers are where we think
they are.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-10-29 16:21:07 +08:00
bunnie
013606a4b2 this time, with saving the merge file (some weirdness in vscode...) 2021-10-04 17:34:24 +08:00
bunnie
44615c9acf Merge branch 'main' of github.com:betrusted-io/xous-core into main 2021-10-04 17:28:35 +08:00
Sean Cross
24dd538a5c kernel: fix process exception handling state
Correctly handle transitions to and from exception handling.

Previously, the thread ID was incorrectly set such that the exception
handler became a valid thread. This has been adjusted so that the
exception handler is no longer considered a thread, and all other
threads will cease scheduling during this process.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-09-28 09:20:12 +08:00
Sean Cross
1ef4c0d87d kernel: mem: actually free unmapped pages
Previously we would only free a page if it was valid. Now we
unconditionally free it.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-09-27 19:40:39 +08:00
Sean Cross
956d5f0866 kernel: remove debugging prints for memory allocation
Signed-off-by: Sean Cross <sean@xobs.io>
2021-09-27 19:38:15 +08:00
Sean Cross
fa31e2235c kernel: allow freeing unbacked virtual memory
Memory is on-demand allocated, meaning it's entirely possible to
allocate and free memory without ever touching physical pages.

Previously, when we attempted to free memory, it would skip over pages
that were never backed by real memory.

With this patch, we continue to free the virtual page even if there is
no associated physical page.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-09-27 13:42:48 +08:00
Sean Cross
62216b7295 kernel: allow freeing unbacked virtual memory
Memory is on-demand allocated, meaning it's entirely possible to
allocate and free memory without ever touching physical pages.

Previously, when we attempted to free memory, it would skip over pages
that were never backed by real memory.

With this patch, we continue to free the virtual page even if there is
no associated physical page.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-09-27 13:39:10 +08:00
bunnie
6304ba4616 backout syscall patch 2021-09-27 13:34:02 +08:00
bunnie
be8a3a9acd an attempt to create the failing test case, but it seems this is too simple 2021-09-26 00:43:46 +08:00
Sean Cross
0ae6d1460a kernel: update version of gdbserver
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-25 16:05:56 +08:00
Sean Cross
7d3d710554 kernel: gdb_server: don't inline functions
This was a holdover from size benchmarks.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-25 16:05:27 +08:00
Sean Cross
30eb24af61 kernel: debug: fix wrap-print on xous target
When targeting the `xous` target, we were missing some variables due to
them relying on `target_os="none"`.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-25 16:04:42 +08:00
Sean Cross
b43366e6ec kernel: services: fix suspend for running processes
If a process is currently running, it needs to be placed into the
`Debug` state rather than the `Ready` state.

Additionally, the process that's being switched to must enter the
`Running` state.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-25 16:03:06 +08:00
Sean Cross
1cb86078d5 kernel: riscv: suspend or terminate processes that fail
If a process fails for some reason (e.g. by performing a fault) and
there is no exception handler, either terminate the process or (if
gdbserver is enabled) have it suspend the process.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-25 16:02:11 +08:00
Sean Cross
184274782c kernel: config: temporarily remove support for lto
LTO is currently broken with Rust 1.54.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-18 18:16:13 +08:00
Sean Cross
bb0339652a kernel: use local copy of riscv crate
A local copy of the `riscv` crate is used in order to get support for
the `xous` target_os.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-18 18:15:29 +08:00
Sean Cross
19653e9c53 kernel: compatibility with riscv32imac-unknown-xous-elf
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-18 18:14:24 +08:00
Sean Cross
e44eec2334 kernel: fix remaining warnings on hosted mode
This removes all remaining warnings from hosted mode. Tests pass, and
the system continues to run normally.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-16 15:07:25 +08:00
Sean Cross
5eaa3a41b1 kernel: services: fix warnings on hosted mode
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-16 15:01:07 +08:00
Sean Cross
90d1c7a4b8 kernel: move arch mods into their own dir
Move `hosted.rs` into `hosted/mod.rs` and `riscv.rs` into
`riscv/mod.rs`.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-16 14:55:38 +08:00
Sean Cross
c59cdfbd51 kernel: rename WouldBlock syscall result
This reflects the new naming convention, which is clearer.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-16 12:25:39 +08:00
Sean Cross
afdf8531aa kernel: use resolver v2
This is required now to support tests, since tests create processes as
threads.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-16 12:25:15 +08:00
Sean Cross
1b315de830 kernel: make init proces stack grown downwards
Previously, we were creating a stack beginning at the initial page,
and then growing it upwards. The correct behavior is to begin it at
the top and grow it downwards.

In order to do this, subtract the size of the stack from the initial
pointer.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-15 19:26:11 +08:00
Sean Cross
e29dc5a739 kernel: don't allow allocating exception thread
This prevents the exception thread from being allocated as a normal
system thread.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-15 19:25:29 +08:00
bunnie
5113df5eec Merge branch 'bunnie-dev' into main
Use a RefCell to solve the interior mutability issue introduced
by the &mut check introduced on MemoryRanges.
2021-08-10 18:13:33 +08:00
Sean Cross
9b4333802d vscode: specify platform for vscode support
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 17:51:47 +08:00
Sean Cross
fa2a841f8a kernel: fix hosted mode exception support
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 17:51:24 +08:00
Sean Cross
6985fda7ba kernel: get exceptions fully working
This finishes work with exceptions such that they now actually work.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 17:47:44 +08:00
Sean Cross
9bba083e2e kernel: remove debug print from mem.rs
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 13:05:23 +08:00
Sean Cross
15c9eadc4c kernel: riscv: re-fix mem warnings
The previous approach did not work, and broke everything. This fixes it
properly.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 13:02:16 +08:00
Sean Cross
b6f706411b kernel: gdb_server: fix clippy warnings
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 12:55:22 +08:00
Sean Cross
68f5e81d3f kernel: riscv: fix warnings in process
Fix clippy warnings in the `process.rs` file.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 12:54:43 +08:00
Sean Cross
dbd34318ce Revert "kernel: fix remaining clippy warnings"
This appears to have broken things.

This reverts commit 8b0dd3630c.
2021-08-06 12:51:40 +08:00
Sean Cross
8b0dd3630c kernel: fix remaining clippy warnings
This removes all remaining clippy warnings from inside the kernel.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 11:43:34 +08:00
Sean Cross
0a6a1f2edd kernel: syscall: ignore final Clippy warning
This warning is due to some debug information that is currently unused.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 11:39:09 +08:00
Sean Cross
cc8dc49dba kernel: riscv: refactor irqs to support exceptions
This fixes the exception handler so that it can support user-defined
exceptions. Additionally, kernel mode errors are called out now.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 11:37:27 +08:00
Sean Cross
19f68edbb4 kernel: riscv: allow exceptions with NULL pc
When the program counter is NULL, we can still get exceptions. This
happens when we jump to an invalid address, for example.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 11:34:50 +08:00
Sean Cross
08b787a03e kernel: debug: fix remaining clippy lints
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 11:34:30 +08:00
Sean Cross
c7ff0ceb21 kernel: mem: fix remaining clippy lints
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 11:32:52 +08:00
Sean Cross
d27a2eb27e kernel: mem: use iter instead of array access
This compresses the entirety of the memory range finder into a single
statement. As a result, duplicate code is removed and we can elide more
range checks.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 11:30:29 +08:00
Sean Cross
9dc4fcbf55 kernel: services: fix all clippy warnings
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 10:16:29 +08:00
Sean Cross
d4675ef9cf kernel: services: allow unsetting exception handler
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 10:05:29 +08:00
Sean Cross
5b2ac0df68 kernel: implement SetExceptionHandler routine
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 10:03:29 +08:00
Sean Cross
76953985fe kernel: fix clippy warnings in mem/server
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 10:03:12 +08:00