Commit graph

3342 commits

Author SHA1 Message Date
Kent McLeod
232b0e86b5 arm_hyp: Move PGD definitions out of libsel4
The PGD constants refer to the top level mapping object used by the
kernel for its own private mappings. Userlevel cannot create any PGD
objects and so these constants don't belong in libsel4.
2020-02-20 11:41:00 +11:00
Kent McLeod
2ceeb1df6f VGICMaintenance: Update spurious check
Ignore any VGIC maintenance interrupts that arrive if a VCPU isn't
currently running.
2020-02-20 11:40:59 +11:00
Alison Felizzi
0e05f416ae arm: Configure traps on vcpu WFE/WFI calls
Configure the ability to trap on vcpu WFE/WFI calls. If enabled,
user-level would need to schedule a future interrupt when a given
vcpu invokes a WFE/WFI instruction. This otherwise leaving the
vcpu in a disabled state. An application can choose to
disable the trap if it doesn't want to handle the instruction and
schedule a future interrupt.
2020-02-20 11:40:59 +11:00
Kent McLeod
531d61215e arm: Restrict cache flush operations in hyp mode
Cache flush operations are applied through the kernel window mapping in
hyp mode. This requires an extra check that the frame being provided is
accessible through the kernel window.
2020-02-20 11:40:59 +11:00
Alison Felizzi
71d636f8b3 arm_hyp: Save and restore vtimer state on switches
Added support for reading and writing additional virtual timer
registers for vcpu hw read and write accesses. These include the
compare value register (CNTV_CVAL) and offset register (CNTV_OFF),
each represented as two 32 bit (high and low) registers on aarch32 and
as single 64 bit registers on aarch64.

Added support for explicitly saving and restoring the virtual
timer registers when the vcpu is enabled and disabled. This
ensures when the vcpu is switched in and out, the virtual timer
registers are restored to a state that is consistent to when
it was last run.

By default the CNTVOFF register will be updated by the kernel to
accumulate the time the VCPU is not running. From the guest this will
result in the VCNT register not increasing when the VCPU is suspended.
This behavior can be turned off by disabling the
KernelArmVtimerUpdateVOffset config option.
2020-02-20 11:40:59 +11:00
Alison Felizzi
f795e7c0ec arm: New virtual PPI event fault type
This commit introduces a new fault type, seL4_Fault_VPPIEvent.

This change means the kernel can reserve PPI interrupts and virtualise
them via delivering the irq to the active vcpu through a
specific fault. This enables multiplexing PPI IRQs across multiple VCPUS
which requires correctly masking and unmasking the IRQ depending on
which VCPU is running.

A new VCPU invocation, seL4_ARM_VCPU_AckVPPI is also added for
acknowledging the handling of the IRQ. This takes an IRQ as a parameter
but will only accept IRQ numbers that are sent as VPPIEvent faults.

Co-authored-by: Rafal Kolanski <rafal.kolanski@data61.csiro.au>
Co-authored-by: Kent McLeod <Kent.Mcleod@data61.csiro.au>
2020-02-20 11:40:59 +11:00
Kent McLeod
4cb3414def aarch64: Add missing faults to seL4_getArchFault
seL4_getArchFault is a libsel4 helper that constructs fault messages out
of the IPC buffer message registers. Aarch64 was missing a few types.
2020-02-20 11:40:59 +11:00
Alison Felizzi
7409fa1de5 arm64: Added define for CNTPCT + CNTVCTL register
Added constant defintion for the "cntpct_el0" and " cntv_ctl_el0"
register. This being consistent with the 32bit mode definition
of the same registers.
2020-02-20 11:40:58 +11:00
Kent McLeod
6e63a4832c arm_hyp: Update ArmV8 vcpu register operations
Update the register save and restore functions to use the provided
wrapper functions that are now in scope.
2020-02-20 11:40:58 +11:00
Kent McLeod
16bedb98e4 arm_hyp: Remove some vcpu_* wrapper functions
These functions have entirely arch specific implementations so remove
function wrapping indirection to ease maintainability.
2020-02-20 11:40:58 +11:00
Kent McLeod
94c7800e7e arm_hyp: Refactor code into arch headers
Move vcpu functions that are specific to a particular Arm architecture
version into the relevant header files. Also move some generic functions
into the generic vcpu header file for use by arch specific headers.
2020-02-20 11:40:58 +11:00
Matthew
56a19e05dc Kernel-Vtx: Use clang compatible inline assembly
Specifying a function name prefixed with 'm' is not compatible with
clang.

For 32 bit, call vmlaunch_failed explicitly from within the assembly.
Requires adding the USED attribute to vmlaunch_failed as it is only
referenced in a string literal.

For 64 bit, move the address of vmlaunch_failed into rax as an integer
rather than loading it as the address of a function (lea).
2020-02-18 13:25:17 +11:00
Luca(Wei) Chen
4a09c94b77 ARM: move handle unknown syscall into slowpath
This reduces the instruction size for fastpath.
2020-02-14 11:01:46 +11:00
Luca(Wei) Chen
2dd4a59a94 fastpath: force inline fastpath_restore
This inline function doesn't get inlined with -O3.
It affects the cold cache performance, so use always_inline
attribute to tell compiler always get it inlined.
2020-02-14 11:01:45 +11:00
Luca(Wei) Chen
feb3717e50 fastpath: fix branch predications
All jump instructions to slowpath are unlikely executed
in fastpath, and this prevents polluting i-cache by pushing
it away.
2020-02-14 11:01:45 +11:00
Matthew
62fcb7c9c4 Error if clang is used with riscv
Riscv is not yet supported with clang so error in
the llvm toolchain file and exit early.
2020-02-12 16:08:35 +11:00
Matthew
8a87015a7c Define region in undefined way for clang only
Initializing an empty array is undeined in the C standard
so would impact verification. Only do this for clang
as to not break verification on gcc
2020-02-12 16:08:35 +11:00
Matthew
b043dbde84 Add ccache to the clang builds
Ccache increases compilation speeds dramatically
Add this to the clang toolchain
2020-02-12 16:08:35 +11:00
Matthew
5a2251a56d Explicit casts between enum types in IPI
Depending on the platform, IPI has a slightly different interface.
Explicitly cast from the more speific enum type to the generic
and vice versa when calling in and out of generic code.

Another possibility would be to typedef a specific enum on RISCV
platforms that aliases the one currently used. Then casting would only
have to take place when passing args to function calls.
2020-02-12 16:08:35 +11:00
Matthew
680ce96b59 Keep consistent definitions of sections for boot
Clang complains when this is set to null.
'Causes a section type conflict'. Use the same structure
as the other objects in the same section
2020-02-12 16:08:35 +11:00
Matthew
faaef077d6 Do not use clangs builtin assembler
The builtin assembler in clang is not intended for
hand written assembly. Only that generated by clang.
Disable this and use the default one
2020-02-12 16:08:35 +11:00
Matthew
ce71d1fccc Move to and from 64 bit system registers
Clang requires explicitly identifying a move is to a 64 bit
register (x<reg>), not just half (w<reg>).
2020-02-12 16:08:35 +11:00
Matthew
497d3c66c5 Specify 32 bit to the clang assembler
If using clang, pass the -m32 flag to the assembler
2020-02-12 16:08:35 +11:00
Matthew
07dfe8cf56 Fix comps between negatives and unsigned vars
In circumstances where values are negative and
compared to unsigned variables, clang will
error saying that this is always true. Include
early break conditions that check for this
2020-02-12 16:08:35 +11:00
Matthew
c1d5a60e04 Initialise the hw_asid in ia32
The stored_hw_asid is unused in the fastpath but is passed
into a function. Clang complains about it being uninitialised
when doing this.
2020-02-12 16:08:35 +11:00
Matthew
0e8a2cf05c Remove unnecessary variables in toolchain files
Setting `-target` flag explicitly is unnecessary. Whenever this needs to
be explicitly passed through, the coompiler id should be checked.

Changes to the musl build system makes the explicit `C_COMPILER`
variable useless.
2020-02-12 16:08:35 +11:00
Matthew
5ebe5526fd Add the suffix to the bitfield generation
Clang complains about shifting signed numbers so we need to make sure it
knows it is unsigned
2020-02-12 16:08:35 +11:00
Matthew
1d8b5d4ab1 Specify the C compiler in a variable for user lvl
Having the basic compiler name in a variable lets us pass it around to
any other user level project (e.g musllibc)
2020-02-12 16:08:35 +11:00
Oliver Scott
b0bdaf9f50 mcs-smp: tcb affinity modification bug
Patch for MCS - TCB Affinity Modification Bug #138.
After updating ques on the remote core the
reschedule operation was never performed.
2020-02-12 15:31:34 +11:00
Siwei Zhuang
dadfb1b6f3 trivial: Bugfix, use the correct config macro
Use the correct config macro to enable code injection.
2020-02-12 12:36:57 +11:00
Luca(Wei) Chen
c06df578f2 ARM: Add support to flush L1 caches
Extend the existing seL4_BenchmarkFlushCaches without modifing the usage
of it. Will be used in sel4bench to measure the cold cache performance.
2020-02-11 11:23:04 +11:00
Curtis Millar
2d40b0d5df riscv32 does not support huge pages
For some reason the kernel documented and maintained constants for a
512MiB 'huge page' in riscv32 which is not part of the specification.

The references and constants are removed
2020-02-10 15:01:43 +11: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
Kent McLeod
2cd80a8c7e Document internal machine/interrupt.h interface
Every platform has to implement a standard set of interrupt interfaces
that the kernel uses to interract with a machine's interrupt controller.
Providing a single header file for each of these functions provides a
single location to document their behavior.
2020-02-05 13:56:48 +11:00
Kent McLeod
94dcfce5c7 trivial: Remove duplicate function prototypes 2020-02-05 13:54:33 +11:00
Kent McLeod
4fb42436f7 trivial: Remove unused ipiBroadcast function 2020-02-05 13:54:33 +11:00
Curtis Millar
b2086f54e1 update non-mcs sabre clock
Both the private and global arm timers are clocked from the same source
and neither of the drivers apply a pre-scaler so the frequency should be
the same in both configurations.

The frequency of this clock is based on PLL1 which could potentially lie
anywhere in the range of 650MHz to 1.3GHz. The value determined for MCS
appears to correctly agree with the user-level timer which appears to be
correctly implemented.
2020-01-30 14:04:56 +11:00
Damon Lee
c1fbb27165 imx31: Add missing DTS entry for the EPIT2 timer
The DTS in the 'tools' directory is missing information about the EPIT2
timer. We add the entry into the corresponding overlay DTS file so that
the EPIT2 node will be included into the resulting DTB.
2020-01-29 12:09:32 +11:00
Curtis Millar
cc90574fc4 Fix MCS timer for KZM
The corrected user timer showed that the estimated value for the kernel
timer used in MCS was incorrect. It has been re-calculated on the fixed
user-level timer.
2020-01-29 09:56:02 +11:00
Curtis Millar
0ff7405eab Fix TX1 clock timer
According to the implementation of the user-level timer the primary
clock source (`m_clock`) can only be configured to 12MHz on TX1 and TK1
(see the comment in `libplatsupport` at
util_libs/libplatsupport/src/mach/nvidia/timer.c:213).

This should allow the TX1 to pass all MCS tests.
2020-01-22 15:08:12 +11:00
Victor Phan
0e62bc3a81 Move vcpu_switch into Arch_switchToThread
Currently the vcpu_switch function is called in the setVMRoot function
after possible early returns. In order to make sure the vcpu is
always switched, the call is moved into Arch_switchToThread before the
call to setVMRoot.
2020-01-20 14:10:28 +11:00
Nick Spinale
b45ca5cd71 aarch64: fix FAR_EL1 width in writeFAR
Fixes a bug where writeFAR was only writing to the low 32 bits of the
64-bit FAR_EL1 register.
2020-01-14 17:47:55 +11:00
Nick Spinale
a047e8d865 aarch64: fix MRS/MSR in writeELR_EL1
Fixes a bug where writeELR_EL1 was reading from ELR_EL1 instead of
writing to it.
2020-01-14 17:26:07 +11:00
G. Branden Robinson
49295a7b02 manual: improve discussion of Recv and Wait
...and other tweaks.

* Clarify the synonymy of Receive and Wait on non-MCS systems.

* Note that Receive takes a reply object on MCS systems, and not on
non-MCS systems.  Also note redundancy of Wait on non-MCS systems.

* Use the full English word "Receive" when the discussion is at the
conceptual level.  It still gets abbreviated in C context, where it also
receives the "seL4_" prefix.

* Try a little harder to explain what's the same and what's different
about a non-MCS "reply capability" and an MCS capability to a reply
object.

* Explain what MCS stands for at the beginning of the chapter.  In the
manual's current organisation, this precedes by a few paragraphs the
term's first occurrence.

* Recast language about things being "on the MCS kernel" in favour of
describing "MCS" and "non-MCS" _configurations_ of the kernel.  (We do
not refer to the "master" kernel in the manual--thankfully.)

* Correct doubled word "to to".

* Italicise "reply capability" to better distinguish it from the
(already italicised) "reply object".

* Add a TODO comment about hyphenation grief.
2020-01-10 16:52:05 +11:00
G. Branden Robinson
e36657f1c6 manual: rework introduction of system calls
* Recast language of introduction to system calls.
* Rearrange system calls to present them in a more pedagogically useful
  order.
* Add TODO comment for future manual organisation efforts.
2020-01-10 16:52:00 +11:00
Jimmy Brush
b4e529ab2c trivial: arm: Improve object method docs 2020-01-06 16:14:02 +11:00
Jimmy Brush
7b44ef9277 aarch64: Fix seL4_ARM_PageDirectory interface doc
It is passed a vspace cap not an upper page directory cap
2020-01-06 16:14:01 +11:00
Jesse Millwood
01cea266d9 RISCV: Added stdout-path to hifive dts
This sets the first UART as the stdout-path dts setting in the
"chosen" node in the HiFive device tree.

Change-Id: Icb6b9abf999bdd8a278df5a2ba73ad492af06a24
2019-12-23 12:18:34 -05:00
Kent McLeod
0de7fc11bf Revert "Cache FPU enable state on all platforms"
This reverts commit 186180cf30.
2019-12-19 17:18:35 +11:00
Kent McLeod
113a53b2c5 Revert "trivial: use global machine/fpu.h (arm)"
This reverts commit 89e53be40b.
2019-12-19 17:18:35 +11:00