Commit Graph

3178 Commits

Author SHA1 Message Date
G. Branden Robinson
fc251b5067 setup.py: add Python dependency on libarchive-c
The `shoehorn` tool in tools/seL4 (the sel4_tools repository) requires
this.

Bump minor version number per semantic versioning rules (interface
extension).  (0.3.1 instead of 0.3.0 because 0.3.0 saw the light of day
with an incorrect dependency on `libarchive` instead of `libarchive-c`.)
2019-08-28 15:54:10 +10:00
G. Branden Robinson
568f509b50 Revert "setup.py: add Python dep[] on libarchive"
This reverts commit a14264336c.

There are (at least) 3 namespaces relevant to Python module names:
Debian package names, PyPI module names, and the name of a module used
by actual Python language imports.  That's one more than my brain could
handle.  I wanted "libarchive-c" in setup.py instead of "libarchive".
2019-08-28 15:49:28 +10:00
Curtis Millar
9cd7958dbe hifive: Real time clock operates at 1MHz
The SiFive FU540-C000 runs mtime on the rtcclk which operates at 1MHz
from an external oscillator.
2019-08-27 10:46:13 +10:00
Curtis Millar
2f00d10f0e mcs: enable MCS for riscv
This allows an MCS kernel to be built on a RISC-V platform.
2019-08-27 10:46:13 +10:00
Curtis Millar
ccfd672039 mcs: Boot RISC-V with scheduling control & context
Make sure that when the kernel boots a scheduling control cap is created
and that the initial thread and idle thread are scheduled using correct
systemt time.
2019-08-27 10:46:13 +10:00
Curtis Millar
18219bbedf mcs: RISC-V uses 39-bit addressing in stuctures.bf
RISC-V uses 39-bit virtual addressing rather than 48 bits so the
'high' bits of a pointer can be 39 or fewer bits on RISCV rather than
48.
2019-08-27 10:46:13 +10:00
Curtis Millar
af34037edb trivial: spelling of the word 'canonical' 2019-08-27 10:46:13 +10:00
Curtis Millar
97782dcfb0 mcs: Update size constants for RISC-V
Update the notification size constant for the larger notification of MCS
and add the constant for the size of the reply object.
2019-08-27 10:46:13 +10:00
Curtis Millar
7adf81f6d7 mcs: fastpath_reply_recv reply argument for RISC-V
Add the reply argument to the fastpath_reply_recv call for RISC-V.
2019-08-27 10:46:13 +10:00
Curtis Millar
d869b3adb7 mcs: Timeout fault and reply for RISC-V
Add fault and reply for timeout faults on RISC-V.
2019-08-27 10:46:13 +10:00
Curtis Millar
f100d73f9c mcs: add mcs capability variants for riscv
When building for RISC-V, capabilities should include SchedControl and
SchedContext capabilities.
2019-08-27 10:46:13 +10:00
Curtis Millar
c45f2f0169 mcs: libsel4 for RISC-V
This uses the aarch64 code as a basis for implementing the full set of
new and updated libsel4 functions for RISC-V.
2019-08-27 10:46:13 +10:00
Curtis Millar
449dcd5038 mcs: Select additional registers for RISC-V
mcs requires an additional 2 registers for performing system calls to
pass information regarding the reply capability and the destination of a
nbsend/recv.
2019-08-27 10:46:13 +10:00
Curtis Millar
210eb59d9d mcs: Implement timer functions for RISC-V
Introduce the functions needed to read the time and set the timer for
MCS in RISC-V.
2019-08-27 10:46:13 +10:00
Curtis Millar
e19fddbb56 mcs: Remove timer init and reset from RISC-V
The timer init and reset are not needed to initialise the clock for MCS
in RISC-V.
2019-08-27 10:46:13 +10:00
Curtis Millar
1c4b6424d8 riscv: Fix rollover when reading time in 32-bit
If the time is being read in 32-bit mode it is read in two operations
between which the time can change. If the time causes the low bits to
roll over to 0 and the high bits to increment between reading the low
and high bits an incorrect time will be returned.

A check is added to ensure that an accurate time is returned.
2019-08-27 10:46:13 +10:00
Curtis Millar
557f8d4fb8 riscv: Relocate read time to header
Move the RISCV function to read the current time to the header file so
that it can be inlined for MCS.
2019-08-27 10:46:12 +10:00
G. Branden Robinson
a14264336c setup.py: add Python dependency on libarchive
The `shoehorn` tool in the tools/seL4 (the sel4_tools repository) will
require this in a future commit.

Bump minor version number per semantic versioning rules (interface
extension).
2019-08-26 14:31:18 +10:00
G. Branden Robinson
d09cdc8329 trivial: add trailing comma to list element
Python syntax allows a comma after the last element of a list, and
having one helps avoid surprises in the event the lines of the list
are rearranged.
2019-08-26 14:29:29 +10:00
Kent McLeod
3b12f529d7 libsel4: Expose mcs constants to non-C files
Use the __ASSEMBLER__ macro to suppress C definitions from appearing in
non-C files when the preprocessor is used. Other libsel4/*/constants.h
files use this strategy to avoid duplicating definitions for seL4 object
sizes that can changed based on kernel configuration.
2019-08-22 13:32:11 +10:00
Kent McLeod
258d9d0b64 libsel4: Correct call for seL4_X86DangerousRDMSR
x64_sys_recv now requires an additional argument that is used for MCS
and ignored for mainline.
2019-08-22 13:24:52 +10:00
Kent McLeod
1387bfeb51 mcs: Update CHANGES file
Adds that mcs was merged into the changes file. More detailed release
notes will be included in the next release version.
2019-08-22 11:22:42 +10:00
Anna Lyons
acdf0be5e5 mcs: Fix potential crash on preemption
Preemption can be triggered due to a revoke operation, which may have
deleted one or both of the current thread and current scheduling
context. Don't manipulate the current thread if it is no longer valid
and just charge the SC iff it is valid and the thread is not.

This was discovered during verification.
2019-08-22 11:22:41 +10:00
Anna Lyons
b33d4680f2 mcs: Avoid charging invalid scheduling contexts
ChargeBudget can be called after a preemption, but the preemption may
have deleted the scheduling context. Do not charge scheduling contexts
that have been deleted (check scRefillMax).
2019-08-22 11:22:41 +10:00
Anna Lyons
86e50d0703 mcs: Avoid missing a timer tick
Preemption can be via the timer interrupt. In this case we need to
update the timestamp so we can reprogram the timer for the next timeout
and guarantee it is in the future, otherwise we will end up setting a
timeout in the past.
2019-08-22 11:22:41 +10:00
Anna Lyons
b358a1c59c trivial: move isSchedulable to header 2019-08-22 11:22:41 +10:00
Anna Lyons
bf56d30d47 trivial: remove redundant condition
Remove redundant condition in schedcontext_resume, discovered by
verification.
2019-08-22 11:22:41 +10:00
Anna Lyons
9dffbd0167 Avoid adding thread without budget to scheduler
Prior to this change calling yieldTo on an sc with a thread that was not
in the scheduler and had an insufficient/unready head replenishment
would be added incorrectly to the scheduler.

If the thread isn't in the scheduler, use schedcontext_resume to ensure
that it is in the release queue if it has an insufficient/unready head
replenishment, and thus prevent that thread from being added to the
scheduler.
2019-08-22 11:22:41 +10:00
Anna Lyons
3a1218b347 Fix: Move refill_unblock_check into isSchedulable
Don't modify sc parameters unless we know that sc is not in the release
queue.
2019-08-22 11:22:41 +10:00
Anna Lyons
257a62c73f mcs: explicitly use ksCurSC
- in refill_[budget|split]_check.
- This simplifies the code and the proofs.
2019-08-22 11:22:41 +10:00
Anna Lyons
52dd8f092a mcs: Avoid removing the SC of the current thread
If the scheduling context is changed on the currently running thread
this causes issues if the operation triggers a preemption. This change
makes the proofs easier, and also makes sense for the api, as users
wishing to suspend the current thread should just use Suspend.
2019-08-22 11:22:41 +10:00
Anna Lyons
12be249514 mcs: in cancelIPC, clear the tcbFault
A fault message is an IPC. Threads which have faulted can be inactive,
blocked on send, or blocked on reply. Always clear tcbFault when
cancelling IPC to make sure restarted threads are not in a fault state.
2019-08-22 11:22:41 +10:00
Anna Lyons
ef4ba6b69a mcs: Introduce firstPhase flag to invocations
Some invocations contain two phases, and certain operations cannot be
allowed to run in the first phase as it could effect the currently
running thread and result in an invalid system state for the second
phase. This change filters those invocations, preventing them from being
used in the first phase of a two-phase, blocking system call.
2019-08-22 11:22:41 +10:00
Anna Lyons
225d74f6ae mcs: Set threads to inactive in cancelBadgedSends
This is the same reasoning as for cancelAllIPC
2019-08-22 11:22:41 +10:00
Anna Lyons
5d1db7c94c mcs: Set thread to inactive if no reply is present
If we're in a scenario where do_call or fault is set, but there is no
reply, the calling/faulting thread needs to be set to inactive to
prevent it reentering the scheduler in a bad state. If the reply is set,
then the calling/faulting thread is set to blocked on reply correctly.
2019-08-22 11:22:40 +10:00
Anna Lyons
395df93969 mcs: Set threads to inactive in cancelAllIPC
If a thread's fault endpoint has been deleted, such that cancelAllIPC is
called on that endpoint, set the thread state to inactive. This prevents
threads with faults from entering the run queue and makes the
behaviour consistent with threads faulting without a fault handler set.

This came up as verification now need the invariant that threads in the
runqueue have no faulted, an invariant not required before MCS.
Previously the behaviour was not broken, as threads would just refault
and be made inactive at that point.
2019-08-22 11:22:40 +10:00
Anna Lyons
9ccdc857e7 mcs: Use rescheduleRequired in schedcontext_bind
Schedcontext_bind is currently called in ThreadControl, which
manipulates capabilities which in turn can result in KsSchedulerAction
being deleted. This means that we cannot use possibleSwitchTo in this
function.

This is a stop-gap fix for verification, the long term fix is to split
setting scheduling parameters from ThreadControl, then we can return to
a direct switch, and also do a direct switch for other thread/scheduler
settings like priorities.
2019-08-22 11:22:40 +10:00
Anna Lyons
f1113460b4 mcs: Fix setPriority
When setting a thread priority, we need to check if it is in the
scheduler before putting it back in the scheduler, otherwise we do not
know enough about the scheduling context to know that the thread is
active.
2019-08-22 11:22:40 +10:00
Anna Lyons
61b886664d mcs: fix notification donation semantics
- update thread state before donate
- schedcontext_resume after donate

This ensures our scheduling invariants (on the run queue) are held.
2019-08-22 11:22:40 +10:00
Anna Lyons
82601b883b mcs: only donate on fault if the faulter has an SC
Fix bug found by Corey during verification
2019-08-22 11:22:40 +10:00
Anna Lyons
6195ea6651 mcs: break call chain in reply_remove_tcb
Rather than preserving the chain break it completely. This changes the
semantics such that if a reply is removed in the middle of a call
chain, a donated scheduling context cannot return to the original
caller.
2019-08-22 11:22:40 +10:00
Anna Lyons
6611cff6c0 mcs: fix behaviour on seL4_SchedContext_YieldTo
When yieldingTo a same prio thread, the same prio thread should run
first, not the current thread. Due to changes to possibleSwitchTo in
master scheduler this code became outdated and the current thread would
be rescheduled immediately.

The desired behaviour is that the thread being yieldedTo should be at
the head of the scheduler queue for its priority, and the current thread
should be just after it.
2019-08-22 11:22:40 +10:00
Anna Lyons
58725c4920 mcs: Preserve the value of scConsumed on Yield
We use the chargeBudget logic in the kernel on seL4_Yield to free up
the budget available in the head refill, however this
updates scConsumed. Given this is a simulated charge (the thread is
yielding the budget, not actually using it), this is incorrect.
2019-08-22 11:22:40 +10:00
Gerwin Klein
ba78e3b298 mcs: allow only unbound SC/TCB in SetSchedParams
This removes some special-casing from the proof.
2019-08-22 11:22:40 +10:00
Gerwin Klein
9412c98e33 trivial: sync comment with code 2019-08-22 11:22:40 +10:00
Gerwin Klein
754baa8fad mcs: Swap TCB cap install order in ThreadControl
Installing the endpoint caps before the CSpace/VSpace roots is easier
for verification, because deleting endpoint caps is always well-behaved,
but CNode cap deletion can be complex.
2019-08-22 11:22:40 +10:00
Anna Lyons
cfd8924a9f smp: always migrateTCB on schedcontrol_configure
we have no guarantees as to where the FPU context is
2019-08-22 11:22:40 +10:00
Anna Lyons
3d56973743 smp: remove excess code in schedContext_donate
- always migrate the TCB (the FPU context could be anywhere)
- don't need to call migrateTCB or rescheduleRequired, this is handled
by calling paths.
2019-08-22 11:22:40 +10:00
Anna Lyons
8cb01f32ec smp: remove excess remote call stall in unbindTCB
This isn't required as all code paths into this function have already
stalled the tcb
2019-08-22 11:22:39 +10:00
Anna Lyons
26205f61e1 smp: remove excess code in bindTCB
- we know the tcb does not have an SC at this point
- it may need to migrate if the FPU context is still on the other core.
2019-08-22 11:22:39 +10:00