Commit graph

649 commits

Author SHA1 Message Date
Sean Cross
787d77fcbd kernel: implement FreeInterrupt
This syscall is the opposite of ClaimInterrupt.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-04-06 10:42:45 +08:00
eupn
90df83f885
kernel: revamp IRQ handling 2023-04-05 16:35:01 +04:00
bunnie
e469eba167 bump version for utralib patch 2023-04-04 02:13:02 +08:00
bunnie
704aaf98af bump versions for kernel interface changes 2023-03-22 02:48:55 +08:00
bunnie
488a220d43
fix URL to public URL
didn't know i could just edit this directly in GH!
2023-03-22 01:05:10 +08:00
eupn
723a730231
kernel: fix warnings 2023-03-14 19:01:11 +04:00
eupn
e2d34d364c
kernel: always print when process is terminated 2023-03-14 18:48:45 +04:00
eupn
1634243f63
kernel: fix compile errors 2023-03-14 18:48:15 +04:00
eupn
7f5656445a
kernel: change some println!s to klog!s
Even when the print-debug feature isn't turned on, println! macro is still able to output some critical non-debug info to the console such as panics, process crashes and violations, etc. Debugging messages are printed with klog! macro that's disabled when debug-print feature is not set.
2023-03-14 18:47:57 +04:00
eupn
89a1447df4
kernel: checkout arm assembly binary 2023-03-14 18:41:45 +04:00
eupn
a42366b6cf
kernel: add arm to asm scripts 2023-03-14 18:41:33 +04:00
eupn
618392ca52
kernel: add arm features and deps to Cargo.toml 2023-03-14 18:39:19 +04:00
eupn
10bffc55b6
kernel: update build script to pick arch specific linker and asm binary 2023-03-14 18:37:40 +04:00
eupn
434e865a45
kernel: add sama5d2 uart workaround 2023-03-14 18:36:41 +04:00
eupn
0953812dfc
kernel: hide hw specific details in process init 2023-03-14 18:35:12 +04:00
eupn
3451d106f9
kernel: update debug and shell modules 2023-03-14 18:32:52 +04:00
eupn
38a02f9dbb
kernel: split precursor and sama5d2 platform modules 2023-03-14 18:30:07 +04:00
eupn
2ecd91b3c5
kernel: split arm and riscv arch modules 2023-03-14 18:28:49 +04:00
bunnie
303f595d6f bump versions to cleanup renode.rs sync issue 2023-03-14 16:34:53 +08:00
bunnie
82e3aa322f bump toml files in prep for publish 2023-03-08 03:54:37 +08:00
bunnie
73aa6c3b14 cleanup hosted mode warning 2023-02-15 20:35:32 +08:00
bunnie
6563ad174e bump revision 2023-02-15 20:35:16 +08:00
bunnie
fced4608b6 bump kernel package rev 2023-02-15 20:26:30 +08:00
bunnie
08ae66a264 fix: #320
this commit adds the facilities to extract eh_frame[_header]
sections and pass it to each process.

A bump is required to `std` to extract the passed parameters.
2023-02-15 19:55:08 +08:00
bunnie
80f031b7e7 bump kernel version 2023-02-12 12:58:42 +08:00
bunnie
4a2234f539 XIP works with some processes, but not others
it works with e.g. shellchat, but not vault.

still scratching my head on what's gone wrong -- it's
crashing in the pre-boot, which means something is not
mapped right for some case that wasn't caught in the
earlier testing.
2023-02-11 01:42:04 +08:00
bunnie
053bc8a06f bump kernel rev 2023-02-03 00:12:57 +08:00
Sean Cross
dc097e32d8 kernel: fix atomic operations
Atomic operations were previously broken. RISC-V breaks atomic
operations into multiple instructions, and there is some state kept
between those instructions. This state is not visible, and is internal
to the processor.

We were ignoring this state, which resulted in inconsistencies
throughout the system. The following sequence was possible:

1. A thread loads a value, and obtains the `reservation set`
2. A context switch happens on the following instruction
3. A different thread loads the value, modifies it, and continues
4. A third thread (or a different process) loads a value and obtains the
   `reservation set`
5. The original thread runs, sees the `reservation set` is held, and
   updates the value, clobbering what the second thread did in #3

A workaround for this is to perform a dummy `sc` as part of the context
switch. This invalidates any atomic operations that may be pending.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-02-02 23:10:12 +08:00
bunnie
8b7876360f bump kernel package version 2023-02-01 22:45:37 +08:00
Sean Cross
043365ac82 kernel: re-add set_last_thread
git somehow dropped this function during the merge, which would have
made things very sad.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-02-01 20:45:43 +08:00
Sean Cross
c7f5ad25b1 kernel: syscall: fix restoring thread id
The previous patch didn't properly restore thread IDs when switching
contexts -- there were spots where we missed things, and spots where we
were double-borrowing.

Fix these corner cases.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-02-01 20:43:45 +08:00
bunnie
680ddd1c58
Revert "Give servers their full quantum" 2023-02-01 14:08:16 +08:00
bunnie
119296ed5b
Merge pull request #314 from betrusted-io/messages-late-return
Give servers their full quantum
2023-02-01 13:46:01 +08:00
Sean Cross
63e6deae53 kernel: save current thread at context switch
Note the current thread in the original process when its quantum
expires. This will allow us to clean up after ourselves when a context
switch occurs, and will help to prevent thread starvation.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-02-01 10:46:25 +08:00
Sean Cross
4ec43363f5 kernel: don't always context-switch on message return
Currently, returning a Message (e.g. a Scalar1, Scalar2, or
MemoryMessage) always results in a context switch from the server to the
client. This is what makes these syscalls cheaper.

However, this results in process starvation. For example, if three
processes send a message to a server, then the server will only be able
to respond to one of those messages at a time. This works well with a
lightly-loaded system, but quickly falls apart when many threads are
running.

Keep track of which process and thread were originally switched to as
part of the `SwitchTo` call. If the Server is responding to a message
and owns the current quantum, don't immediately switch to the Client
thread.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-02-01 10:19:07 +08:00
bunnie
cc97f157e4 bump kernel rev for publication 2023-01-31 16:10:53 +08:00
Sean Cross
1303e6416d kernel: fixup current_thread==0 on resume
For some reason, the current thread becomes 0 during suspend or resume.
This causes an error during boot.

Patch this up while we figure out what's causing it.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-01-31 16:01:35 +08:00
Sean Cross
abb1455fe6 fix previous commit
Signed-off-by: Sean Cross <sean@xobs.io>
2023-01-31 15:51:31 +08:00
bunnie
d5b5a83445
Merge pull request #311 from betrusted-io/unify-kernel-scalar-return
Unify kernel scalar return
2023-01-31 15:48:59 +08:00
bunnie
9256e7cc09 bump versions to absorb xous-names fix 2023-01-31 15:07:32 +08:00
Sean Cross
778e217de8 kernel: unify scalar return calls
Unify scalar return calls so that we only have one return path rather
than three.

We can almost unify memory returning as well, but it's not quite there.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-01-31 14:46:38 +08:00
Sean Cross
fc8d78c2ec kernel: fix hosted mode
The process scheduler changed in subtle ways taht completely broke
hosted mode.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-01-31 11:24:09 +08:00
bunnie
84368c3f3a bump versions for publication 2023-01-31 02:18:12 +08:00
Sean Cross
8875d9b4b4 kernel: services: fix corner cases on thread selection
There were a few corner cases when it came to thread selection. Namely,
the same thread had a higher chance of repeatedly being executed.

Clean up these corner cases, and as a result get libstd tests to pass.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-01-30 22:15:01 +08:00
Sean Cross
af3f89d245 kernel: syscall: add notes for handing mem to user
Add notes on how to properly hand memory to userspace. This does not yet
work, but is committed here as a work-in-progress.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-01-30 22:15:01 +08:00
Sean Cross
1d6c1e34de kernel: mem: increase default mem size
The default mem size got shrunk down to 4 MB earlier, but there is a
lingering issue that prevents specifying virtual addresses. As a result,
pddb and others don't work.

Temporarily revert this change.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-01-30 22:15:01 +08:00
Sean Cross
a75d030d77 kernel: main: simplify process search
The process search now uses iterators properly. It's still not ideal
because it needs to investigate every process, but it's better than it
was.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-01-30 22:15:01 +08:00
Sean Cross
7f7142d948 kernel: riscv: print processes from tid #0
Start numbering threads from index 0. This matches up with what the rest
of the system uses.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-01-30 22:15:01 +08:00
Sean Cross
8c82736524 kernel: syscall: short-circuit return_scalar irq
When in an IRQ, short-circuit the return logic. This should make
interrupt returns slightly faster.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-01-30 22:15:01 +08:00
Sean Cross
502223ec9b kernel: syscall: rename context to tid
The word `context` is an older word. We now use "thread" or "tid".

Signed-off-by: Sean Cross <sean@xobs.io>
2023-01-30 22:15:01 +08:00