Commit graph

1101 commits

Author SHA1 Message Date
Anna Lyons
5fe6d0bcef riscv/spike: fix seL4_UserTop for riscv
Use correct values and document them.
2018-12-20 12:27:23 +11:00
Kofi Doku Atuah
cd26d7d00c Aarch64 HYP Fastpath: Call vcpu_switch when switching from Guest to native threads
Previously the kernel did not call vcpu_switch on the fastpath since the fastpath avoids
calling setVMRoot, so when sending an IPC message from a guest thread to a native thread,
if the IPC was small enough to go on the fastpath the kernel would fail to disable the
HYP traps and would treat the native thread like a guest thread.
2018-12-18 15:38:43 +11:00
Kent McLeod
0348468c87 aarch64: Add pgde enum for tracking hyp hw_asids
aarch64 hyp mode only has support for 8 bit hardware ASIDs. We use the
same strategy used in aarch32 for hardware asids where we maintain a
pool of hwasids that seL4 ASIDs are allocated. The allocation is stored
in the last entry of top level paging structure. This commit
encapsulates this into the bitfield specification in the same way as
aarch32.
2018-12-13 18:09:04 +11:00
Anna Lyons
4bc6b76f5f Remove empty plat_mode/machine header files 2018-12-12 16:24:31 +11:00
Anna Lyons
2a0d682ff2 Remove MAX_IRQ
MAX_IRQ was used on several platforms. Remote it. This is a layer of indirection which adds no value.
2018-12-12 16:24:31 +11:00
Anna Lyons
403f5dace7 Remove N_INTERRUPTS constant
The N_INTERRUPTS constant is never used. maxIRQ tracks this value.
2018-12-12 16:24:31 +11:00
Anna Lyons
e5bb674594 Calculate IRQ_CNODE_BITS from maxIRQ
IRQ_CNODE_BITS is determined by the maxIRQ on the platform. Calculate
this value from maxIRQ instead of hardcoding for each platform.
2018-12-12 16:24:31 +11:00
Anna Lyons
76faadc923 Add seL4_UserTop and move kernelBase to the arch level
- seL4_UserTop is a new constant which represents the top of virtual
memory available to user level
- this commit also rationalises several constants (USER_TOP, kernelBase)
and moves them to the arch level, such that ports only need to define
seL4_UserTop.
2018-12-12 16:24:31 +11:00
Thibaut Pérami
2f43788b82 libsel4: add seL4_CapRightsBits 2018-12-12 14:20:37 +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
Kofi Doku Atuah
fbec286d97 AArch64: Comment HYP and EL1 vaddrspace layouts
Also document the specific addresses for TX1 and TX2.
2018-12-11 18:27:32 +11:00
Kofi Doku Atuah
e46445c557 TX2: AArch64: Hyp: Use the correct conditional timer IRQ 2018-12-11 18:27:32 +11:00
Kofi Doku Atuah
479cd82dbe TX2: AArch64 Hyp: Add GICH controller paddr 2018-12-11 18:27:32 +11:00
Kofi Doku Atuah
0b933ea7a3 TX2: AArch64 HYP: Set EL2 mode addresses 2018-12-11 18:27:32 +11:00
Yanyan Shen
60b15e1047 armv8/hyp: Remove duplicated functions 2018-12-11 18:27:32 +11:00
Yanyan Shen
9bba386aa3 armv8: Add readTIPDRURO for aarch64 2018-12-11 18:27:32 +11:00
Edward Pierzchalski
c06f9dbafe riscv: make register size equal to word size
RISCV32 registers aren't 64 bits wide, after all.
2018-12-06 15:32:26 +11:00
Anna Lyons
b9522d87b6 riscv: fix incorrect register index
s4 should be 19, not 10
2018-12-06 15:04:41 +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
Edward Pierzchalski
4ea62e5158 riscv: add remaining registers to user context.
The registers a7, s2-11, and t3-6 were missing from seL4_UserContext.
We also add these to frameRegisters and gpRegisters, which are used
to implement the TCB invocations for reading and writing these
registers.

Zero-length arrays aren't valid expressions or types in ISO C, so
to keep the c parser happy we need to either remove gpRegisters or
provide some contents for it.

In the past, frameRegisters and gpRegisters distinguished between
those registers preserved across a syscall and those that weren't.
TCB_CopyRegisters allows the caller to choose which set to copy.

Since we preserve all non-return registers, this distinction isn't
relevant anymore and there's no easy way to justify the members of
frameRegisters and gpRegisters.

We arbitrarily choose to put the 'last' register t6 in gpRegisters,
for consistency with the register list in registerset.h and with the
order that registers are restored.
2018-12-06 15:04:41 +11:00
Edward Pierzchalski
2d075c2760 riscv: remove spurious MODIFIES specs.
Until these functions have non-empty definitions, the C parser will spit
out warnings about ignoring the MODIFIES spec.
2018-12-06 15:04:41 +11:00
Edward Pierzchalski
b59038b10f riscv: replace braced-groups with functions.
Braced groups in expressions like

    int x = 0;
    x = ({x++; x;});

aren't supported by the C parser (or ISO C), so we replace the SBI_CALL
macro with an equivalent function.
2018-12-06 15:04:41 +11:00
Edward Pierzchalski
9d0db528b3 riscv: remove invalid 'void CONST'.
Normally a warning, but promoted by [-Werror=attributes].
2018-12-06 15:04:41 +11:00
Peter Chubb
896e864431 TX2: Add initial TX2 support
See CHANGES and https://docs.sel4.systems/Hardware/ for more information
2018-11-07 11:52:51 +11:00
Curtis Millar
b203026382 Store TLS_BASE in globals frame on fastpath switch.
The TLS_BASE stored in the globals frame needs to refer to the TLS_BASE
of the current thread and so must be maintained across all context
switches. (This was only being maintained on the slow path).
2018-10-24 09:17:43 +11:00
Kofi Doku Atuah
b3aebb3a4a ARM: HYP: Document functions that update the s2 translation base 2018-10-12 18:44:36 +02:00
Kofi Doku Atuah
47fd1a6abe ARM: HYP: Fix bug in VMID update
The VTTBR register is found at coprocessor address p15, 6
and not p15, 4.
2018-10-12 18:38:42 +02:00
Axel Heider
8cf34ab395 add missing include for config.h
These files contain conditional parts which depends on CONFIG_PLAT_xxx being set, thus they must include config.h.
2018-09-24 11:03:14 +02:00
Anna Lyons
db3e18b7e4 SELFOUR-1491: error if set trigger not supported
So far this is only implemented for the GIC, which most of our platforms
use. Error if this invocation is made on another platform, and guard
calls to the trigger function if it is not supported.
2018-09-19 12:17:52 +10:00
Mitchell Buckley
f4f6b156e3 SELFOUR-1491: verification updates
- renamed an architecture label so that it begins with ARM.
- changed setIRQTrigger so that it takes a boolean value instead of an int.
- Arch_decodeIRQControlInvocation converts the second argument (trigger)
to a boolean immediately.
2018-09-19 12:06:35 +10:00
Anna Lyons
eb0553fa75 SELFOUR-1491: add seL4_IRQCOntrol_GetTrigger
Add a new invocation which allows an irq handler capability to be
obtained with a specific trigger method (edge or level). Obtaining
this capability modifies the GIC state.
2018-09-19 12:06:35 +10:00
Anna Lyons
ffbb278305 trivial: move MS_IN_S to utils.h 2018-09-18 10:05:26 +10:00
Chris Guikema
9a3449a42f riscv: move virtual memory fence after address space switch
While the RISC-V ISA says to that a VMFENCE before a write to the
satp may be necessary, vm faults occur with this ordering when
running on the Rocket Chip. Placing the VMFENCE after the satp write
resolves these faults.

This is also the ordering used in the RISC-V port of Linux when
switching MMU contexts.

Change-Id: I1ec794651d080a5e7a987fa8b2062dc01daeb683
2018-09-18 09:55:48 +10:00
Axel Heider
924d1c2639 zynqmp: add Ultra96 platform
Add Ultra96 platform, which is based on the zynqmp SoC
2018-09-14 16:16:23 +02:00
Thomas Sewell
e11d930bc4 Move some lockTLB magic into C.
This patch moves the 'outer' chunk of lockTLBEntry into C rather
than handwritten assembly. The outer chunk accesses a global
counter and does arithmetic. The inner chunk (lockTLBEntryCritical)
writes to the registers, must be specially aligned, and is generally
special.

The change reduces unnecessary handwritten assembly, and also avoids
a special case that was problematic for binary verification.
2018-08-22 15:06:51 +10:00
Adam Felizzi
72e675f1da Kbuild: Removed Kbuild
Removed all Kbuild/Kconfig/Makefiles from the kernel as we migrate
to a CMake only build system. Kbuild is no longer supported.
2018-08-10 10:38:53 +10:00
Adrian Danis
3eefc3e7c2 riscv: Make room for devices in rv32
Leaves the last entry in the top level page table free so that it can be used for mapping
devices in the future. This moves the kernel image down to the second last entry in the
top level page table. Leaving the last entry in the top level page table also matches the
rv64 design.
2018-08-09 12:36:28 +10:00
Adrian Danis
2112cd6e7d riscv: Explicit single level 2 page table
Only a single level 2 page table is now used for mapping the kernel image so this simplifies
the state data to only allocate a single PT and removes the now out of date description.
2018-08-09 10:43:42 +10:00
Adrian Danis
b14cc44a7a riscv: Statically determine kernel image window mapping
Uses a static check to determine whether or not we can use a single 1 GiB mapping for the
kernel image area, or if we need an additional PT.
2018-08-09 10:43:42 +10:00
Chris Guikema
9f8d07956a riscv: Order read/writes before writing sptbr
This instruction is required when more than one thread exists with
different ASIDs. The system will lock up after the first context
switch when running on hardware.

Issue first noticed and fixed by Hesham Almatary
<Hesham.Almatary@cl.cam.ac.uk>

Change-Id: I6eb64df6b584ff7de79c8af30b28bbc7bb234643
2018-08-09 10:43:42 +10:00
Jesse Millwood
b9246b16dc riscv: Made two level page table for kernel mapping
This uses a one dimensional page table for the first level
and a two dimensional array for the second level such that
in a worst case scenario, the entire kernel region could
be mapped using second level tables.

Co-authored-by: Chris Guikema <chris.guikema@dornerworks.com>

Change-Id: Iad62303a0d7c2321d6038ca718888100614f91db
2018-08-09 10:43:42 +10:00
Jesse Millwood
3db47a881e riscv: PADDR_LOAD changed when running on the rocket-chip
This change is required because the zedboard rocket-chip only has
256MiB of memory. Therefore the load address needs to be lowered
to fit in the available range.

This change will also require the kernel to be mapped with 2MiB
granularity so everything is properly page aligned.

Change-Id: I75ddec0be1bb2fd05d0a947ea19bce46e2cd9f96
2018-08-09 10:43:42 +10:00
Thomas Sewell
122aaeb5d5 Declare priv_timer to be a const pointer.
The structure isn't constant, but the pointer to it is, and this
saves a few cycles and fixes a minor issue for translation validation.
2018-08-06 16:06:30 +10:00
Adrian Danis
723aa0ead3 arm: Use TCB version of TPIDRUR[OW] state
These registers are part of the 'regular' TCB state and are saved and restored as part
of normal thread switching. As such it is conflicting to have a duplicate idea of the value
of these registers, especially as it is not kept in sync with the version in the TCB,
which is what is actually being loaded into the hardware.
2018-07-13 10:12:18 +10:00
Adrian Danis
128fe5a185 arm: Always save TPIDRURW for VCPU threads
Threads that have a VCPU, and hence might be running in supervisor mode, probably don't
care about the IPC buffer and would rather their registers contain the values they expect.
2018-07-13 10:11:51 +10:00
Adrian Danis
8023a39bb6 arm: Preserve TPIDRURO when switching VCPUs
This register can be modified by the supervisor mode thread attached to a VCPU and we
should be saving and restoring it. The necessity of doing this has been revealed due to
the kernel now allowing TPIDRURO to be used for TLS_BASE, causing the register to be
overriden if we switch away from a VCPU and then back to it.
2018-07-05 11:57:45 +10:00
Adrian Danis
f40c07971e riscv: Define TLS_BASE
Defines TLS_BASE to the be the TP register. Currently the TP register is already used to
place the location of the IPC buffer into it and so a user thread should not set a value
for TLS_BASE unless they have their own way to find their IPC buffer.
2018-07-04 16:28:08 +10:00
Adrian Danis
7baf572808 arm: Remove duplicate functions
These functions got duplicated due to a merge.
2018-07-03 15:44:36 +10:00
Adrian Danis
7d7f338b2b arm: Provide TLS_BASE virtual register
This commit provides a universal TLS_BASE virtual register on ARM, similar to as exists
on x86. Depending on the precise configuration this virtual register maps to a different
register
 * aarch64: TPIDRURW is used for the TLS_BASE and is already declared and being saved
   and restored on context switches, so this just adds TLS_BASE as an alias of it
 * armv6: Has no hardware register for use for a TLS_BASE, and so the virtual register
   gets stored into the globals frame
 * armv7+: TPIDURO is used for TLS_BASE and so the restore paths are modified to load
   TLS_BASE into it
2018-07-03 13:34:59 +10:00
Adrian Danis
89297f96e0 arm: Add missing helpers for read/write of TPIDRURO 2018-07-03 13:34:51 +10:00