Commit graph

908 commits

Author SHA1 Message Date
Yanyan Shen
db3c4ff44f riscv: Guard SMP inlines with the macro
Guard the added SMP inline functions with the ENABLE_SMP_SUPPORT.
2019-10-10 17:22:06 +11:00
Yanyan Shen
0a6df5fc87 riscv: Remove IPI functions when SMP is off
Remove ipi_get_irq() and ipi_clear_irq() when SMP is not enabled.
2019-10-10 17:22:06 +11:00
Yanyan Shen
e7957006e5 trivial: Correct year 2019-10-10 17:22:06 +11:00
Yanyan Shen
b32c0b8dcb riscv: Add fence_r_rw() and fence_w_r()
Add more memory fences.
2019-10-10 17:22:06 +11:00
Yanyan Shen
a45f389704 trivial: Fix style 2019-10-10 17:22:06 +11:00
Yanyan Shen
4741fb6492 riscv: SMPify booting code
Add SMP support for booting code.
2019-10-10 17:22:06 +11:00
Yanyan Shen
b848e58d5a riscv: Add IPI calls and handlers
Add IPI call functions and handler functions.
2019-10-10 17:22:06 +11:00
Yanyan Shen
d1a0de41ff riscv: Split IRQ init to platform and local
Split IRQ init code to platform-code and per-hart code.
2019-10-10 17:22:06 +11:00
Yanyan Shen
e1c529caa5 riscv: Add SMP code for ifence/sfence/hwASIDFlush
If SMP is enabled, sfence/ifence/hwASIDFlush also IPI other
cores.
2019-10-10 17:22:06 +11:00
Yanyan Shen
07a5a3f5d9 riscv: Add memory fences and local ifence/sfence
Add memory fences.
Add local ifence and sfence which work on the calling
core only.
2019-10-10 17:22:06 +11:00
Yanyan Shen
5a0d349845 riscv: Include header for SMP macros
Include header or SMP macros.
2019-10-10 17:22:06 +11:00
Yanyan Shen
1c53fea9d3 riscv: Add L1 cache line size and memory barrier
Add the L1 cache line size based on HiFive Unleashed.
2019-10-10 17:22:06 +11:00
Yanyan Shen
934080b7f5 riscv: Add IPI types and arch_pause() function
Add reschedule and call IPI types.
Add arch_pause() function.
2019-10-10 17:22:06 +11:00
Yanyan Shen
e92b4e68b5 riscv: Add SMP functions
Add SMP functions for RISCV.
2019-10-10 17:22:06 +11:00
Yanyan Shen
a6c9dcf8a7 riscv: Use sscratch for per-core kernel stack
When SMP is enabled, the sscratch register is used to
contain the per-core kernel stack instead of the current
running thread. We get the current running thread from the
top of the kernel stack.
2019-10-10 17:22:06 +11:00
amrzar
a4d6bf850c SELFOUR-161: Merge Page_Remap with Page_Map
- Remove Remap function from seL4 API for arm, x86, riscv and the
respective invocation implementation.
- Update Map as replacement for Remap
- Update manual

This allows a change of rights if the frame being mapped is already
mapped in at the given vaddr. To map a page to a different address,
unmap it first.

Co-authored-by: Hesham Almatary <hesham.almatary@data61.csiro.au>
Co-authored-by: Anna Lyons <Anna.Lyons@data61.csiro.au>
Co-authored-by: Victor Phan <Victor.Phan@data61.csiro.au>
Co-authored-by: Kent McLeod <Kent.Mcleod@data61.csiro.au>
2019-10-10 15:54:23 +11:00
Simon Shields
3e83f89990 x86: avoid -Waddress-of-packed-member
It's safe to take the address of this member, since it's the
first thing in a cacheline-aligned struct.
2019-09-26 15:34:26 +10:00
Kent McLeod
8234026c1f aarch64: Move tpidrro_el0 from vcpu to tcb context
This register is visible to software executing at EL0 but not writeable.
Storing it in the VCPU context required custom save/restore handling as
it had to be explicitly handled when switching from a VCPU thread to a
non-VCPU thread so that it didn't become a channel. It is possible to
now update this register via seL4_TCB_WriteRegisters for software
executing at EL0.

This also fixes a potential bug where if a vcpu-thread is switched for a
non-vcpu-thread and then switched to a different vcpu-thread the
original vcpu-thread's copy of this register will get set to 0.
2019-09-19 11:39:14 +10:00
Kent McLeod
ef8b01390d KernelIRQReporting: Change reserved IRQ reporting
Reserved IRQ reporting would print on every received reserved IRQ. This
feature is supposed to report spurious interrupts, yet most cases
reserved IRQs are not spurious. We change the printing to only print if
the reserved IRQ was unhandled. The intention is to allow more app
configurations to leave this feature enabled in development builds.
2019-09-19 11:33:03 +10:00
Anna Lyons
7798b4767d aarch64: allow access to memory below physBase
On aarch64 physBase is the constant that points to the bottom of
physical memory (RAM).

Prior to this change the kernel window was mapped directly to physBase,
which is usually not a 0 paddr. As a consequence the kernel could not
access any memory below physBase.

This change fixes this issue by mapping the start of the kernel window
to 0 in the physical address space.

- add new constant PADDR_LOAD, the location of the kernel image in the
physical address space.
- add new constant PADDR_BASE, the start of the physical address space
(0).
- add new constant KERNEL_ELF_BASE, the location of the kernel image in
kernel virtual memory.

A consequence of this change is that on aarch64, the kernelBase constant
now points to the start of the kernel window in virtual memory, but
*not* to the start of the kernel image as these are now different.
2019-09-13 08:35:19 +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
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
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
Anna Lyons
a38e62f2f9 mcs: timeout exceptions
- Add seL4_TCB_SetTimeoutEndpoint
- implement timeout exceptions
2019-08-22 11:22:38 +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
bdc56112bd arm: tickless generic timer implementation
Update the generic timer to implement the MCS kernels tickless timer
driver API and update all platforms that use the arm generic timers:

    - bcm2837
    - exynos5
    - hikey
    - imx7
    - odroidc2
    - tk1
    - tx1
    - tx2
    - zynq7000

Also move the generic timer constants to machine.h to avoid a circular
dependency.
2019-08-22 11:22:35 +10:00
Anna Lyons
742cabf15b mcs: provide tickless api for arm timers
This does not implement the timers for any platforms, but
provides the generic arm arch, and aarch32/aarch64 infrastructure for
tickless timer drivers.
2019-08-22 11:22:34 +10:00
Anna Lyons
acfc3c5257 mcs: tickless driver for x86
Add a tickless timer driver for x86. The driver defaults to using
TSC_DEADLINE mode, but falls back to the apic if that feature is not
available.
2019-08-22 11:22:34 +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
Anna Lyons
6746428a9d arm,gicv3: implement setIRQTarget
This allows SPIs to be routed to different cores.
2019-07-30 16:49:53 +10:00
Anna Lyons
0f139e7f6e arm,gicv3: update to use virtual ppi irqs
This commit updates the gic_v3 driver to translate virtual irqs to
hardware irq numbers, which enables PPI support for SMP.
2019-07-30 16:49:53 +10:00
Anna Lyons
794aad98f1 arm,gicv3: consisent sgi/ppi checks
This commit brings the gic_v3 is_sgi and is_ppi checks in line with
gicv2 making the code more consistent.

It also removes unneccessary conditionals in the checks, as is_sgi is
always called before is_ppi so the lower bounds checks are not required.
2019-07-30 16:49:53 +10:00
Anna Lyons
0d3692ede9 arm,gicv3: use SPI_START
This removes a redundant constant to use one from the gic_common header.
2019-07-30 16:49:53 +10:00
Anna Lyons
32952cc390 arm,gic: move gic helpers to gic_common
In order to support gic_v3 SMP, move helpers from gic_v2.h to
gic_common.h
2019-07-30 16:49:53 +10:00
Anna Lyons
0b9aa61a56 arm,gic: refactor constants into gic_common.h
Move common definitions from gic_v2.h and gic_v3.h into gic_common.h
2019-07-30 16:49:53 +10:00
Anna Lyons
21888e6a95 aarch64: add missing dsb
Co-authored-by: Yanyan Shen <yanyan.shen@data61.csiro.au>
2019-07-30 16:09:09 +10:00
Anna Lyons
7d55e2174c arm: CONFIG_L1_CACHE_LINE_SIZE_BITS in cmake
Move definition of L1_CACHE_LINE_SIZE_BITS to cmake where it is set
according to the arm processor family.

This removes duplication in the hardware.h header files and makes adding
a new processor family require less lines changed.
2019-07-30 16:09:08 +10:00
Kent McLeod
7bc76e8275 gicv2: Don't translate irqInvalid into array index
This also adds a check that translating a core + irq doesn't result in
an index that is irqInvalid.
2019-07-29 13:33:02 +10:00
Kent McLeod
51ee24fd59 trivial, gic_v2: Use CURRENT_CPU_INDEX() 2019-07-29 13:00:08 +10:00
Anna Lyons
b1788e02d5 aarch64: add support for 40-bit PA
This commit adds support for using a 40-bit physical addresses in
aarch64-hyp mode.

40-bit PA support is implemented by using a 3-stage translation, with a
13 bit page upper directory as the vspace root. PageGlobalDirectories
are not used in this configuration.

To use 40-bit PAs, platforms should set KernelArmPASizeBits40 to ON.

Co-authored-by: Yanyan Shen <yanyan.shen@data61.csiro.au>
Co-authored-by: Chris Guikema <chris.guikema@dornerworks.com>
2019-07-25 10:30:45 +10:00
Anna Lyons
8af1aa77f6 aarch64: abstract vspace_root in vspace code
On aarch64-hyp the virtual address translation structure can differ
depending on the physical address range. This commit prepares to support
more than a single physical address range by removing the assumption
that the top-level structure in a vspace is a PGD, replacing it with the
concept of a vspace_root.

Specifically:
    - add and use macros to refer to vtable bitfield generator functions
    - use the existing vspace_root_t type rather than pgde_t
    - pull performASIDPoolInvocation into header
    - add and use VSPACE_PTR rather than PGDE_PTR
    - rename decodeARMVPageGlobalDirectoryInvocation to refer to VSpace
    - update comments/error messages
    - rename variables
2019-07-25 09:59:17 +10:00
Anna Lyons
dfd8641c85 aarch64-hyp: check PA and granule sizes
Check that the configured physical address range is supported by the
processor and that the granule size (4KiB) is supported.
2019-07-25 09:19:34 +10:00
Chris Guikema
86a22fd343 trivial: properly mask vtcr macros 2019-07-25 09:19:00 +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
1deb1d2696 [SMP] New IPI call to unmask remote IRQ
Added a new IPI on ARM to unmask a remote private interrupt.
2019-07-19 16:37:03 +10:00
Kent McLeod
dd6b8cb665 gic_v3: Support for aarch32 2019-07-18 13:47:23 +10:00