Commit graph

135 commits

Author SHA1 Message Date
Indan Zupancic
f3addaa0fb Trivial: Remove now incorrect comment
Signed-off-by: Indan Zupancic <Indan.Zupancic@mep-info.com>
2021-09-10 20:48:04 +10:00
Curtis Millar
6a9e860e4e mcs: Only unbind extant donated ntfn sc
When determining whether a SC donated from the notification should be
returned, we must ensure not to try and return a NULL SC to a
notification with not bound SC.

This could occur when a passive server performs a NBSendWait/NBSendRecv
with a notification in the receive phase, where the SC for the receiver
was returned in the send phase and the notification has no bound SC.

Signed-off-by: Curtis Millar <curtis.millar@data61.csiro.au>
2021-04-29 12:07:07 +10:00
Curtis Millar
afbea15710 mcs: Add sporadic flag to SchedControl_Configure
This adds a flags parameter to SchedControl_Configure to enable
configuration of a sporadic SC.

This also allows flags to be added in the future as needed without
breaking the API.

This allows the user to configure an SC either to be constrained as a
sporadic task where accumulated time is only delayed to when a task has
become runnable (implementing the sporadic server algorithm) or
whenever the task becomes the current executing task (implementing the
sliding-window constraint as in constant-bandwidth servers).

This can be used to prevent non-realtime tasks from exceeding bandwidth
under any circumstances, even in an over-committed configuration, whilst
also allowing work-conserving tasks to be configured in the same system.

To implement sporadic servers, we need to ensure that the suspension of
a task cannot be used as a mechanism to amplify budget of a task by
granting that task access to effectively multiple periods worth of
replenishments within a single period.

To align the implementation of SCs with the model of sporadic servers we
must delay available time until the release of a task. Within seL4, a
release would be any time where an SC changes from not being associated
with a Running, RunningVM, or Restart thread to one that is.

This can occur when an SC is bound to a new thread in such a state or
when a thread changes to such a state from any non-running states.

Critically, replenishments should not be delayed at the point when an SC
becomes the current SC (as was the case prior to this commit). This has
the effect of enforcing a continuous, constant bandwidth which is a
restriction that is incompatible with standard scheduling logic.

Accounting for this requires inserting a new refill_unblock_check
call whenever a sporadic SC is unblocked and removing the
refill_unblock_check call from when said SC is scheduled.

Signed-off-by: Curtis Millar <curtis.millar@data61.csiro.au>
2021-04-14 15:24:40 +10:00
Matthew Brecknell
4520503c8a remove slot_range_t
The RISC-V calling convention specifies that when a C function takes an
argument by value, the binary function should take the argument by
reference, if the value is larger than 2 pointer words.

For binary verification, we avoid implementing this aspect of the RISC-V
calling convention, by eliminating all such function arguments for
functions which are not inlined.

In this commit, we remove the `slot_range_t` structure altogether. For
the small number of functions which previously used this type, we unpack
the structure into three separate arguments.

Even though we are primarily concerned with RISC-V, we remove
`slot_range_t` arguments across all architectures.

Signed-off-by: Matthew Brecknell <Matthew.Brecknell@data61.csiro.au>
2021-03-19 11:29:51 +11:00
Matthew Brecknell
b2ad98214d avoid passing extra_caps_t by value
The RISC-V calling convention specifies that when a C function takes an
argument by value, the binary function should take the argument by
reference, if the value is larger than 2 pointer words.

For binary verification, we avoid implementing this aspect of the RISC-V
calling convention, by eliminating all such function arguments for
functions which are not inlined.

In this commit, we remove `extra_caps_t` function arguments. This
primarily concerns invocation decode functions. Since `loookupExtraCaps`
already stores extra caps in a global `current_extra_caps`, this
essentially amounts to eliminating many redundant structure copy
operations.

On some execution paths involving IPC, the extra caps lookup may happen
twice: first in the invocation decode, and then for cap transfer in the
performance phase of the IPC operation. Because the two phases are
entirely distinct, there is no interference in the use of a common
global variable.

Even though we are primarily concerned with RISC-V, we remove
`extra_caps_t` arguments across all architectures.

Signed-off-by: Matthew Brecknell <Matthew.Brecknell@data61.csiro.au>
2021-03-19 11:29:51 +11:00
Stefan O'Rear
b94d70adfc Outline object physical functions
Most of the uses of these are in functions where the cap type is
statically known and the correct branch could be used directly, but the
compiler does not know this so having these as inlines causes a large
number of accesses to bitfields of unrelated cap types in functions that
manipulate caps.

Moving this out of line makes the results of changing cap bitfields less
noisy.

Signed-off-by: Stefan O'Rear <sorear@fastmail.com>
2020-12-07 10:48:31 +11:00
Miki Tanaka
4ee1f90a7d mcs: add tcb argument to reply_unlink
reply_unlink takes a reply and remove the link between that reply
and its tcb. This link always exists at the call site and the tcb
information is always avaialble, or can be made available.

This commit adds this tcb as an extra argument to aid varification.

Signed-off-by: Miki Tanaka <miki.tanaka@data61.csiro.au>
2020-10-02 12:38:39 +10:00
Sylvain Gauthier
0c32e252d4 fix TCB_PTR_DEBUG_PTR debug macro
The base pointer is wrong, and it creates some nasty corruption down the
line (only affects debug builds).

Signed-off-by: Sylvain Gauthier <sylvain.gauthier@data61.csiro.au>
2020-08-31 16:23:32 +10:00
Mitchell Buckley
cc4b86d098 Check for reschedule on sched context return
The current state of MCS seL4 verification makes use of an invariant
that whenever the scheduler action is set to "resume current thread"
the current thread and the current sc are bound together. Since
maybeReturnSchedContext may unbind a thread from a scheduling context,
it should perform a check on whether it is unbinding from the current
thread, and in that case call rescheduleRequired which will (among
other things) change the scheduler action.

Signed-off-by: Mitchell Buckley <mitchell.buckley@data61.csiro.au>
2020-08-12 10:10:31 +10:00
Kent McLeod
09d42ac0ed mcs: Return bound notification SC before ep recv
If a thread is running on the SchedContext of it's bound notification,
when it next does a blocking recv/wait operation on an ep the SC is
removed. This allows the thread to return to being a passive thread to
receive the next notification or ep message.

Signed-off-by: Kent McLeod <Kent.Mcleod@data61.csiro.au>
2020-07-24 16:48:48 +10:00
Kent McLeod
15e615ada5 tcb_t: Add ascii diagram of tcb object layout
Now that debug_tcb_t is also located in a tcb object, add a diagram for
clarity.

Signed-off-by: Kent McLeod <Kent.Mcleod@data61.csiro.au>
2020-07-22 00:32:27 +10:00
Kent McLeod
9d9bb994e5 debug: create debug_tcb_t struct
Special debug variables that were previously stored at the end of the
tcb_t struct often cause the struct to get too large for the power-of-2
sized untyped object definition. This change moves these variables into
a new structure named debug_tcb_t that is located between the TCB CNode
and the tcb_t struct within a tcb kernel object. Because tcb_t needs to
be stored on a power-of-2 aligned boundary and the TCB CNode only
contains < 5 slots, there is easily > 512 bytes of unused data in every
tcb object. The kernel verification needs to be sure that objects don't
overlap in memory and so this space can't be easily used in a release
build at the moment, but for debug configurations using it shouldn't be
an issue.

Signed-off-by: Kent McLeod <Kent.Mcleod@data61.csiro.au>
2020-07-22 00:31:18 +10:00
Curtis Millar
c428f320b7 reflect function split in thread_control_flag
The thread_control_flag enum which defines which arguments should be
used to reconfigure the TCB should also be split into two sets of flags
as they are now applied to two different functions.

Signed-off-by: Curtis Millar <curtis.millar@data61.csiro.au>
2020-04-27 11:44:00 +10:00
Anna Lyons
60f9eaa654 Split ThreadControl into two functions
This ensures that verification are not required to prove problematic
combinations of updates to a TCB that aren't even permitted by the API.

Signed-off-by: Curtis Millar <curtis.millar@data61.csiro.au>
2020-04-27 11:44:00 +10:00
Qian Ge
512a0200de replacing all ifndef with pargma once
All the kernel header files now use pargma once rather than the ifndef,
as the pre-processed C files do not change while header files
are protected with pargma once. This will also solve any naming issues
caused by ifndef.
2020-03-23 11:04:46 +11:00
Gerwin Klein
79da079239 Convert license tags to SPDX identifiers
This commit also converts our own copyright headers to directly use
SPDX, but leaves all other copyright header intact, only adding the
SPDX ident. As far as possible this commit also merges multiple
Data61 copyright statements/headers into one for consistency.
2020-03-09 13:21:49 +08:00
Kent McLeod
2d362cb7c8 arm,SMP: Refactor irq_t structure for smp
Explicitly create a struct definition for irq_t on SMP Arm
configurations. This makes it a lot harder to mistakenly use the wrong
irq encoding when moving an irq between a cnode index and hardware irq
number / core. A couple areas where this was being handled incorrectly
was fixed as part of the refactor. When performing an ipi for masking
PPI interrupts, the idx encoding is used as it fits into a single word.
2020-02-05 13:56:48 +11: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
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
4f00022f7d mcs: Use cancelIPC instead of reply_clear
- reply_clear only does half the job
- remove reply_clear no longer used
2019-08-22 11:22:39 +10:00
Anna Lyons
f103ac223d mcs: Refactor replies to solve revoke problems
Before this change, we set the replyObject in the thread state on recv
with no back pointer such that stray pointers would be left in the
thread state when a reply object was completed.

The new semantics are clearer and fix this problem by doing the
following:

- tcb->tcbReply is removed and the thread state field is always used,
  this was unneccessary duplication previously
- the thread state value is set to the reply object only when the thread
  is in BlockedOnReply or BlockedOnRecv
- the reply contains a back pointer, replyTCB, which points to that
  thread
- if a thread has its reply removed, it must be set to
  ThreadState_Inactive.
- deletion is easy in the blockedOnRecv case, we just unlink the reply
  and the tcb.
- deletion is complicated for blockedOnReply. If we are deleing a tcb,
  we remove the actual reply object and the call chain is broken. If we
  are deleting a reply, we maintain the call chain by moving the tcb to
  the next reply.
- we refactor the reply object interface to solve the above.
    * reply_clear: removes the reply from any connections (tcb, sc)
    * reply_unlink: just unlinks the tcb and reply, and sets the thread
      state to inactive
    * reply_remove: removes the reply from the call chain
    * reply_remove_tcb: removes the exact reply that a tcb is bound to,
      as we are removing that tcb. Breaks the call chain.
2019-08-22 11:22:39 +10:00
Anna Lyons
2329cd81dc mcs: add seL4_SchedContext_YieldTo
Implement seL4_SchedContext_YieldTo, which allows users to manipulate
the scheduling queues up to their MCP and can be used for user level
scheduling.
2019-08-22 11:22:38 +10:00
Anna Lyons
a38e62f2f9 mcs: timeout exceptions
- Add seL4_TCB_SetTimeoutEndpoint
- implement timeout exceptions
2019-08-22 11:22:38 +10:00
Anna Lyons
c405ef53d2 mcs: install fault endpoint into tcb cnode
- seL4_TCB_Configure no longer takes a fault endpoint.
- seL4_TCB_SetSpace takes a cap in the callers cspace for the
  fault endpoint, not the target tcbs.
- seL4_TCB_SetSchedParams now also takes a fault endpoint as above.

This change installs the fault endpoint cap into the tcb cnode
first validating it.

This means either of the functions that set it will now return an error
if the cap is not either a null cap or an endpoint with send and
grant rights.

Significantly, the cap passed to the function should be in the callers
cspace, not the target tcbs.
2019-08-22 11:22:38 +10:00
Anna Lyons
106b893ee0 mcs: configurable scheduling context size
This allows users to define custom amounts of refills without
increasing the scheduling context size system wide.

also add libsel4 functions for refill size
2019-08-22 11:22:38 +10:00
Anna Lyons
a22cb3d102 mcs: associate scheduling context + ntfn
This commit allows scheduling contexts to be bound
to notification objects. When a passive server
receives a notification it will receive the scheduling
context from the notification. When the server
blocks the scheduling context is returned.
2019-08-22 11:22:37 +10:00
Anna Lyons
554f812da3 mcs: scheduling context donation over ipc
After this commit, threads blocked on an endpoint can recieve a
scheduling context from the thread that wakes the blocked thread.
2019-08-22 11:22:37 +10:00
Anna Lyons
5fe1890a83 mcs: order EP and NTFN queues
Previously IPC signal queues were FIFO, as of this change they are
ordered by priority (FIFO for same prio threads).
2019-08-22 11:22:35 +10:00
Anna Lyons
34c1f920b1 mcs: add periodic scheduling
This commit adds periodic scheduling with sporadic servers.
2019-08-22 11:22:35 +10:00
Anna Lyons
952134d1b8 mcs: Add a scheduling context object
This is the first part of the seL4 MCS. This commit:

    * adds a scheduling context object. Threads without scheduling
      context objects cannot be scheduled.
    * replaces tcbTimeSlice with the scheduling context object
    * adds seL4_SchedControl caps for each core
    * adds seL4_SchedControl_Configure which allows users to configure
      amount of ticks a scheduling context has, and set a core for the
      scheduling context.
    * adds seL4_SchedContext_Bind, Unbind and UnbindObject, which allows
      a tcb to be bound to a scheduling context.
2019-08-22 11:22:34 +10:00
Sylvain Gauthier
121943c3c7 [SMP] Added PPI support for gic_v2
Correctly defined the macros to translate between virtual and hardware
IRQs such that PPIs can be properly handled on gic_v2. It is now
possible to create a per-core handler for PPIs on platforms using this
GIC.
2019-07-19 16:37:03 +10:00
Sylvain Gauthier
a6157d5d8e [SMP] Abstracted IRQ indexing to handle PPIs
irq_t is now a "virtual" interrupt type that encapsulates the
information of the core in case of a private interrupt. There is a
couple of macros that need to be defined on the interrupt controller
level to translate between virtual and hardware IRQs.
2019-07-19 16:37:03 +10:00
Curtis Millar
b6417f2150 Remove platform IPC buffer register.
This removes the assumption that each platform sotres the IPC buffer
address in a platform-specific register. The IPC buffer address is
instead stored in a thread-local variable in libsel4 which must be
initialised by the runtime.
2019-07-01 10:46:46 +10:00
Anna Lyons
f3d0eb20f6 Update seL4_FaultType to 4
With the increased faults on various configurations (hyp, mcs) we need
more bits to identify faults.
2019-06-18 15:14:03 +10:00
Curtis Millar
01c7e62cce Update size comments to reflect the size better
This changes the comments regarding the size of the TCB to be more
generally accurate to help manually determine the size of the TCB for
different configurations.
2019-04-08 10:48:32 +10:00
Jesse Millwood
76bf1d2bcd Changed padding and capIRQ in irq_hander_cap structure
This is for the new GIC code

Change-Id: I64fd20767e9b46b3300d87397c72e4e55d386746
2019-03-27 11:16:12 +11:00
Sylvain Gauthier
142bf9b127 More standard constant name, moved ASID constants to arch generic files 2019-03-22 17:34:39 +11:00
Kent McLeod
f6e5e218dc Remove symlinked libsel4 files from include dir
These files can be included normally using libsel4 include paths. This
removes situations where the same file is available under different
include paths due to symlinking into different directory structures.
2019-03-21 12:44:57 +11:00
Anna Lyons
d0930f67de style: consistently attach return type
Add attach-return-type to astyle
2019-03-19 14:05:36 +11:00
Anna Lyons
761006e03b style: consistently align pointer with name
Run astyle with align-pointer=name
2019-03-19 14:04:54 +11:00
Kent McLeod
c1b1d07579 bitfields: Split definition cannonical addresses
These shared objects have different definitions based on the cannonical
address of the virtual memory system.
2019-02-08 17:17:02 +11:00
Thibaut Perami
3df00ea4d7 SELFOUR-6: Add GrantReply to the rights system.
GrantReply is a new access right added to endpoint capabilities, which
allows seL4_Call to be used on those capabilities (specifically, it
allows reply caps *only* to be granted across endpoints).

Prior to the addition of GrantReply, endpoint capabilities required the
Grant access right, which allowed any arbitrary capabilitiy to be
transferred over an endpoint. Using GrantReply, systems can now be
constructed where threads using seL4_Call over an endpoint do not need to be in the same
security subsystem.
2018-12-12 14:04:28 +11:00
Edward Pierzchalski
8bf7c55de4 Dedup user_data and user_data_device definitions.
These are reasonably expected to exist on every platform by the
UMM type generator. They also had identical definitions, so we
consolidate them.
2018-12-06 15:04:41 +11:00
Adrian Danis
7641e43872 Refactor logic for cap revocability in cteInsert into new function with arch case
Revocability of a cap, with respect to its parent, is a general property on caps and
makes sense to be abstracted. This allows for the addition of an arch case without
further complicating the cteInsert function itself.
2018-04-24 14:04:46 +10:00
Bruce Mitchener
b942a50441 Fix trivial comment typos. 2018-03-27 10:51:26 +11:00
Adrian Danis
bce62b4e43 Check that TCB object is not larger than necessary 2018-03-23 12:28:54 +11:00
Adrian Danis
a2a2d9b937 Define tcb_t as half the TCB object size
A TCB object has two objects inside it, the cnode object and the 'actual tcb object'.
For simplicity of verification we would like the tcb_t portion of the object to also
be size aligned instead of just just being offset by the size of the cnode.
2018-03-23 12:28:54 +11:00
Adrian Danis
f5abc87894 Rename TCB_SIZE_BITS to TCB_CNODE_SIZE_BITS
This definition is used as the size of the cnode portion of the TCB object (and not the tcb_t)
portion and so this provides a much less confusing name.
2018-03-23 12:28:54 +11:00
Anna Lyons
33398f2191 SELFOUR-331: add seL4_TCB_SetSchedParams
This allows the prio and mcp to be set in one system call.
2018-02-26 11:24:42 +11:00