Commit graph

1845 commits

Author SHA1 Message Date
Matt Rossouw
e8c070cd35 Added initial support for Cheshire platform
Signed-off-by: Matt Rossouw <matthew.rossouw@unsw.edu.au>
2025-02-03 16:10:58 +11:00
Yanfeng Liu
b67ff0bcdf riscv/hardware.h: simplify RISCV_GET_PT_INDEX
This simplifies RISCV_GET_PT_INDEX by reusing RISCV_GET_LVL_PGSIZE_BITS.

Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
2024-12-05 09:12:40 +11:00
Ivan-Velickovic
e45d229601 Fix printing when IRQ is out of range
Signed-off-by: Ivan-Velickovic <i.velickovic@unsw.edu.au>
2024-12-03 08:56:47 +11:00
Yanfeng Liu
58674cdaec arch/riscv64: revise address space comments
This revises comments of virtual space mapping.

Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
2024-11-27 09:20:25 +11:00
julia
640643954c riscv: fix off-by-1 write for PLIC IRQ priorities
This produced 'sifive_plic_write: Invalid register write 0x180' in QEMU.
https://github.com/seL4/seL4/issues/1350#issuecomment-2464273308

Signed-off-by: julia <git.ts@trainwit.ch>
2024-11-11 12:25:13 +00:00
Matt Rossouw
65825d4df8 Re-enabled PLIC for Ariane
Signed-off-by: Matt Rossouw <matthew.rossouw@unsw.edu.au>
2024-11-06 10:02:41 +00:00
Gerwin Klein
03ad568c89 move cache flush from untyped reset to retype
Do not perform cache flushing in clearMemory. Instead flush the cache
only for those object types where it is necessary, and only when the
object is retyped, not when the untyped cap is reset.

This reduces overall need for flushing and delays it to the point of
use. This should speed up boot time significantly, but may impact WCET,
because the largest flush is now the largest page size (e.g. 24) instead
of CONFIG_RESET_CHUNK_BITS (8). The user could already request a flush
of the largest page size before, though, so it this may not actually
impact WCET. Remains to be investigated.

Why this is safe:

- Flushing is only necessary for objects that are seen by other parts of
  the system, not for kernel-internal object. These objects are
  non-device frames (including IOMMU pages) and page tables. All other
  objects are only read/written by the kernel. Frames need to be flushed
  to RAM (as clearMemory did), because they could be seen uncached by
  devices. Page tables only to PoU for the page table walker.

- Before createNewObject in retype, these objects do not exist and
  cannot be seen by any part of the system. createNewObject is the point
  where new objects can become visible to the user.

- Theoretically, we could defer flushing further to the point where
  frames or page tables are mapped, but it is more complex to track
  whether a flush has already happened when they are mapped multiple
  times, whereas at retype the object cannot have been flushed already.

- The original implementation, before clearing memory was moved into
  reset untyped, also flushed at the same points.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2024-10-24 15:33:44 +11:00
Michael McInerney
7aac8a3053 mcs: use sc_active in commitTime
Signed-off-by: Michael McInerney <michael.mcinerney@proofcraft.systems>
2024-10-17 20:01:08 +11:00
Gerwin Klein
ff3e7ff93e aarch32: remove unused functions
getKernelStack() is never called, and readHTPIDRO() was only called in
getKernelStack(). readTPIDRPRW() is only used in hyp configurations.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2024-10-14 17:45:42 +11:00
Alwin Joshy
1253115999 hw debug api: aarch64 port
Adding support for the hardware debug API to
aarch64.

Signed-off-by: Alwin Joshy <joshyalwin@gmail.com>
2024-07-18 16:09:52 +10:00
Alwin Joshy
b3974732b9 hw debug api: modify single stepping checks
On aarch32, single stepping is configured by setting an instruction
breakpoint to mismatch mode. The way that it is checked whether a
given breakpoint is being used as a normal breakpoint or for
single-stepping is by checking if it has been configured to mismatch.
This works because the HW debug API does not currently provide a way
to otherwise configure mismatch breakpoints, but seems like an
unsatisfactory solution. Whether single-stepping is enabled, and
the breakpoint that is being used for it is already stored in the
TCB of a thread, and this commit changes checks related to
single-stepping to use this information instead.

Signed-off-by: Alwin Joshy <joshyalwin@gmail.com>
2024-07-18 16:09:52 +10:00
Alwin Joshy
28ffc62f74 aarch32: change dbg register fields
Changing the debug register fields to what they are referred to
as in the ARMv7 and ARMv8 manuals. Mostly a cosmetic change,
but improves clarity.

Signed-off-by: Alwin Joshy <joshyalwin@gmail.com>
2024-07-18 16:09:52 +10:00
Alwin Joshy
c35930f565 change files to allow compilation
Signed-off-by: Alwin Joshy <joshyalwin@gmail.com>
2024-07-18 16:09:52 +10:00
Indan Zupancic
ad6a956103 Prepare Split arm/machine/debug.c
Signed-off-by: Alwin Joshy <joshyalwin@gmail.com>
2024-07-18 16:09:52 +10:00
Axel Heider
3c2c5ba18a risc-v: remove special handling for restoring tp
This is most likely an artifact from the change of the IPC buffer
handling before v11.0.0, where a thread-local register (tp on RISC-V)
was reserved by the kernel for storing the pointer to the thread's
IPC buffer. Architectures such as aarch64 would set the register
inside Arch_switchToThread() and then not touch the register in
restore_user_context(). When the RISC-V port was up-streamed, it
didn't restore the register with the other registers, but also
didn't restore it in Arch_switchToThread() and so ended up restoring
it right at the end of the restore process.

Co-authored-by: Kent McLeod <kent@kry10.com>
Signed-off-by: Axel Heider <axel.heider@codasip.com>
2024-07-18 11:55:55 +10:00
Michael McInerney
6b6bb12501 mcs: remove parameter from schedContext_unbindTCB
This removes the tcb parameter from schedContext_unbindTCB, which
is unnecessary, since it is always the scTcb of the given sc.

Signed-off-by: Michael McInerney <michael.mcinerney@proofcraft.systems>
2024-07-17 09:11:51 +10:00
Michael McInerney
220ef4f94e mcs: refactor awaken
This refactors awaken, providing an inline function for the
while loop condition, and modifying tcbReleaseDequeue to now
perform the entire loop body.

Since tcbReleaseDequeue will perform tcbReleaseRemove on the
head of the release queue, the variable ksReprogram will be set
to true within tcbReleaseRemove, and therefore, we do not need
to set this variable separately within the loop body of awaken.

Signed-off-by: Michael McInerney <michael.mcinerney@proofcraft.systems>
2024-07-16 18:01:44 +10:00
milicat
d3d4cc6023 Fix macro to get irq idx from irqt
Signed-off-by: milicat <milicat@foxmail.com>
2024-06-25 22:18:54 +10:00
Michael McInerney
b93de1fdd5 mcs: use sc_active in isSchedulable
Signed-off-by: Michael McInerney <michael.mcinerney@proofcraft.systems>
2024-06-22 18:06:05 +10:00
Andy Bui
c7bdf1f921 vcpu: only trap WFx instructions from vCPUs
When KernelArmDisableWFIWFETraps is disabled (trapping of WFI/WFE is
enabled), the kernel traps WFx instructions from both native and vCPU
threads. This change makes the code in line with the config description.

In any case, there don't exist many use cases for trapping WFx from
native threads vs vCPU threads. Example: kvm uses this to yield physical
CPU time to other vCPUs instead of busy waiting.

Signed-off-by: Andy Bui <andy.bui2001@gmail.com>
2024-06-20 14:36:32 +10:00
Gerwin Klein
6e9370a561 ioapic: set IOAPIC_IRQ_LINES to max allowed
Correctly mask the IOAPICVER register to the Maximum Redirection Entry
field to potential avoid spurious higher bits on e.g. AMD processors.

Set IOAPIC_IRQ_LINES to the maximum value this field is allowed to
return (239+1). While our haswell machines report 24 IRQ lines as
expected, the skylake machines report 120.

The only impact should be the size of the ioredtbl_state array.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2024-06-14 14:19:24 +10:00
Axel Heider
503ad776bc risc-v: improve comments
- mention skipped t1/x6
- mention skipped a0/x10, a1/x11

Signed-off-by: Axel Heider <axel.heider@codasip.com>
2024-05-23 15:48:04 +01:00
Michael McInerney
686bba4d2a mcs: more uniformly handle ready and release queue
This introduces library functions for updating the linked lists which
use the tcbSchedNext and tcbSchedPrev pointers of a TCB, and uses these
to perform the updates to the ready queues and the release queue.

In order to accommodate this, ksReleaseQueue is now of type tcb_queue_t.

Co-authored-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
Signed-off-by: Michael McInerney <michael.mcinerney@proofcraft.systems>
2024-05-23 18:04:06 +10:00
wucke13
0260fba168 fix: invisible chars due to ANSI escape codes
The prior behavior would emit ANSI escape codes which set the terminal
foreground color to black bold (`[30;1m`), leaving the default
background color. On many terminals configured with a dark color scheme,
this creates black on black characters, i.e. the output is invisible.

This change moves to a better adapted output, where the output is only
marked as bold (`[1m]`), which works well on all color schemes.

Fixes #1243

Signed-off-by: wucke13 <wucke13@gmail.com>
2024-04-28 10:26:11 +10:00
Axel Heider
a58480425c make SMP conditional check more general
Check for CONFIG_ENABLE_SMP_SUPPORT instead of checking for the
number in CONFIG_MAX_NUM_NODES. This allows enabling SMP support
with just one node also.

Signed-off-by: Axel Heider <axel.heider@codasip.com>
2024-04-11 09:20:00 +01:00
Axel Heider
05d0f06620 fix type, add missing 'extern' keyword
Signed-off-by: Axel Heider <axel.heider@codasip.com>
2024-04-09 19:55:34 +01:00
Krishnan Winter
90bd5575b2 aarch64: Rename armKSGlobalLogPDE
Renamed armKSGlobalLogPDE to
armKSGlobalLogPTE inline with RFC-10.

Signed-off-by: Krishnan Winter <krishnanwinter1@gmail.com>
2024-04-09 09:35:54 +01:00
Krishnan Winter
21d699828d Fix macro to access overflow node
Previously accessing the ccnt_num_overflows
value using the NODE_STATE macro. In SMP
configurations, this looks for this value
in the system node state, however, it
resides in the cpu arch node state. This should
therefore be accessed using the ARCH_NODE_STATE.

Signed-off-by: Krishnan Winter <krishnanwinter1@gmail.com>
2024-03-27 10:57:45 +00:00
Axel Heider
271f6cc903 risc-v: make trap_entry a function
Signed-off-by: Axel Heider <axelheider@gmx.de>
2024-03-23 08:48:42 +11:00
Axel Heider
ff422899fc trivial: remove superfluous empty line
Signed-off-by: Axel Heider <axelheider@gmx.de>
2024-03-23 08:48:42 +11:00
Birgit Brecknell
f6656e2c78 Add a glossary to the manual
Add a glossary with seL4-specific terms and their
definitions.
Remove chapter number from bibliography
Tweak Makefile for glossary

Signed-off-by: Birgit Brecknell <bbrcknl@gmail.com>
2024-03-20 14:54:06 +11:00
Indan Zupancic
b527b46dec Arm32: Fix vcpu_hw_write_reg
Forgotten in commit 5bce5c0c1e.

Signed-off-by: Indan Zupancic <indan@nul.nu>
2024-03-15 19:27:37 +01:00
Gerwin Klein
4172bd6170
vcpu: add padding to keep vcpu struct packed
Add padding to keep vcpu struct packed on 32-bit platforms. This doesn't
change the size on 32-bit platforms, because the compiler would insert
padding itself. It does increase the size of the struct by one word
on 64-bit platforms, but it remains below 2^vcpuBits.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2024-03-14 10:02:43 +01:00
Kent McLeod
5bce5c0c1e
ARM: Allow VMPIDR_EL2 reg to be set on unicore
Currently the seL4_VCPUReg enum only defines the seL4_VCPUReg_VMPIDR_EL2
register when the kernel is configured for SMP. This register should be
available for unicore systems too as otherwise a user level VMM is not
able to control the value of MPIDR_EL1 that the guest VM reads.

Signed-off-by: Kent McLeod <kent@kry10.com>
2024-03-14 10:02:42 +01:00
Indan Zupancic
3ccbfc083a RISC-V SMP: Fix Compile Error
Partially revert commit 70d1a5f792.

Can't include arch/machine.h because that will cause
a circular include dependency.

Signed-off-by: Indan Zupancic <indan@nul.nu>
2024-03-13 19:19:39 +01:00
Axel Heider
70d1a5f792 riscv: add read_sscratch()
Signed-off-by: Axel Heider <axelheider@gmx.de>
2024-03-13 11:38:24 +00:00
Rafal Kolanski
c9989664e3 AArch64: mark isFpuEnable as DONT_TRANSLATE
Current verification model does not include lazy FPU switching, i.e. it
acts as if this function always returns true, so no FPU faults could be
produced. In order to guard against deriving a contradiction, we don't
allow the C parser to translate it.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2024-02-02 09:14:07 +11:00
Gerwin Klein
cc3205ea48 aarch64/vspace: simplify check for page PTE
- directly test for page PTE types instead of testing for invalid etc.

- remove unnecessary condition `resolve_ret.ptBitsLeft > PAGE_BITS`
  (always true).

- reduce bitfield accesses via pointers to make verification easier.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2024-01-22 14:58:49 +11:00
Gerwin Klein
7f4662a791 Revert "aarch64/vspace: allow flushing larger .."
This reverts commit 494dd2dd96.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2024-01-22 14:58:49 +11:00
Gerwin Klein
494dd2dd96 aarch64/vspace: allow flushing larger pages
- The failure condition `resolve_ret.ptBitsLeft > PAGE_BITS` prevented
  larger page sizes from being flushed in VSpaceRoot invocations.

  Instead of testing for number of bits left to resolve, simply check
  the PTE whether it is a page or not.

- reduce bitfield accesses via pointers to make verification a bit
  easier.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2024-01-22 11:29:04 +11:00
Gerwin Klein
4a2f8e7a81 aarch64 structures: constrain irq_w field width
The rest of the code uses 9-bit irq width. Keep in sync here to ease
verification.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2024-01-16 10:55:41 +11:00
Rafal Kolanski
55aee64707 arm hyp: gic_vcpu_num_list_regs should be word_t
On AArch64, if this is int, we encounter a situation where we can't
prove equivalence with the abstract spec without an extra invariant that
the number of these registers isn't zero (to satisfy 32<->64 bit casts).
Sticking with word size will make sense on both 32 and 64 bit.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2023-12-06 03:23:49 +11:00
Rafal Kolanski
66e5c79d06 Arm 64-bit: do not use unsigned int for arg length
Arch_decodeInvocation takes a word_t length and then passes it to
functions that take an unsigned int length. This was OK on 32-bit where
these types are the same, but on 64-bit this is a downcast without a
range check. It isn't clear why this doesn't trip a compiler warning.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2023-12-06 03:23:49 +11:00
Axel Heider
7d93471e9c debug: use c99 standard instead of gcc extensions
Signed-off-by: Axel Heider <axelheider@gmx.de>
2023-11-16 12:09:52 +00:00
Ivan-Velickovic
49e5f47041 Update PLIC handling for Star64/U74-MC
Similarly to the U54-MC, the U74-MC has a S-core that does not run in
supervisor mode.

Signed-off-by: Ivan-Velickovic <i.velickovic@unsw.edu.au>
2023-11-08 14:34:18 +00:00
Ivan-Velickovic
e959f83962 Add support for Star64 SBC
Signed-off-by: Ivan-Velickovic <i.velickovic@unsw.edu.au>
2023-11-08 14:34:18 +00:00
Gerwin Klein
4b8bed320d arm_global: document deadline assert
The comment that PRECISION is too low when the assert fails was wrong.
PRECISION should have no influence on it.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-11-08 11:01:00 +11:00
Gerwin Klein
14ff0c28ec x86 setDeadline: must set at least 1 tick
- make sure the tick count does not underflow
- make sure the tick count does not become 0 in the division, because
  a value of 0 stops the timer.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-11-08 11:01:00 +11:00
Gerwin Klein
dac2857229 mcs: move setDeadline assertions
Move the ksCurTime assertions out of setDeadline, because they are not
necessarily true there. Assert ksCurTime in setNextInterrupt instead.

We only know that the deadline being set is at least ksCurTime -
getTimerPrecision(), which can be slightly in the past (ksCurTime is
already slightly in the past, at kernel entry).

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-11-08 11:01:00 +11:00
Michael McInerney
521f7e3c19 mcs: remove getKernelWcetTicks from refill_ready
Previously, a refill would be ready if its head time
was at most getKernelWcetTicks after the current time.
This would mean that refill_unblock_check could
bring a refill's time forward, which violates an
invariant (namely that the time of the last refill
is at most the period from the time of the head refill).

Moreover, since the time to exit the kernel is always
less than the WCET, this might result in us running
a thread whose refill time is in the future, which
seems to violate the timing model.

Signed-off-by: Michael McInerney <michael.mcinerney@proofcraft.systems>
2023-11-08 11:01:00 +11:00
Gerwin Klein
97588df016
mcs: simplify sc_sporadic, assert invariant
It is an invariant in the MCS kernel that scSporadic implies sc_active.
Make use of that invariant by avoiding an explicit check for sc_active,
but assert the invariant in debug mode so it fails quickly when new
code breaks the invariant.

Essentially reverts 56098195f2 now that the invariant is preserved,
but adjusts the assertion from 17109eb8c9 to actually express
the invariant.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-11-07 08:39:10 +11:00
Hesham Almatary
c2497cbb38 riscv: place traps and fastpath code adjacently
Follow Arm's code where it tries to place traps and vector
code adjacently in a 4KiB page to optimise performance
(through spatial cache locality).

Closes #1091

Signed-off-by: Hesham Almatary <hesham.almatary@cl.cam.ac.uk>
2023-11-02 09:36:28 +00:00
Rafal Kolanski
4f9b736526 aarch64: use VS prefix for vspace_cap fields
The vspace (top level PT) cap had non-standard names which were a bit
confusing to reason about. The name conflict with capPTBasePtr also
spits out fully-qualified names in verification.
This commit updates all the field names of vspace_cap to start with
"capVS" and updates all the call sites.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2023-10-27 10:25:37 +11:00
Indan Zupancic
b4592ebc97
ARM: No special handling for edge-triggered IRQs
Clearing the pending state only has an effect if the IRQ state is
active-and-pending, which happens for edge-triggered interrupts if
another edge happens on the IRQ line for the currently active
interrupt. This window is small enough to ignore, at worst user
space will get another notification, which is harmless.

If unnecessary notifications are unwanted, the pending state should
be cleared during seL4_IRQHandler_Ack(), as that covers a much bigger
window. However, edge-triggered interrupts are not expected to happen
often. Making all interrupt handling slightly faster and the code
simpler is the better trade-off.

Reading the GIC config word is very slow for GICv2, see pull #1107.

Signed-off-by: Indan Zupancic <indan@nul.nu>
2023-10-26 11:34:51 +01:00
Rafal Kolanski
908cac7202 aarch64: IS_PAGE_ALIGNED -> checkVPAlignment
Verification sees macros as the preprocessed C code. On other arches, we
have checkVPAlignment, but on AArch64 we had IS_PAGE_ALIGNED only. Since
this was the only use, this commit also removes IS_PAGE_ALIGNED in
favour of checkVPAlignment.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2023-10-26 10:52:01 +11:00
Rafal Kolanski
88c35852fc aarch64: performASIDPoolInvocation consistency
For verification purposes, use same arg names as other platforms, and
don't go through `_ptr_set_` from the bitfield generator (same as
RISC-V).

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2023-10-26 10:52:01 +11:00
Nick Spinale
c49ed7c152 boot: skip clock sync test on qemu-arm-virt
This sanity check does not pass reliably on qemu-arm-virt due to it
being a virtualized platform.

Signed-off-by: Nick Spinale <nick@nickspinale.com>
2023-10-24 20:38:43 +11:00
Michael McInerney
6de399dc65 mcs: rephrase refill_capacity to ease verification
Signed-off-by: Michael McInerney <michael.mcinerney@proofcraft.systems>
2023-10-24 08:43:03 +11:00
Rafal Kolanski
7221eba1b9 arm: tune vcpu/gic struct padding for verification
Verification requires packed C structures for reasoning. While we
previously updated `struct vcpu` to be packed on AArch32, on AArch64
`struct gicVCpuIface` needs extra padding.

This extra padding now aligns a previously un-aligned field on AArch32,
meaning that needs to go away, and the comment there adjusted.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2023-10-20 12:39:47 +11:00
Rafal Kolanski
a5cb1a86b4 aarch64: add MODIFIES for DONT_TRANSLATE ops
These were marked DONT_TRANSLATE due to 32-bit `__asm__` blocks which
verification can't handle, which resulted in MODIFIES proofs not being
generated.
This commit adds the obvious MODIFIES proofs for machine ops: nothing
gets modified by reading hardware registers, and writing them only
changes state that isn't in the model.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2023-10-19 00:01:07 +11:00
Kent McLeod
45bf84798c arm,smc: Handle revoke cap operations
Enable badged SMC capabilities to be revokable so that dynamic systems
can revoke badged capabilities that are handed out.

Signed-off-by: Kent McLeod <kent@kry10.com>
2023-08-27 11:44:51 +10:00
Alex Pavey
7d029e56e2 smc_cap: Add badge handling to smc cap
Signed-off-by: Alex Pavey <Alex.Pavey@dornerworks.com>
2023-08-27 11:44:51 +10:00
Alex Pavey
e62bc9bba3 smc_cap: Add SMC Capability with Call method
See PR at https://github.com/seL4/seL4/pull/701

Signed-off-by: Robbie VanVossen <robert.vanvossen@dornerworks.com>
2023-08-27 11:44:51 +10:00
Axel Heider
4d77c7008f boot: Remove constant BI_FRAME_SIZE_BITS
Use seL4_BootInfoFrameSizeBits directly.

Signed-off-by: Axel Heider <axelheider@gmx.de>
2023-08-23 15:10:32 +02:00
Axel Heider
b8c0b1cb02 boot: introduce seL4_BootInfoFrameSize
Provide seL4_BootInfoFrameSize (and seL4_BootInfoFrameBits) for
userland, to there is no longer a need to hard-code the 4 KiByte
assumption.

Signed-off-by: Axel Heider <axelheider@gmx.de>
2023-08-23 15:10:32 +02:00
Rafal Kolanski
8153bc569e aarch64: avoid void-return statements
C parser has issues with `return f(...)` when f's return type is void.
Rephrase `vcpu_hw_write_reg` to look like its AArch32 equivalent, using
`break` in the switch statement.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2023-08-22 18:36:05 +10:00
Rafal Kolanski
d06eb0a81a aarch64: DONT_TRANSLATE 32-bit __asm__
Verification infrastructure can only handle word-sized variable access
in __asm__ statements. The following functions use 32-bit access on a
64-bit arch and are now marked DONT_TRANSLATE:
* readCIDR
* writeCIDR
* readAFSR0
* writeAFSR0
* readAFSR1
* writeAFSR1
* readESR
* writeESR
* readISR
* vcpu_init_vtcr

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2023-08-22 18:36:05 +10:00
Axel Heider
aa118c25b8 use types time_t and tickts_t properly
Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
2023-08-14 15:41:57 +10:00
Axel Heider
cbad541120 doc: improve comments
Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
2023-08-14 15:41:57 +10:00
Axel Heider
1ca227a1b5 boot: simplify boot code recycling
Add helper functions to get kernel image location. This removes any
dependencies from the rest of the code on symbols and defines. It
also avoid passing a parameter though various functions.

Signed-off-by: Axel Heider <axelheider@gmx.de>
2023-08-13 09:04:26 +10:00
Mathieu Mirmont
f2428d2b29 x86: include apic.h instead of xapic.h
Incuding apic.h also gets x2apic.h included.

Signed-off-by: Mathieu Mirmont <mat@parad0x.org>
2023-08-13 09:02:57 +10:00
Ivan-Velickovic
6904039608 Read time directly on RISC-V platforms
Currently getting the timestamp for RISC-V platforms uses the
`rdtime` pseudo-instruction which ends up invoking OpenSBI
and then accessing the CLINT memory-mapped `mtime` register.
This patch eliminates the use of `rdtime` in favour of
directly getting the timestamp for performance.

Signed-off-by: Ivan-Velickovic <i.velickovic@unsw.edu.au>
2023-08-13 09:01:48 +10:00
Kent McLeod
cb8ee83f0c aarch64,vspace: Remove pud cap type
Now the vspace_cap is used for all vspace roots and all other page
tables are referred to by page table caps.

Signed-off-by: Kent McLeod <kent@kry10.com>
2023-08-10 08:20:22 +10:00
Kent McLeod
dc808b3d76 aarch64,vspace: Rename pgd cap to vspace cap
This is already what's presented at userlevel. Now the underlying kernel
cap reflects the same name.

Signed-off-by: Kent McLeod <kent@kry10.com>
2023-08-10 08:20:22 +10:00
Kent McLeod
b3cc852425 aarch64,vspace: Remove page_directory captype
The page_table cap is used in it's place.

Signed-off-by: Kent McLeod <kent@kry10.com>
2023-08-10 08:20:22 +10:00
Kent McLeod
5b00dff656 aarch64,vspace: Merge pgde_t type into pte_t type
Finish combining different page table types into a single type.

Signed-off-by: Kent McLeod <kent@kry10.com>
2023-08-10 08:20:22 +10:00
Kent McLeod
fc4ee3f931 aarch64,vspace: Merge pude_t type into pte_t
Next step is to merge pude_t type.

Signed-off-by: Kent McLeod <kent@kry10.com>
2023-08-10 08:20:22 +10:00
Kent McLeod
dad370959f aarch64,vspace: Merge pde_t into pte_t
Remove the pde_t type and replace all usages with pte_t.
This doesn't remove the page directory cap type yet. Now the page
directory cap refers to a table of pte_t entries and is treated the same
as the object that a page table cap refers to.

Signed-off-by: Kent McLeod <kent@kry10.com>
2023-08-10 08:20:22 +10:00
Kent McLeod
629c60d0a0 aarch64,vspace: Setup single pte_t type
This first commit only handles 4k pages.
4k pages are mapped using level 3 descriptor formats which annoyingly
have an opposite type definition (bit[1]) from all other levels. At all
other levels, a bit value of 0 is page and 1 is table. At level 3, a bit
value of 1 is page (and there is no bit value for a table).

This prevents us from using a single tagged-union type definition for
all page table descriptor definitions. For now we treat 4k pages as
special and try and push on ahead with the single type definition
anyway.

Signed-off-by: Kent McLeod <kent@kry10.com>
2023-08-10 08:20:22 +10:00
Axel Heider
3c180701ee remove Arch_migrateTCB()
It does the same on all architectures, so the contents can be moved
into the generic code.

Signed-off-by: Axel Heider <axelheider@gmx.de>
2023-06-21 08:58:28 +10:00
Axel Heider
5091e5313d doc: fix typos
Co-authored-by: Ivan-Velickovic <i.velickovic@unsw.edu.au>
Signed-off-by: Axel Heider <axelheider@gmx.de>
2023-06-08 12:47:14 +10:00
Kent McLeod
7fec9bc9e9 Add CONFIG_X86_64_VTX_64BIT_GUESTS guards
Guard the new implementation of 64-bit x86 guests behind a config
option. This is done so that existing projects that use x86_64 hosts
with ia32-bit guests can continue to be supported until either the old
feature is preferred to be deprecated, or support can be added to
support both simmultaneously.

Signed-off-by: Kent McLeod <kent@kry10.com>
2023-06-06 13:29:34 +10:00
Chris Guikema
2dbd1b818a 64-bit-vms: Add kernel support for 64-bit VMs
This commit combines a number of smaller commits which do the following:

    * Enter IA-32e mode when running a 64-bit host
    * Handle additional general purpose registers in 64-bit mode
    * Handle 64-bit specific MSR events
    * Properly save and restore FS, GS, and Shadow GS registers

CCDC-GVSC DISTRIBUTION A.  Approved for public release; distribution
unlimited. OPSEC#4481.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-06-06 13:29:34 +10:00
Gerwin Klein
35c41a822f macros: avoid breaking C subset
__builtin_offsetof is not part of the verification C subset -- avoid
accidental use by not declaring a macro for it and filter out the
single use by explicitly marking it as invisible to verification.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-05-31 14:55:57 +10:00
Gerwin Klein
94d393418e gic_v3: _Static_assert is not supported
Prefer compile_assert over _Static_assert. The latter is only available
in C11, and the verification demands C99.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-05-31 13:30:07 +10:00
JorgeMVP
b544529615 generc_timer: enable only once for mcs/non-mcs
Enable the timer only at initialization and since it is always
enabled. It is not needed to be re-enabled.

Signed-off-by: JorgeMVP <jorgepereira89@gmail.com>
2023-05-25 20:42:02 +10:00
JorgeMVP
62c8148268 generic_timer: force timer to de-assert irq
Generic Timer IRQs are level-sensitive, when the CNT_TVAL
is updated the trigger condition is de-asserted and the
change is propagated to the GIC in a finite time to clear
the pending state.

However, we have to make sure the timer deasserts before
EOIR/DIR, otherwise the interrupt happens again. Therefore,
we need an isb() to cause the timer to de-assert before EOIR/DIR.

There is also a chance of spurious IRQ. A spurious IRQ can be
generated, in the case we have a level-sensitive IRQ, and its
pending state is cleared at device-level but not yet propagated
to the GIC. In between the IRQ deactivation and IRQ ack of the
new interrupt if the requested change from the timer gets propagated
then it causes a spurious IRQ.

Signed-off-by: JorgeMVP <jorgepereira89@gmail.com>
2023-05-25 20:42:02 +10:00
Ivan-Velickovic
8c9cf6c7db Remove VMKernelReadOnly from AArch64 VM rights
In the interest of stability and not breaking
things, the value of VMReadOnly remains the same.

Signed-off-by: Ivan-Velickovic <i.velickovic@unsw.edu.au>
2023-05-25 14:48:37 +10:00
JorgeMVP
a681fb9755 gic_v3: AP1R for group 1 IRQs
- In non-secure world, group 1 IRQs are used instead of group 0.
Signed-off-by: JorgeMVP <jorgepereira89@gmail.com>
2023-05-08 20:46:22 +10:00
Kent McLeod
8402de52db aarch64: Add option for user cache maintenance
Add a config option, KernelAArch64UserCacheEnable, that enables user
level access to DC CVAU, DC CIVAC, DC CVAC, and IC IVAU which are cache
maintenance operations for the data caches and instruction caches
underlying Normal memory and also access to the read-only cache-type
register CTR_EL0 that provides cache type information. The ArmV8-A
architecture allows access from EL0 as fast cache maintenance operations
improves DMA performance in user-level device drivers.

These instructions are a subset of the available cache maintenance
instructions as they can only address lines by virtual address (VA).
They also require that the VA provided referrs to a valid mapping
with at least read permissions. This corresponds to lines that the
EL0 could already affect via regular operation and so it's not expected
to break any cache-partitioning scheme.

The config option allows this policy to be selected for a particular
kernel configuration, but it is default enabled as this has been the
existing behavior for current aarch64,hyp configurations and have not
been explicitly disabled in non-hyp configurations.

Signed-off-by: Kent McLeod <kent@kry10.com>
2023-04-25 15:49:28 +10:00
Kent McLeod
57ca89d68e trivial: Fix typo of UCT bit in SCTLR_EL1
Signed-off-by: Kent McLeod <kent@kry10.com>
2023-04-25 15:49:28 +10:00
Axel Heider
55dc30b4a6 boot/risc-v: avoid uncommon fence usage
Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
2023-04-23 22:26:19 +10:00
JorgeMVP
b8f1753d64 ipi: add missing barrier and enforce completion
- dmb() no longer works for GICv3, and consequently
a stronger barrier like dsb() has to be used. A weaker
variant of dsb is used to ensure the observability of
complete stores in the same inner-shareable domain.

Signed-off-by: JorgeMVP <jorgepereira89@gmail.com>
2023-04-23 15:00:48 +10:00
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
Axel Heider
d9159cfe3f trivial: fix typos
Signed-off-by: Axel Heider <axelheider@gmx.de>
2022-02-27 13:10:34 +11:00
Bin Meng
2082aa4e30 trivial: Convert UTF-8 character to ASCII
When building seL4 on a host whose default encoding is not UTF-8,
tools/bitfield_gen.py complains, as with the following log from
Python 3.6 on a Ubuntu 18.04 host says:

  Traceback (most recent call last):
    File "tools/bitfield_gen.py",
  line 2773, in <module>
      string = f.read()
    File "/usr/lib/python3.6/encodings/ascii.py", line 26, in decode
      return codecs.ascii_decode(input, self.errors)[0]
  UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position
  607543: ordinal not in range(128)

As the Python 3 doc for open() [1] says the default encoding is
platform dependent, such build error may happen on some hosts.
We can either updating tools/bitfield_gen.py to call open() with
an explicit encoding="utf-8" parameter, or avoiding UTF-8 characters
in the source codes.

After inspecting the two places in current source tree that use UTF-8
characters, none of them is absolutely necessary. Let's convert them
to ASCII characters.

[1] https://docs.python.org/3.6/library/functions.html#open

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
2022-02-25 18:55:33 +11:00
Cao Jianlong
324f833a0d trivial: remove duplicate headers
Remove the duplicate objecttype.h in include/object.h

Signed-off-by: Cao Jianlong <caojianlong@outlook.com>
2022-02-05 15:30:25 +11:00
Rafal Kolanski
5e0c364c7d aarch64: verification VCPU tweaks
In `vcpu_enable` and `vcpu_disable`, use `setHCR` to wrap setting
REG_HCR_EL2 (similar to AArch32).
Reorder `vcpu_enable` to match AArch32 operation order for easier proof.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-02-04 15:19:18 +11:00
Axel Heider
8c16b4b94d risc-v: move C code out of hardware.h
Since hardware.h is shared with assembler code, it's better to avoid
having C ode in there. This also aligns the RISC-V port with the ARM
port, where machine.h contains the special register wrapper functions.

Signed-off-by: Axel Heider <axelheider@gmx.de>
2022-01-30 20:15:56 +11:00
Axel Heider
c3683ea60d benchmark: fail log buffer setup if not enabled
Signed-off-by: Axel Heider <axelheider@gmx.de>
2022-01-30 19:15:16 +11:00
Axel Heider
ba72022acb use _Static_assert() in kernel
Both gcc and clang provide this even for c99.

Signed-off-by: Axel Heider <axelheider@gmx.de>
2022-01-24 22:24:03 +11:00