Commit graph

1652 commits

Author SHA1 Message Date
JorgeMVP
a4b591727a arm64: add required isb() between AT and PAR inst
- "When an address translation instruction is executed,
explicit synchronization is required to guarantee the
result is visible to subsequent direct reads of PAR_EL1."

Signed-off-by: JorgeMVP <jorgepereira89@gmail.com>
2023-04-23 14:59:35 +10:00
JorgeMVP
a7845d297d gic_v3: fix offset for gicd iroutern mem-map reg
GICD_IROUTERn is at the offset 0x6100 for SPI 32.
SGIs and PPIs do not have a target since they are private to CPUs.
Signed-off-by: JorgeMVP <jorgepereira89@gmail.com>
2023-04-14 18:18:50 +10:00
Gerwin Klein
ca1d5f9226 machine: compile time checks for multikernel
Add compile time checks for conditions on physBase that are necessary
for verification of multikernel builds to succeed -- if these fail, the
proofs will fail.

If these succeed, and nothing else has changed compared to a verified
kernel other than physBase, then the proofs will succeed. This does not
mean that all platform requirements are validated, it just means that
all requirements for the proofs to be consistent are met.

The conditions correspond to those in

    spec/machine/*/Arch_Kernel_Config_Lemmas.thy

in the verification repository.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-04-12 15:56:26 +10:00
Gerwin Klein
51966d4508 boot: document region types
Mention that it can be Ok for regions to overflow. State explicitly
that the end is exclusive.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-04-12 15:07:02 +10:00
Alwin Joshy
f8b2440b38 Implemented the vm fault fastpath on aarch64
This fastpath optimizes the performance of VM faults in
seL4. It is heavily based on the existing seL4_Call
fastpath and includes the addition of fastpathing replies
to faulted threads in the seL4_ReplyRecv fastpath.
Currently only supported only implemented for aarch64.

Signed-off-by: Alwin Joshy <joshyalwin@gmail.com>
2023-03-08 17:58:14 +11:00
Rafal Kolanski
65a1b457a4 make physBase a static inline function
For verification flexible w.r.t kernel placement in physical memory, we
need to relate physBase as a named constant to its abstract equivalent.
Unfortunately, apart from enums, the C programming language does not
have real constants. The C parser follows the C standard and requires
enums constants to be storable as int, meaning without major overhaul
enums are not sufficient for storing word_t-sized memory addresses.

Since the linker scripts can't deal with static inline functions
in the constants they need (KERNEL_ELF_BASE and KERNEL_ELF_PADDR_BASE),
we provide the following preprocessor definitions for the linker
specifically:
* PHYS_BASE_RAW (the numerical value returned by physBase())
* KERNEL_ELF_BASE_RAW
* KERNEL_ELF_PADDR_BASE_RAW

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2023-03-07 14:29:14 +11:00
Chris Guikema
b99e1ba325 rocketchip-zcu102: use plic0
On the ZCU102 Rocketchip instantiation, the PLIC is available required
to use hardware peripherals like a UART

Signed-off-by: Chris Guikema <chris.guikema@dornerworks.com>
2023-02-22 09:35:14 +11:00
Axel Heider
d14c53974c user proper field from thread context structure
The thread context structure layout is explicitly designed to have the
register context first, as this simplifies saving the user context on
entry in assembly code. On the exit path there is no need to hard-code
this assumption, stick to the semantics and leave details to the
compiler.

Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
2023-01-13 10:22:28 +11:00
alwin-joshy
069c937272
Implemented signal fastpath on AARCH64 (#793)
The signal fastpath aims to optimize the
seL4_Signal operation. In this commit, it is
implemented for MCS AARCH64 (SMP and non-SMP).
The fastpath does not include the case where
signaling results in a higher priority thread
being unblocked and made available for
scheduling (on any core). It does not
fastpath the case where the signaled thread
is donated a scheduling context and has its
FPU state saved in the FPU of a core.

Co-authored-by: Shane Kadish <shane.kadish@csiro.au>
Signed-off-by: Alwin Joshy <joshyalwin@gmail.com>
2023-01-10 10:15:39 +11:00
Axel Heider
838b9a4331 risc-v/plic: support rv32 targets
Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
2022-12-03 08:21:29 +11:00
Axel Heider
548a81a057 riscv: support qemu-riscv-virt platform
Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
2022-11-13 11:53:54 +11:00
Axel Heider
1e38178832 aarch32: fix define check
Fix wrong name used in refactoring of commit 4b491dcf

Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
2022-11-11 13:52:25 +11:00
Axel Heider
72aeea983a boot/arm: remove activate_global_pd usage
activate_global_pd is just an alias for activate_kernel_vspace nowadays

Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
2022-11-11 09:03:57 +11:00
Axel Heider
b07d653bdb boot: remove unused return values
Remove the return value from configure_sched_context(), because it never
fails. As a consequence, create_idle_thread() also never fails and does
not need a return value.

Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
2022-10-30 19:54:02 +11:00
Indan Zupancic
2a8c9683f3 MCS, SMP: Add clock synchronisation test
Because ksCurTime is compared cross-node now, time across
nodes must be the same. Check this once during boot.

Replace __atomic_signal_fence with the more correct
__atomic_thread_fence, as ksNumCPUs will be changed
cross-node.

Signed-off-by: Indan Zupancic <Indan.Zupancic@mep-info.com>
2022-10-28 10:39:30 +11:00
Indan Zupancic
04c096128b Cleanup refill_new
Remove the now unused core argument from refill_new and replace all
REFILL_NEW calls with direct calls.

Signed-off-by: Indan Zupancic <Indan.Zupancic@mep-info.com>
2022-10-28 10:39:30 +11:00
Indan Zupancic
ba262f6d75 Do not use cross-node ksCurTime
The code using ksCurTime assumes that ksCurTime is up-to-date,
but this assumption is wrong for ksCurTime of other CPU cores.
Those can be quite some time in the past.

The implications of using NODE_STATE(ksCurTime) is that clocks
on all cores must be synchronous:

- Riscv is okay: The specification states: "The real-time clocks
  of all hardware threads in a single user application should be
  synchronized to within one tick of the real-time clock."
- x86 okay if not ancient when Invariant TSC is supported.
- aarch64 is okay.
- arm32: arm_global.h is okay. Exynos timer seems okay. am335x and
  omap3430 are single-core.

See also #854.

Signed-off-by: Indan Zupancic <Indan.Zupancic@mep-info.com>
2022-10-28 10:39:30 +11:00
Axel Heider
0c8c386394 fastpatch: use thread passed as parameter
Use the thread passed as parameter instead of making assumption that
this is in sync with the global state.

Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
2022-10-28 09:20:47 +11:00
Axel Heider
9c083b84ef make macro less obscure
- explicitly mention the parameter to make macro less obscure.
- add brackets to make the expression an atom.

Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
2022-10-01 10:16:32 +02:00
Yanyan Shen
e4c5bf242c aarch64: Use isb after changing FPU ctrl registers
Signed-off-by: Yanyan Shen <yshen@hybridkernel.com>
2022-09-22 10:13:13 -07:00
Axel Heider
6dd3a18065 re-use existing functions to avoid redundancy
Signed-off-by: Axel Heider <axelheider@gmx.de>
2022-09-15 11:25:04 +02:00
Michael McInerney
b7f2a1fb6f mcs: remove unused tcbReply field from tcb struct
The pointer to a reply object, if any, can be accessed
via the replyObject in the thread state

Signed-off-by: Michael McInerney <michael.mcinerney@proofcraft.systems>
2022-09-13 13:21:20 +02:00
Peter Chubb
d84f3fcb4a Add newer Skylake model ID
At least some server-class Skylake processors use 0x55 as
their model ID.
These are Skylake X processors.

Signed-off-by: Peter Chubb <peter.chubb@unsw.edu.au>
2022-07-29 17:01:32 +10:00
Gerwin Klein
1c28462ebf structures: fix MCS object sizes
The kernel expects object sizes to be powers of two for size and
alignment computations.

- add missing padding for MCS 64-bit configurations for notifications
  (other configs were already fine)
- add missing padding for reply object struct
- strengthen compile time assertion to catch discrepancies in the
  future.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-07-19 14:01:45 +10:00
FinnZhang
dd2a435722 fix arm64 address space graphic in comment
Signed-off-by: FinnZhang <finnzhang@outlook.com>
2022-06-29 16:12:05 +10:00
Ryan Barry
4ce6cbe9ea Don't clobber msgInfo register
The messageinfo register is set to 0 after processing a kernel object
invocation if the invocation set the thread state to restart. This is a
problem if the kernel object invocation had also set the message info
register.

The existing convention in this case is for the kernel invocation to
set the thread state to running right before it returns to avoid the
problematic code path. However, there are some invocations that do not
follow this convention and their message info register gets clobbered.
There are also some invocations that set message registers without
setting the message info register at all, or that do not guard their
message register updates with a call parameter.

This commit fixes these issues modulo setConsumed, which we defer to a
later point.

Co-authored-by: Jimmy Brush <code@jimmah.com>
Signed-off-by: Ryan Barry <ryan.barry@proofcraft.systems>
2022-06-17 15:31:10 +10:00
Rafal Kolanski
b8ef00e09a arm: don't do S1 translation in Arch_setMRs_fault
For a VM fault in a hypervisor context, 32-bit Arm translated the IP
address into an IPA, while 64-bit Arm did not. The previous commit
made these consistent by performing the translation on both.

After investigation and discussion, the 32-bit Arm behaviour was
declared a bug: reporting an IPA (instead of a VA) to the VMM is not
very useful and can cause issues when the fault message is not sent
immediately (SELFOUR-1602). This commit, therefore, removes all stage 1
translation from Arch_setMRs_fault on Arm platforms.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-06-06 10:10:49 +10:00
Rafal Kolanski
fce5cece4d arm: consolidate stage 1 translation function use
This commit introduces `addressTranslateS1` to be used on Arm platforms
with hypervisor enabled for stage 1 (vaddr to IPA) translation. On
AArch32 this is a rename from `addressTranslateS1CPR`, and on AArch64 it
wraps `ats1e1r`. This changes the ABI on AArch64 to report faulting
address as IPA.

Reasoning:

With hypervisor enabled, AArch64 defined `addressTranslateS1CPR` to do
nothing, while AArch32 defined it to do stage 1 translation. This
delivered VM faults to the user with the faulting address being either
an IPA or a vaddr depending on mode. This inconsistency is undesireable.

This commit proposes adjusting the inconsistency to match AArch32
behaviour, as it is one of the verified platforms.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-06-06 10:10:49 +10:00
Indan Zupancic
4a7d08def0 MCS, ARM: Introduce TIMER_OVERHEAD_TICKS
For ARM currently TIMER_PRECISION exists, but that is in microseconds
and not fine-grained enough.

This is needed to make periodic tasks synchronous with the system clock.
If this value is zero every period will be extended with the overhead of
taking an interrupt and reading the system clock. To avoid this drift,
the configured value should be set to at least the average overhead.

See also issue #844.

Signed-off-by: Indan Zupancic <Indan.Zupancic@mep-info.com>
2022-05-23 16:31:45 +10:00
Kent McLeod
d18f752739 trivial: add missing space character
Signed-off-by: Kent McLeod <kent@kry10.com>
2022-05-20 12:29:25 +10:00
Axel Heider
aff5d9930c fix config includes
Use kernel's config.h

Signed-off-by: Axel Heider <axelheider@gmx.de>
2022-05-20 08:47:55 +10:00
Axel Heider
c35545679d risc-v: add SBI remote hart mask helper function
Avoid redundant code.

Signed-off-by: Axel Heider <axelheider@gmx.de>
2022-05-20 08:47:18 +10:00
Kent McLeod
3576f7b635 x86_64: Fix x86_64 gcc compile error with sysexitq
sysexit requires a 64-bit operand to remain in 64-bit mode when
switching to user level. gcc versions older than 12 encode this as
"REX.W SYSEXIT" while clang encodes this as "SYSEXITQ". Both compilers
don't support the alternate encoding. We instead use ".byte
0x48,0x0F,0x35" which is the actual opcode of the required instruction
which will work with both compilers.

Signed-off-by: Kent McLeod <kent@kry10.com>
2022-05-20 08:35:55 +10:00
Kent McLeod
76680fb583 arm_hyp: Add compiler assert for seL4_UserTop
seL4_UserTop must be defined to be > 0xC0000000 when the kernel is in
hyp mode due to assumptions made by the kernel init code.

Signed-off-by: Kent McLeod <kent@kry10.com>
2022-05-12 16:30:13 +10:00
Kent McLeod
e7c544ccf3 arm_hyp: Access SPSR via non-banked instructions
Accessing the hyp mode SPSR register via the banked instruction syntax
is UNPREDICTABLE if hyp is the current mode. The direct syntax needs to
be used instead. This is documented in the ARMv7 Architecture reference
manual.

Signed-off-by: Kent McLeod <kent@kry10.com>
2022-05-12 16:30:13 +10:00
Cao Jianlong
8278066238 aarch64: remove redundent CPSR.AIF in HCR_NATIVE
CPSR.AIF already presented in HCR_COMMON macro,
And HCR_NATIVE includes HCR_COMMON, then no need
To set CPSR.AIF bit again

Signed-off-by: Cao Jianlong <caojianlong@outlook.com>
2022-04-14 19:50:24 +10:00
Nataliya Korovkina
756a37b7d3 benchmark: config opt. name to enable log buffer
The latest code updates introduced CONFIG_ENABLE_KERNEL_LOG_BUFFER
meanwhile other code and config.cmake keeps using
CONFIG_KERNEL_LOG_BUFFER

Signed-off-by: Nataliya Korovkina <malus.brandywine@gmail.com>
2022-03-31 08:56:06 +11:00
Axel Heider
773ec49d2b risc-v: do not hide timer roll overs
Provide the raw timer register values, higher layer may then detect
and handle roll overs.

Signed-off-by: Axel Heider <axelheider@gmx.de>
2022-03-25 12:28:38 +11:00
Axel Heider
ba089dafbc risc-v: always use the second value
Signed-off-by: Axel Heider <axelheider@gmx.de>
2022-03-25 12:28:38 +11:00
Axel Heider
20c71c6248 risc-v: use word_t type for register variables
Signed-off-by: Axel Heider <axelheider@gmx.de>
2022-03-25 12:28:38 +11:00
Axel Heider
f9df87b228 risc-v: simplify integer expression
There is no need to cast twice.

Signed-off-by: Axel Heider <axelheider@gmx.de>
2022-03-25 12:28:38 +11:00
Kent McLeod
8e227395a0 aarch64: Remove reserved VSpace slots from API
Now that there is no need to reserve page table entries in each VSpace
object, the full architecture specified address space range is usable.

Signed-off-by: Kent McLeod <kent@kry10.com>
2022-03-24 20:26:15 +11:00
Kent McLeod
ae1007a51a aarch64,smmu: Move bind_cb attribute to asid map
Each vspace object has a count of how many SMMUv2 context banks are
bound to it. This attribute is moved out of a reserved page table entry
slot into the asid_map_t structure.

This also reduces the width of the MappedCB field from 12 to 8 bits
which is large enough to hold the maximum number of CBs allowed by the
SMMUv2 spec (128). This conserves otherwise wasted bits.

Signed-off-by: Kent McLeod <kent@kry10.com>
2022-03-24 20:26:15 +11:00
Kent McLeod
ebcfcb7016 aarch64,fastpath: Fixup ASID validation checks
When switching to the new thread, it's VSpace must have a valid ASID
mapping. This means that the ASID in the vspace cap must resolve to the
same vspace object as the vspace cap does. In addition, when the VSpace
object is for a stage 2 translation there must be a currently assigned
hardware VMID for the vspace. Otherwise the slowpath must be taken.

Once these checks are done, the TTBR registers can be directly updated
without needing to perform another ASID translation.

Signed-off-by: Kent McLeod <kent@kry10.com>
2022-03-24 20:26:15 +11:00
Curtis Millar
1ae9360300 Store aarch64 vmid in asid map
This stores the 8-bit vmid in the ASID map rather than in a
slot of the virtual address space root for hypervisor configurations.

Co-authored-by: Kent McLeod <kent@kry10.com>
Signed-off-by: Kent McLeod <kent@kry10.com>
2022-03-24 20:26:15 +11:00
Curtis Millar
14a0b4ac5e Use ASID map bitfield for aarch64
This uses the asid_map bitfield from x86 for aarch64 to map from ASID to
a given address space.

This will allow for alternate mappings from ASIDs in the future as well
as moving small amounts of metadata into the the ASID table itself.

Co-authored-by: Kent McLeod <kent@kry10.com>
Signed-off-by: Kent McLeod <kent@kry10.com>
2022-03-24 20:26:15 +11:00
Axel Heider
451dc90f99 print value for unknown entry reason
This is not supposed to happen, thus printing the value gives a bit more
insight what might have happened here.

Signed-off-by: Axel Heider <axelheider@gmx.de>
2022-03-16 16:00:42 +11:00
Axel Heider
c673f1cded make macro ARRAY_SIZE() handle corner cases
Put the parameter in brackets to ensure it is an atom. This makes the
macro work as expected in corner cases like ARRAY_SIZE(foo + 3) also.

Signed-off-by: Axel Heider <axelheider@gmx.de>
2022-03-10 18:16:00 +11:00
Ivan Velickovic
ab32a37398 trivial: fix examples explaining IRQT_TO_IDX macro
Signed-off-by: Ivan Velickovic <i.velickovic@unsw.edu.au>
2022-03-04 19:42:52 +11:00
Andy Bui
978efa97cb trivial: Fix typo in FPU extension ifdef for RISCV
Signed-off-by: Andy Bui <andy.bui@student.unsw.edu.au>
2022-03-01 19:20:07 +11:00