When the secondary boots and derefes the boot_ctx pointer passed in as a
parameter, it reads NULL, causing the secondary to end up stuck in an
exception loop. The data is sat in the primary core's cache and hasn't
been flushed to RAM. Since the secondary starts without the MMU (and
caches) enabled, the CCI doesn't kick in and we read stale data.
Manually flush the boot_ctx data to RAM before waking up the secondary.
The `sys_clock_nanosleep` implementation was missing a `flags` parameter
in the second position. This meant that `rqtp` was interpreted as
`rmtp`, and when interrupted, `rmtp` would write to a garbage address
causing an `EFAULT`.
Fix the argument ordering.
Poll the wrapped future first, ensuring that the interrupt logic doesn't
short-circuit a future which is already ready.
This fixes an issue where `sys_wait4` would return `-EINTR` when
receiving a `SIGCHLD`. Since `SIGCHLD` indicates the wait condition
is met, the underlying future is ready and should return the PID
successfully rather than aborting.
This function is used to force the scheduler to reschedule another task,
avoiding the fast-path exit. Given the sheer number of task state
change points in the code, the fast-path exit code has become too
brittle.
Instead, check that the current task's state is still `Running` before
taking the fast-path short-circuit. The cost of one spinlock uncontended
lock-unlock cycle is worth the cost of avoiding many subtle scheduling
logic bugs.
Allow a `read()` on a tty to be interrupted by a syscall. This is the
fundamental fix for making '^C' interrupt a process like `cat` when it's
reading from `stdin`.
Allow the `nanosleep` family of functions to be interrupted. When an
interruption occures, calculation the remaining duration and write that
back to user-space.
Add a test to ensure proper functionality into usertest.
Add a new struct, `InterruptableFut` which allows signal
short-circuiting logic. If a future within the kernel's syscall logic is
wrapped in a `InterruptableFut`, then a wakeup with any pending signals
causes the underlying future to be dropped and it's operation cancelled.
Provide a `InterruptResult` enum to allow the caller to know whether the
operation was interrupted and allows them to take appropriate action.
Typically exiting with `-EINTR`.
Finally, provide a blanket implementation for all futures, allowing then
to call `.interruptable()` to easily wrap any future.
Currently we close CLOEXEC FDs when we call `clone()` when making a copy
of the file descriptor table. Defer this until the `exec` syscall.
This fixes numerous bugs, namely with bash and setting the foreground
process group for the current TTY.
When calling `clone()` with PTRACE_O_TRACEFORK set, make the child
inherit the current ptrace context. Also start the process with SIGSTOP
pending as per the ptrace docs.
This enable strace follow-forks functionality `strace -f`.