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>
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>
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.
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>
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>
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>
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>
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.
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>
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>
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>
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>
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>
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>