4846 Commits

Author SHA1 Message Date
Michael McInerney
efd9426e17 mcs: use local variable in restart
This eases verification by using a local variable
which remains unchanged during execution of the
function.

This preserves semantics since refill_unblock_check
will not modify the tcbSchedContext field of any TCB.

Signed-off-by: Michael McInerney <michael.mcinerney@proofcraft.systems>
2026-02-26 10:38:21 +11:00
Julia Vassiliki
b5cc70d753 libsel4: make thread-local ipc buffer optional
At the moment, the seL4 microkit does not setup TLS variable
support. The workaround has been to `#define __thread` (blank)
before including `<sel4/sel4.h>` in `<microkit.h>`, which causes
issues if `<microkit.h>` is included *after* `<sel4/sel4.h>`,
often with obscure linker errors to `__emutls_**` symbols.

Instead we add a libsel4 config option that allows us to build
it with __thread copied out. We introduce an LIBSEL4_THREAD_LOCAL
macro in a similar way to the existing LIBSEL4_INLINE macro.

Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
2026-02-25 11:46:23 +00:00
Julia Vassiliki
b5d53702d4 trivial: adjust style for cmake-format
Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
2026-02-25 11:46:23 +00:00
Indan Zupancic
7dc04b9a4c Arm SMMU: Set CB_INVALID for initial task
Zero is a valid context id.

capVSMappedCB is only checked on VSpace deletion.

Signed-off-by: Indan Zupancic <indan@nul.nu>
2026-02-20 20:36:02 +00:00
Gerwin Klein
56b42cf87e github: update Isabelle branch for MCS proofs
MCS proofs are now also running on Isabelle2025.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2026-02-18 13:52:09 +11:00
Gerwin Klein
3cb4dc0665 trivial: update cmake style
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2026-02-16 14:50:05 +11:00
Gerwin Klein
d4a8aac853 arm,smc: verification refactor of decode/invoke
- Factor out the inline assembly from invokeSMCCall so that it can be
  made a separate machine operation in the specification. This part of
  the change should produce the same binary as before.
- Parse IPC buffer arguments in decode, not in invoke. This eliminates
  the "buffer" argument to the invoke function and keeps argument
  processing in decode.
- Use setMR instead of replicating its functionality.
- Reduce decode argument list to the ones that are used.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2026-02-16 14:50:05 +11:00
Gerwin Klein
100f76565f arm,smc: switch statement cleanup
No change to behaviour, the commit just makes sure all cases are
explicitly listed instead of falling through to default.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2026-02-16 14:50:05 +11:00
Gerwin Klein
d2341c88d9 arm,smc: set SMC to on for verified AArch64
The AArch64 kernel now has verification support for SMC caps. Remove
dependency of KernelAllowSMCCalls on "NOT KernelVerificationBuild" and
set KernelAllowSMCCalls to ON by default for AArch64 verification
builds.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2026-02-16 14:50:05 +11:00
Michael McInerney
d16c975677 mcs: refactor finaliseCap to ease verification
This in particular introduces the function
schedContext_unbindReply, which is used within
finaliseCap, as well as invokeSchedContext_Unbind.

Signed-off-by: Michael McInerney <michael.mcinerney@proofcraft.systems>
2026-02-16 14:13:14 +11:00
Michael McInerney
8d569b8e65 mcs: refactor decodeSchedControl_ConfigureFlags
Done in order to ensure overflow does not occur. More
specifically, we call usToTicks on an argument only
when it has been checked to be at most MAX_PERIOD_US,
so that we know that overflow does not occur as a
result of the conversion. We also rephrase the check
on extra_refills. Rather than performing an addition,
which may in extreme cases overflow, we perform a
subtraction, which we know does not underflow, as a
result of our invariants.

Signed-off-by: Michael McInerney <michael.mcinerney@proofcraft.systems>
2026-02-12 10:36:36 +11:00
Julia Vassiliki
c55f50b6e5 manual: correct alignment of IPC buffer
Not all platforms are 512-byte aligned. Specifically, 64-bit
platforms are 1024-byte byte aligned.

Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
2026-01-30 12:13:59 +00:00
Ivan Velickovic
04db8cebcc x86: skip clock_sync_test on QEMU
Try detect if we are running as a guest based on the CPUID
and skip clock_sync_test if we are.

Similar as previous patches for skipping QEMU on ARM/RISC-V
but at run-time instead of build-time.

Tested with qemu-system-x86_64 using `-smp 4`, the test is now
skipped with regular QEMU as well as `-accel kvm`.

Signed-off-by: Ivan Velickovic <i.velickovic@unsw.edu.au>
2026-01-13 09:16:25 +10:00
Indan Zupancic
33636e983d Cleanup: Use fpuRelease
Instead of doing exactly the same.

Signed-off-by: Indan Zupancic <indan@nul.nu>
2026-01-12 11:08:45 +00:00
Indan Zupancic
c88c066a83 SMP: Only migrate when needed
schedContext_donate() is performance critical and should be fast,
but migrateTCB() assumes that there is a change in affinity and
calls fpuRelease() unconditionally, causing unnecessary FPU
saving and restoring.

Signed-off-by: Indan Zupancic <indan@nul.nu>
2026-01-12 11:08:45 +00:00
Bill Nguyen
1340539b10 manual: add seL4_X86_EPT_VMAttributes
Signed-off-by: Bill Nguyen <bill.nguyen@student.unsw.edu.au>
2026-01-09 16:52:09 +11:00
Bill Nguyen
2bdafbf7c3 libsel4: fix attribute type for x86 EPT invocation
Signed-off-by: Bill Nguyen <bill.nguyen@student.unsw.edu.au>
2026-01-09 16:52:09 +11:00
Gerwin Klein
d648c5dd53 trivial: align for better readability
White space change only:

- left-align sizes within each block declaration
- min 2 spaces to separate field name from size

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2026-01-09 09:00:43 +11:00
Gerwin Klein
c9f3c64162 bf structs: eliminate BF_CANONICAL_RANGE #ifdefs
Eliminate #ifdefs for BF_CANONICAL_RANGE in bitfield specifications,
using the new field_ptr command. Use word_size expressions for some of
the padding fields to make clearer where the sizes come from.

The transformations in this commit are written to produce exactly
identical output for code and proofs. In some rare cases, padding
could in the future be rearranged to make more use of field_ptr, but
these edits would create code differences and are left for later.

It may now also be to share more blocks between generic 32 and 64
definitions if they only reference word_size. This is also left for
later to reduce noise.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2026-01-09 09:00:43 +11:00
Gerwin Klein
e9c89bcac0 bfgen: add field_ptr(align) name size
Add the new block command

    field_ptr(align) name size

as an abbreviation for

    padding size - canonical + align
    field_high name canonical - align

The (align) part is optional. If left out, align is 0.

This is useful for removing #ifdefs for pointer storage that are trying
to achieve constant size over different canonical bit representations.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2026-01-09 09:00:43 +11:00
Gerwin Klein
29b63be21d bfgen: allow simple arithmetic integer expressions
Allow arithmetic integer expressions in all places where previously
only integer literals were allowed.

The operators +, -, *, / and % are supported. Additionally, in field,
field_high, and padding specifications, the constants "word_size" and
"canonical" are available.

This enables more readable bitfield specifications without changing
any of the code and proof generation. Produces identical output to
before.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2026-01-09 09:00:43 +11:00
Indan Zupancic
717cf90201 Aarch64: Drop ISBs in enableFpu/disableFpu
Doing an ISB is very expensive, about ~30 cycles on some CPUs,
so try to avoid them if possible.

For the writes to (most) system registers to be observed, a
'Context Synchronization event' needs to occur (see ARM DDI 0487
M.a §D24.1.2.2 / pD24-8367).

The kernel is not doing any FPU operations after disabling the FPU,
so there is never a need for an ISB there. Returning to user space
counts as a 'Context Synchronization event' and ensures the FPU enable
or disable has completed when user space starts executing.

An ISB after enabling the FPU is only needed in case the FPU was
disabled for the kernel and the kernel wants to do FPU operations
like saving or restoring the FPU state. The ISB ensures that the
FPU enable system register write is finished before FPU using
instructions are executed.

For Aarch64 non-HYP it is possible to disable the FPU for user space
(EL0), but keep it enabled for the kernel (EL1). This is done by
setting CPACR_EL1.FPEN to 1, which the code actually already did.

Aarch64 with virtualisation enabled is more complicated and needs
higher level changes to achieve the same, which aren't done here,
the change is limited to removing the ISB in disableFpu().

This partially fixes issue #1569.

Signed-off-by: Indan Zupancic <indan@nul.nu>
2025-12-19 00:57:04 +00:00
Seph Gentle
67f9a1002c x86: Added missing BOOT_CODE annotation
x86_cpuid_initialize was missing BOOT_CODE annotation.

Fixes #1575

Signed-off-by: Seph Gentle <me@josephg.com>
2025-12-18 14:16:52 +00:00
Indan Zupancic
78c3b11a02 FPU: Fix task enabling FPU for itself
There is no switchToThread() call when a task toggles
seL4_TCBFlag_fpuDisabled for itself, so the FPU stays
disabled even when it was just enabled.

The disable case was handled properly as fpuRelease()
does the right thing already.

Signed-off-by: Indan Zupancic <indan@nul.nu>
2025-12-18 13:53:17 +11:00
Jakub Duchniewicz
2bef61b9da Fix style
Signed-off-by: Jakub Duchniewicz <j.duchniewicz@gmail.com>
2025-12-10 09:05:02 +11:00
Jakub Duchniewicz
bce8202afe Rename the platform to uppercase
Signed-off-by: Jakub Duchniewicz <j.duchniewicz@gmail.com>
2025-12-10 09:05:02 +11:00
Jakub Duchniewicz
51f571efce Add support for rock3b
Signed-off-by: Jakub Duchniewicz <j.duchniewicz@unsw.edu.au>
2025-12-10 09:05:02 +11:00
Bill Nguyen
0fec79db4b x86: update deprecated message register define
Signed-off-by: Bill Nguyen <bill.nguyen@student.unsw.edu.au>
2025-12-08 23:09:51 +00:00
Bill Nguyen
704f80b9be libsel4: fix incorrect seL4_VMEnter() description
SEL4_VMENTER_CALL_CONTROL_ENTRY_MR refers to the
VM Entry Interruption-Information Field of the VMCS [1].
Not the VM-Entry Controls, which are two different things.

[1]: src/arch/x86/object/vcpu.c: vcpu_update_state_sysvmenter()

Signed-off-by: Bill Nguyen <bill.nguyen@student.unsw.edu.au>
2025-12-08 23:09:51 +00:00
Rihui Wu
b0567c4d1c benchmark: fix thread utils on riscv's fastpath
Signed-off-by: Rihui Wu <rihui.wu@unsw.edu.au>
2025-12-05 11:14:27 +00:00
Akif Ejaz
4f7d7b7376 Add support for the Banana Pi BPI-F3
Based on the SpacemiT K1 SoC

Signed-off-by: Akif Ejaz <akifejaz40@gmail.com>
2025-11-27 20:01:07 +01:00
Mathieu Mirmont
c0749e6227 x86_64: Fix boot code error reporting
Writing too quickly to a UART risks loosing bytes when its internal
FIFO fills up. Also lines should be terminated with "\r\n" for
compatibility with 1975 hardware.

Signed-off-by: Mathieu Mirmont <mat@neutrality.ch>
2025-11-25 15:42:26 +01:00
seL4 CI
233c984e3b Update VERSION file to 14.0.0-dev
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2025-11-25 09:35:53 +11:00
seL4 CI
c0fc32450f Release 14.0.0
Update VERSION
Update CHANGES.md

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
14.0.0
2025-11-25 09:33:58 +11:00
Ivan Velickovic
11c5d50527 Fix TCB size for SMP + benchmark config
In the definition of tcb_t, there's extra fields if there's
SMP or BENCHMARK_TRACK_UTILISATION or ARM_HYPERIVSOR_SUPPORT.
It looks like the combination of all three (which Microkit uses)
is not enough for 11 bits.

Signed-off-by: Ivan Velickovic <i.velickovic@unsw.edu.au>
2025-11-24 17:03:56 +10:00
Gerwin Klein
19b78543f9 arm: complete SGI error conditions documentation
- add missing error codes and explanations
- add not on target check limitations

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2025-11-24 16:56:46 +11:00
Gerwin Klein
f6e9ac2f9c CHANGES: change log for SGI caps
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2025-11-24 16:56:46 +11:00
Gerwin Klein
20253baa0b CHANGES: all Arm platforms now included in proofs
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2025-11-24 16:56:46 +11:00
Gerwin Klein
bfb390f918 CAVEATS: verification update; remove clang problem
- add new platforms supported by verification
- remove 32-bit imx8mm with FPU (proof out of date)
- add AArch64 integrity
- add FPU where covered
- remove caveat on lazy FPU and VCPU switching (fixed)
- remove caveat on SMP lock with clang (fixed)

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2025-11-24 10:28:33 +11:00
Gerwin Klein
3dbd033338 riscv: remove debug printing inside spuriousIRQ
Remove debug printing inside handleSpuriousIRQ() to get the
same behaviour as on the other architectures. Spurious IRQ reporting
already happens on the outside of this function.

The IRQ that is printed has to be irqInvalid (= 0 on RISC-V), because
that is when this function is called. RISC-V introduces an additional
case when irq > maxIRQ, which should not be possible (could
theoretically happen during a board port when maxIRQ is set
incorrectly).

The reason this IRQ printing is coming up now is that MCS (incorrectly)
calls preemption point handling when no IRQ has fired, but thread budget
has expired. This registers as spurious IRQ in preemption handling,
since no IRQ happened and getActiveIRQ correctly returns irqInvalid.

Generic spurious IRQ printing was disabled for this case on the outside
of this function (until the MCS behaviour is adjusted), but the special
RISC-V printing was not covered by that measure so far.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2025-11-22 11:50:40 +11:00
Nick Spinale
fdf7f2a082 trivial: adjust style for cmake-format
Signed-off-by: Nick Spinale <nick@nickspinale.com>
2025-11-21 17:37:27 +11:00
Nick Spinale
1955a9bda1 rpi4: Fix memory layout for for aarch32
Reduce seL4_UserTop to make space for everything in the kernel's virtual
address space.

Signed-off-by: Nick Spinale <nick@nickspinale.com>
2025-11-21 17:37:27 +11:00
Kent McLeod
1f77fb9c5a rpi4: Support building kernel for aarch32
When building for aarch32 only 32-bit physical addressing is supported.
An overlay is needed to clamp memory that extends above 32bit addresses.

Signed-off-by: Kent McLeod <kent@kry10.com>
2025-11-21 17:37:27 +11:00
Kent McLeod
9746e27615 aarch32: Allow compilation for cortex-a72
cortex-A72 can be run in aarch32 mode similar to cortex-a53.

Signed-off-by: Kent McLeod <kent@kry10.com>
2025-11-21 17:37:27 +11:00
Ivan Velickovic
0f497ab3a0 Disable clock sync test on QEMU RISC-V
This will sometimes fail when using QEMU RISC-V virt
with multiple cores, make the behaviour consistent as
QEMU ARM virt.

Given that QEMU is not intended to be a cycle accurate
simulator, I imagine that is why this does not reliably
succeed.

Signed-off-by: Ivan Velickovic <i.velickovic@unsw.edu.au>
2025-11-20 16:24:55 +11:00
Gerwin Klein
5f62269d84 arm,gic_v2: minor rephrasing for verification
The proofs are shared between GICv2 and GICv3, which means we want the
term structure to be the same for key functions that are visible to the
proofs (but constants are Ok to change).

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2025-11-20 08:05:46 +11:00
Gerwin Klein
e0abb976b5 CHANGES: change log entries from commit history
Add change log entries from commit history since tag 13.0.0.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2025-11-19 19:58:33 +11:00
Indan Zupancic
3cbd3b2e95 SGI, GICv3: Fix plat_SGITargetValid
Otherwise it is not possible to send SGIs to all cores on platforms
with non-contiguous Affinity values or more than 16 cores.

16 is the limit of the target list, which is only relevant when
sending an SGI to multiple targets at once.

Update the API documentation to reflect what's actually happening.

Signed-off-by: Indan Zupancic <indan@nul.nu>
2025-11-18 16:00:12 +11:00
Indan Zupancic
7e66128ba1 SMP: Update changelog
See PRs #871, #1413 and #1414 for details.

Signed-off-by: Indan Zupancic <indan@nul.nu>
2025-11-18 15:46:52 +11:00
Julia Vassiliki
17921dd38e mcs: hotfix for incorrect spurious IRQ reporting
This is a hotfix for issue #1540, an a less intrusive alternative
to #1544.

Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
2025-11-17 14:21:16 +11:00