Commit graph

1217 commits

Author SHA1 Message Date
Kent McLeod
9a552d84b6 RISC-V: Refactor IRQ handling to use PLIC
Previously we only handled IRQs generated by the BBL running in machine
mode via changes to supervisor interrupt pending (SIP) bits. Now that we
need to support shared global interrupts through the PLIC we need to
modify the way interrupts are processed.

We additionally remove many DONT_TRANSLATE annotations on functions that
the CParser is able to parse.

Also authored by: Siwei Zhuang <siwei.zhuang@data61.csiro.au>
2019-06-18 10:22:47 +10:00
Kent McLeod
c73d5178d9 RISC-V: Add PLIC interface and HiFive driver
We assume the PLIC is currently the only global interrupt controller
that RISC-V platforms are going to use. Each platform may have a
different programmers model for interracting with the hardware
controller. We provide a common interface for PLIC drivers to implement
that the kernel will use to manage IRQs.

Also authored by: Siwei Zhuang <siwei.zhuang@data61.csiro.au>
2019-06-18 10:22:47 +10:00
Siwei Zhuang
4b24006678 RISC-V: Add kernel device functionalty
- Create device untypeds for platform devices that can be passed to user
space.
- Create kernel device mapping for devices required by the kernel.
Note that the current kernel device mapping is simply a 1GiB of page
physical memory as that contains all devices for all RISC-V platforms
that are currently supported.
2019-06-18 10:22:43 +10:00
Kent McLeod
2865d6b61b spike: Refactor into clearer subplatforms
For now we keep the RISC-V platforms under the spike kernel platform
name. Splitting the different platform definitions into different header
files will help maintainability as we add different device layouts and
kernel device drivers.
2019-06-17 20:31:33 +10:00
Kent McLeod
8dc90b559f RISC-V: Correct PPTR_USER_TOP definition
PPTR_USER_TOP represents the first inaccessible user address which is
usually ((2^(38-12))-1)*0x1000 on SV39. This corresponds to the first
address of the last page in the lower half of the top level page table.
2019-06-17 20:31:33 +10:00
Kent McLeod
4957c5e8a5 RISC-V: Comment 64-bit SV39 kernel address space
Add a comment and diagram explaining the current structure of the SV39
kernel address space. The top half of the virtual address space is
reserved for the kernel and consists of the Kernel window of all
accessible physical memory, the kernel ELF mapping and the Kernel device
mapping region.
2019-06-17 20:31:33 +10:00
Kent McLeod
10655ce634 RISC-V: Add PPTR_KDEV for kernel device mappings
There is a 1GiB region reserved at the top of the Kernel virtual address
space to map devices used by the kernel into. The start of this range is
referred to by PPTR_KDEV. This also represents the end of the Kernel ELF
window mapping.
2019-06-17 20:31:33 +10:00
Siwei Zhuang
6a16d532e6 RISCV: Introduce KERNEL_ELF_BASE for verification
Verification requires the KERNEL_BASE to be 1GB aligned at the start of
the kernel elf window. It was also the location where the kernel elf was
mapped. As we have to include SBI memory in the kernel elf window,
the KERNEL_ELF_BASE is introduced for the real kernel elf mapping.
Keeping KERNEL_BASE unchanged.
2019-06-17 20:31:33 +10:00
Anna Lyons
aab92637d1 x86: move boot_state definition to boot_sys.h
This is because future work needs to access the rmrr_list globally.
2019-06-17 17:36:11 +10:00
Anna Lyons
f16b8e222a armv7: enable readDscrCp if ENABLE_BENCHMARKS=y
In order to enable user-level access to the PMU, which is required by
the benchmarks.
2019-06-17 17:34:18 +10:00
Anna Lyons
9dcb470631 arm: remove plat/machine/timer.h
plat/machine/timer.h is unused on arm, so remove it and fix up the
includes.
2019-06-17 10:44:36 +10:00
Anna Lyons
f5b820e9b9 benchmark: remove unused function
Remove benchmark_utilisation_kentry_stamp.
2019-06-14 14:11:09 +10:00
Anna Lyons
18eefea980 trivial: use UINT32_MAX 2019-06-14 14:11:09 +10:00
Anna Lyons
3e0bbe8245 arm: clean & consolidate pmu management code
- consolidate armv_init_ccnt into arm_init_ccnt, which is general
 - move armv_handleOverflowIRQ definition to benchmark.h
   (no need for extra header)
 - clean up definition of armv_handleOverflowIRQ
2019-06-14 14:11:09 +10:00
Anna Lyons
65529552dc trivial: add missing config include 2019-06-14 12:12:15 +10:00
Anna Lyons
c090b058a5 arm: consolidate benchmark_arch_utilisation_reset
- Move identical definitions from armv6 and armv7 to common arm code.
- Remove excessive #ifdef guards - let the compiler throw it away if
  it isn't used
2019-06-14 12:12:15 +10:00
Anna Lyons
a7728128cd arm: move handleOverflowIRQ to benchmark.h
Consolidate to reduce include complexity and make benchmarking features
easier to find/comprehend.
2019-06-14 12:12:15 +10:00
Anna Lyons
d4868012f8 arm: always handle overflow irqs
Always handle overflow irqs from the cycle counter if overflow irqs are
enabled, not just when we are updating the log. Otherwise if logging
isn't enabled but the counter overflows the kernel will be stuck in a
interrupt handling loop.
2019-06-14 12:12:15 +10:00
Anna Lyons
e2a7c49de6 arm: use NODE_STATE in benchmark_overflowHandler
This code did not compile prior to this change.
2019-06-14 12:12:15 +10:00
Adrian Danis
7c1a705336 SELFOUR-1198: correct restart PC
Fixes a case where a thread can go from Running->Inactive->Restart and use a restart PC
that is out of date. An out of date restart PC occurs when a thread was transitioned to
running after being in a blocked state, but was never scheduled and so did not execute
the traps code that updates the restart PC.

A 'more correct' fix would be to update the restart PC when a thread is first transitioned
to Running, but this results in lots of unnecessary update as
 * Frequently immediately schedule a thread after it is transitioned to running, making
   the update to restart PC completely redundant as it gets immediately overwritten
 * Rarely suspend threads making all the updates a 'high' cost for fixing an infrequent
   operation

As a result this solution lazily fixes the restart PC only when we enter a state where
we might need a correct restart PC, which currently in the kernel is only when we
go from Running->Inactive, which can only happen in `suspend`
2019-05-31 14:45:47 +10:00
Curtis Millar
01b73622f5 Consistent naming of FaultIP and NextIP in kernel
Always refer to the virtual register that stores the address of a fault
as FaultIP and the register that stores the return for a fault NextIP.
2019-05-28 15:12:38 +10:00
Sylvain Gauthier
84e6d4cdb1 Added IRQ routing to specific core for ARM
Add a new syscall, `seL4_IRQControl_GetTriggerCore`, to get a IRQHandler
with specific target core(s) and trigger method. Only available in SMP
mode.
2019-05-20 10:01:40 +10:00
Yanyan Shen
a0ae9f76a1 armv8: Save/restore TPIDRRO_EL0 for VCPUs
TPIDRRO_EL0 is used as IPC Buffer for seL4-native threads.
The register should be saved and restored for VCPUs.
2019-05-17 14:33:42 +10:00
Matthew Brecknell
c030cafad2 x86 boot: pass mem_p_regs by pointer
This avoids taking the address of a local variable in arch_init_freemem,
which is not supported by the Isabelle C parser.
2019-05-15 14:03:40 +10:00
Anna Lyons
8a6180f4b3 arm: make mode reserved regions a constant
Replace an unneccessary function call with a constant. This simplifies
and increases the maintainability of arch_init_freemem.
2019-05-15 14:03:40 +10:00
Anna Lyons
661e8efebb arm: merge redundant hardware.c
hardware.c was defined for both 32 and 64 bit arm kernels. However, the
only difference in the file is the register used in setNextPC. Add this
register as a #define in registerset.h, move hardware.c to be common for
both 32- and 64-bit arm.
2019-05-15 14:03:40 +10:00
Anna Lyons
e3a83035f8 boot: consolidate init_freemem
init_freemem sets up available regions of memory for the hardware that
seL4 is booting on. Previously this function was duplicated across
architectures, with minor duplication.

This change provides a top-level init_freemem suitable for all
architectures.

- arm/riscv: change get_avail_p_reg to return whole p_reg array
- update all architectures to use new init_freemem.
- wrap init_freemem calls with arch_init_freemem for each arch, where
arch_init_freemem sets up the available and reserved regions of memory
which are passed to init_freemem.
2019-05-15 14:03:40 +10:00
Anna Lyons
67f2de94a1 trivial: riscv - remove unused function prototype 2019-05-15 14:03:40 +10:00
Anna Lyons
41780b0602 x64: add missing constant PPTR_TOP
PPTR_TOP represents the top that can be made available to the
user as untyped.
2019-05-15 14:03:40 +10:00
Yanyan Shen
134eb53e31 aarch64: Correct tpidrro_el0 2019-05-14 13:15:50 +10:00
Jasper Lowell
69339d4203 Boot code: Statically allocate idle thread
The idle thread is not managed at user-level and so it can instead be
statically allocated. This simplifies the boot code and increments
towards being easier to formally verify.
2019-05-07 12:21:31 +10:00
Kofi Doku Atuah
c3766ccd16 ARM, HYP, CP14, Debug: Don't deliver CP14 accesses to userspace as faults
Persuant to the fact that userspace cannot save and restore the debug coprocessor,
there is no point in delivering a fault message to userspace when CP14 is accessed.

The debug coprocessor must be entirely handled by the kernel, and a new hardware
accessor and manipulation capability must be designed and implemented now.
2019-05-06 14:34:19 +10:00
Matthew Brecknell
1c6c06dc3e boot: implement intStateIRQNode as an array
It turns out that verifying this is easier than if intStateIRQNode is a
pointer that is statically initialised to point to another array.
2019-05-03 16:19:19 +10:00
Anna Lyons
a6b4cf739d boot: allocate irq cnode statically
The memory used for the irq cnode is never available to the user. As a
result this memory can be allocated statically, simplifying the
bootcode.

- remove allocation of irq cnode
- add static init
- generate irq cnode size from cmake for arm
- add static constants for riscv, x86 as there is no variability at the
moment.
2019-05-03 16:18:39 +10:00
Simon Shields
6a31a57ef8 ARM: optionally pass bootloader DTB to userspace
We now support receiving a DTB from the ELF loader and passing it on
to userspace in extra bootinfo. We still support booting without a DTB,
though - the device tree address is set to zero in the boot code and no
extra bootinfo region is provided.
2019-05-01 12:18:52 +10:00
Kent McLeod
d250dc03c7 spike: Use sip CSR for isIRQPending
An instruction is pending if the STIP or SEIP bits are set in the sip
CSR.
2019-05-01 11:00:11 +10:00
Anna Lyons
f7c43820d2 trivial: fix #ifdef on am335x 2019-04-15 08:47:32 +10:00
Anna Lyons
2c05d13c40 trivial: arm_hyp - fix build 2019-04-12 14:47:46 +10:00
Anna Lyons
82d0485911 arm: priv_timer -> include/drivers/timer/arm_priv
update configs that use it.
2019-04-12 14:25:58 +10:00
Anna Lyons
391b717d1d arm: generic_timer -> drivers/timer/arm_generic
- move generic_timer.h to drivers/timer/arm_generic.h
- update all configs that use it.
2019-04-12 14:25:58 +10:00
Anna Lyons
cb9499069d zynqmp: use declare_default_headers
- remove unused header files replaced by declare_default_headers
2019-04-12 14:25:58 +10:00
Anna Lyons
66df769f8c zynq7000: use declare_default_headers
- remove unused header files replaced by declare_default_headers
2019-04-12 14:25:58 +10:00
Anna Lyons
26a3b55521 omap3: use declare_default_headers
- remove unused header files replaced by declare_default_headers
- move timer.h to drivers/timer/omap3430.h
- move interrupt.h to drivers/irq/omap3.h
2019-04-12 14:25:58 +10:00
Anna Lyons
df4d19ae5f imx7: use declare_default_headers
- remove unused header files replaced by declare_default_headers
2019-04-12 14:25:58 +10:00
Anna Lyons
e4f567e19e imx6: use declare_default_headers
- remove unused header files replaced by declare_default_headers
2019-04-12 14:25:58 +10:00
Anna Lyons
7bf513b75e imx31: use declare_default_headers
- remove unused header files replaced by declare_default_headers
- move interrupt.h -> drivers/irq/imx31.h
- move hardware.bf -> drivers/timer/imx31-epit.bf
- move timer.h -> drivers/timer/imx31-epit.h
- move definitions from hardware.h to plat/imx31/machine/hardware.c
2019-04-12 14:25:58 +10:00
Anna Lyons
209563d4ca hikey: use declare_default_headers
- remove unused header files replaced by declare_default_headers
2019-04-12 14:25:58 +10:00
Anna Lyons
e1a36c2601 exynos: use declare_default_headers
- remove unused header files replaced by declare_default_headers
- move timer.h to drivers/timer/exynos5422-mct.h
- move mct.h to drivers/timer/mct.h
2019-04-12 14:25:58 +10:00
Anna Lyons
474a7da5c0 bcm2837: use declare_default_headers
- remove unused header files replaced by declare_default_headers
- move machine.h to drivers/irq/bcm2836-armctrl-ic.h
2019-04-12 14:25:58 +10:00
Anna Lyons
2d77062df4 apq8064: use declare_default_headers
- remove unused header files replaced by declare_default_headers
2019-04-12 14:25:58 +10:00