4859 Commits

Author SHA1 Message Date
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
Corey Lewis
01c3487efd arm: flush vcpu when setting domain of a thread
Signed-off-by: Corey Lewis <corey.lewis@proofcraft.systems>
2025-11-16 19:52:27 +11:00
Corey Lewis
e558631c73 arm: flush vcpu when switching domain
This avoids information about vcpu state being leaked across domains.

Signed-off-by: Corey Lewis <corey.lewis@proofcraft.systems>
2025-11-16 19:52:27 +11:00
Corey Lewis
2734df9217 arm: remove misleading comment
The compile error for exposing vcpu_t could be easily fixed, the real
issue is the functions not existing when HYP is disabled.

Signed-off-by: Corey Lewis <corey.lewis@proofcraft.systems>
2025-11-16 19:52:27 +11:00
Gerwin Klein
e0fdf1c235 changelog: log vtx defect
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2025-11-13 11:45:09 +11:00
Liu, Chang
aa329f9476 x86: skip unaddressable memory for multiboot2
On 32-bit x86, when booting under multiboot1 the physical memories
above 4GB are skipped and not included as usable memory regions.
Make sure we also do this when booting under multiboot2.

Signed-off-by: Liu, Chang <cl91tp@gmail.com>
2025-11-11 11:37:49 +00:00
Julia Vassiliki
7099f9d543 aarch64: fixup address space layout docs for hyp
Fixes #957

I removed the notes about TK1 since it's not just TK1.

Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
2025-11-10 23:47:39 +00:00
Mathieu Mirmont
57a909f615 x86: fix VCPU object creation
VCPU objects are "physical" objects, as in they do use memory areas
allocated from Untyped.

Signed-off-by: Mathieu Mirmont <mat@neutrality.ch>
2025-11-07 10:07:39 +11:00
Julia Vassiliki
836ee89a0b cmake: fix style
Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
2025-11-03 11:35:46 +11:00
Julia Vassiliki
7f0c2f0c1f platforms: fix imx8mq board timer frequency
The i.MX8MQ platforms use a clock frequency of 8333333 rather
than the 8000000 value which the -MP and MM platforms do.

This caused booting seL4 on these platforms to always print

        Warning:  gpt_cntfrq 8333333, expected 8000000

which seems to have actually been a correct warning.

Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
2025-11-03 11:35:46 +11:00
Julia Vassiliki
3db39fd7bc am335/ompa3/bcm2837: compare irq & maxIRQ with <=
Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
2025-11-03 10:00:53 +11:00
Julia Vassiliki
3977e12b8b arm,gic-v3: fix GICD_CTLR_ARE_NS bit value
This reverts https://github.com/seL4/seL4/pull/1490 as the
change that was made in that PR was reading the wrong part
of the GIC specification, because ARM decided that the
register layouts are different in non-secure vs secure mode.

Fixes (again) https://github.com/seL4/seL4/issues/1489

Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
2025-10-30 13:20:40 +00:00
Julia Vassiliki
70c75b956e aarch64: improve kernel address space layout docs
These diagrams were really unclear and confusing to me,
especially as I always needed to convert from "2^64 - 2^39"
form to "0x0000008000000000" form many times in my head.

They were also out of date and wrong, containing graphics of the
PDPT (from x86) as well as TLB bitmaps.

Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
2025-10-28 11:14:27 +00:00
Julia Vassiliki
0f058d05db aarch64: keep EL2 docs near hypervisor config
Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
2025-10-28 11:14:27 +00:00
Gerwin Klein
8d3313ac25 trivial: adjust style for new cmake-format
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2025-10-24 09:41:03 +11:00
Nick Spinale
d310f5f137 cmake: record all disabled options
Before this change, options that were hidden from the cmake-gui due to
unsatisfied config_choice conditions were not recorded in
gen_config.{yaml,json,h}. After this change, these hidden options are
recorded as disabled.

Signed-off-by: Nick Spinale <nick@nickspinale.com>
2025-10-24 09:41:03 +11:00
julia
f9eb65c9a5 tools: don't exclude device-tree reserved memory
... from the device UT listed by platform_gen. The kernel itself
does not care about this memory, and it is just given as device UT.

We also just remove the reserved array entirely from the return of
`get_physical_memory` since it only seems to be a footgun, it's
only used internally to affect what memory the kernel wants to use.

Co-authored-by: Kent McLeod <kent@kry10.com>
Signed-off-by: julia <git.ts@trainwit.ch>
2025-10-16 11:05:15 +01:00
julia
97b25da8b1 tools: keep align-reserved memory in 'devices'
`align_memory()` in hardware.py both modifies the first normal memory
region to adjust the base of it for alignment, and adds an extra
reserved region to our list of reserved regions. This then feeds
through `get_addrspace_exclude` which inverts the regions given
and turns it into the available "device memory" at user-level.

    dev_mem = hardware.utils.memory.get_addrspace_exclude(
        list(reserved) + phys_mem + kernel_devs, config)

Anything as an argument to this is not given as "device memory" by
the kernel. (It does not precisely match how the kernel works).

However, since `align_memory()` has adjusted both the phys_mem up
(which *would* have added this region as "device" memory) but also
added it to "reserved" region, which then made it disappear entirely,
as "reserved" regions are not exposed to userspace.

However, this **does not** match the behaviour of the kernel, as it was
not reserved, so this behaviour did not match the untypeds given to
userspace. This commit solves this by removing the extra reserved
region being added for that memory.

PR #1426 worked around this issue by removing the alignment on AArch64.
Whilst this fixed the issue that microkit was seeing, it just masked
the underlying issue. Reverting that PR, then applying this fix,
results in the following platform_gen.yaml:

    devices:
    - end: 0x1000000
      start: 0x0
    - end: 0xff800000
      start: 0x3b400000
    - end: 0xff841000
      start: 0xff801000
    - end: 0x100000000000
      start: 0xff843000
    memory:
    - end: 0x3b400000
      start: 0x1000000

Note especially the device region from 0x0 to 0x1000000; which is the
combination of the 0x0 to 0x1000 reserved region, and the 0x1000 to
0x1000000 reserved by the kernel's alignment requirement. Previously,
the platform_gen.yaml reported only the 0x0 to 0x1000 region,

    devices:
    - end: 0x1000
      start: 0x0
    - end: 0xff800000
      start: 0x3b400000
    - end: 0xff841000
      start: 0xff801000
    - end: 0x100000000000
      start: 0xff843000
    memory:
    - end: 0x3b400000
      start: 0x1000000

I will be following this commit up with a PR to instead make the
alignment-reserved region into a new memory region, since there's not
any reason why userspace can't use this memory.

This has been tested on a few platforms with sel4test and with
microkit on the pi4B.

Signed-off-by: julia <git.ts@trainwit.ch>
2025-10-16 11:05:15 +01:00
julia
2279b0dd33 trivial: use KERNEL_ELF_TOP over ki_end
Signed-off-by: julia <git.ts@trainwit.ch>
2025-10-15 11:59:16 +01:00
Gerwin Klein
b60b6652a4 arm,am335x: avoid continue for binary verification
The Isabelle side of the binary verification tool chain currently does
not implement proof tactics for the "continue" statement. Use skip
(semicolon) instead for empty loop body.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2025-10-10 14:36:43 +11:00
Gerwin Klein
0811613ed7 configs: add remaining verified Arm configs
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2025-10-10 14:36:43 +11:00
Gerwin Klein
08fb719ca2 arm,sgi: wrap NUM_SGIS for verification
Wrap NUM_SGIS using wrap_config_set() so that verification automation
does not simplify it away automatically when it is 0.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2025-10-10 14:36:43 +11:00
Gerwin Klein
0f78e4e957 syscall: handle spurious IRQ for preemption
Make the treatment of spurious IRQs equal between handleInterruptEntry
and preemption handling. The infoflow proof requires that these behave
identically -- this was so far only true for platforms that define
handleSpuriousIRQ to be empty (which is almost all of them).

Adding platforms to the verification that have a non-empty body for
handleSpuriousIRQ requires equalising the calls.

Factor out the code that is common between preemption and interrupt
kernel entry into its own function checkInterrupt to remove duplication.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2025-10-10 14:36:43 +11:00
Gerwin Klein
73df5be82c machine: move setIRQTrigger into interrupt.h
Move setIRQTrigger from <arch>/hardware.h into interrupt.h together
with the rest of the IRQ interface, because it is now a visible
interface even for platforms and architectures that do not provide the
functionality.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2025-10-10 14:36:43 +11:00
Gerwin Klein
ec918cf123 arm,irq: use UNREACHBLE in unimplemented functions
UNREACHABLE instead of halt means the compiler can elide the function
from the binary.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2025-10-10 14:36:43 +11:00
Gerwin Klein
6c7a376200 arm: default setIRQTrigger for non-GIC platforms
Provide a default dummy implementation for setIRQTrigger even for
non-GIC platforms where this operation is not supported. Otherwise,
the function is declared in the header, but has no implementation.

Implementing it as UNREACHABLE() means verification will show that the
function is not called.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2025-10-10 14:36:43 +11:00
Gerwin Klein
eaed120175 util: provide FNSPEC for __unreachable
Adding a spec with precondition False means verification has to show
that the function is not called.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2025-10-10 14:36:43 +11:00
Gerwin Klein
40c4ad5112 arm: plat_SGITargetValid for non-GIC platforms
Provide an implementation of the header function plat_SGITargetValid
even for non-GIC platforms. This function will not be called, but
verification has a general lemma about it, and the default
implementation makes that lemma true without adding special cases.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2025-10-10 14:36:43 +11:00
Gerwin Klein
5e08006c48 arm: improve error for unsupported IssueSGISignal
Fail early with IllegalOperation if IssueSGISignal is not supported at
all for the platform.

This also helps with verification, because the later range check gets
simplified away automatically, leading to divergent code paths.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2025-10-10 14:36:43 +11:00
Gerwin Klein
9d17561157 arm: make HAVE_SET_TRIGGER visible to verification
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2025-10-10 14:36:43 +11:00
Indan Zupancic
a117712c19 Make fastpath_restore match restore_user_context
Mostly call c_exit_hook() with global lock held.

Signed-off-by: Indan Zupancic <indan@nul.nu>
2025-10-09 10:31:01 +01:00
julia
09e6c3f5e2 debug: invalidate ksKernelEntry on kernel exit
There's a few cases in the kernel where the ksKernelEntry tracking
is not perfect, such as in SError reporting, and (I believe) a few
other places which I haven't tracked down to a cause - but some of
e.g. the RISC-V trap code where the first entry faults and the 2nd
proceeds can report stale information.

In these cases, the kernel says that the entry was via a certain
syscall or interrupt (etc), even though that was clearly not the
case because we know the kernel exited. Now we will print out this:

    halting...
    Kernel entry via Unknown (0)

The changes:

- When exiting the kernel, via `c_exit_hook()`, reset
  `ksKernelEntry.path` to "Unknown".

  An alternative here would have been add a global "valid" boolean
  to the kernel state, but this requires modifying every site where
  we set the ksKernelEntry.path to also set valid = true, which is
  ugly.

- Remove Entry_UnimplementedDevice from entry_type_t as it is never
  used, to leave enough room to add Entry_Unknown.

- Switch out the CONFIG_DEBUG_BUILD || BENCHMARK TRACK ENTRIES #if
  in the x86 breakpoint code with the more concise
  `TRACK_KERNEL_ENTRIES` define used elsewhere.

Signed-off-by: julia <git.ts@trainwit.ch>
2025-08-20 15:57:58 +01:00
julia
f5e45a2453 trivial: arch/config.cmake style changes
Signed-off-by: julia <git.ts@trainwit.ch>
2025-08-19 09:06:24 +01:00
julia
5de930983b arm,riscv: eliminate idle_thread function prologue
Similar to #510 but for all other platforms. The idle_thread runs
without a stack and so cannot handle the stack prologue. This should
hopefully make the kernel rely less on FORCE_INLINE for this as well.

We create idle.S assembly files for each platform, as GCC does not
support `__attribute__((naked))` on AArch64 (GCC 13.2.0) and bails out.

Signed-off-by: julia <git.ts@trainwit.ch>
2025-08-19 09:06:24 +01:00
Gerwin Klein
dfaef4b712 arm: make irqInvalid static const
Helps the C compiler to recognise irqInvalid as a constant. This in
turn helps with binary verification, because irqInvalid is already
parsed as a constant in Isabelle since it is never written to.

See also the discussion in #1349 and #1324

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2025-08-15 12:16:46 +01:00
Gerwin Klein
db2b2be64c aarch32: make sure irqInvalid is irq_t
The GIC platforms use irq_t for irqInvalid -- bring remaining AArch32
platforms in line with that.

irq_t is an unsigned type (when it is an integer) and enum constants are
signed. For the proofs to treat these platforms uniformly, they need to
be the same kind. They can't all be enums, because irq_t can be a more
complex type for SMP platforms.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2025-08-15 12:16:46 +01:00
julia
736bfd6a2e asidpools: fix bug in create_it_asid_pool
This was *fine*, because IT_ASID has an ASID_HIGH(IT_ASID) of
0, but the asid_pool_cap_new expects capASIDBase which should
instead be an aligned ASID ID (i.e. asidLowBits all 0).

Signed-off-by: julia <git.ts@trainwit.ch>
2025-08-08 10:39:53 +01:00
julia
41c9e79dd1 asidpools: consistently use ASID_LOW macro
Signed-off-by: julia <git.ts@trainwit.ch>
2025-08-08 10:39:53 +01:00