Commit Graph

1316 Commits

Author SHA1 Message Date
julia 2580739bde libsel4test: check err type against unsigned char
On arm-none-elf-eabi-gcc, -fshort-enums is on by default and
is compatible with unsigned char (but not *signed* char) so we
need to add support for this to the test_op macros.

Also, _test_abort() when these type failures happen so that the
failure is more obviously an issue with the compiler/test setup,
not the tests themselves.

Signed-off-by: julia <git.ts@trainwit.ch>
2025-07-23 16:51:26 +10:00
julia b5f23dbffd libsel4test: static_assert sizeof() mismatches
This would previously fail at runtime, but we can fail the build
instead and catch this earlier.

In file included from /src/helpers.h:13,
                 from /src/tests/ipc.c:13:
/projects/sel4test/apps/sel4test-tests/src/tests/ipc.c:
  In function ‘test_ipc_pair’:
/projects/seL4_libs/libsel4test/include/sel4test/test.h:243:10:
  error: static assertion failed: "sizeof(res) does not match
         sizeof(SUCCESS), use of test_eq incorrect"

  243 |          _Static_assert(sizeof(_a) == sizeof(_b), \
      |          ^~~~~~~~~~~~~~

/projects/seL4_libs/libsel4test/include/sel4test/test.h:270:24:
  note: in expansion of macro ‘test_op’

  270 | #define test_eq(a, b)  test_op(a, b, ==)
      |                        ^~~~~~~

/projects/sel4test/apps/sel4test-tests/src/tests/ipc.c:347:25:
  note: in expansion of macro ‘test_eq’

  347 |                         test_eq(res, SUCCESS);
      |                         ^~~~~~~

Signed-off-by: julia <git.ts@trainwit.ch>
2025-07-23 16:51:26 +10:00
Indan Zupancic ff0fda6f18 Limit retain to Clang
Because of GCC bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99587
using has_attribute is not reliable and can give compile warnings
that will be turned into errors because of -Werror.

The retain atribute was added to support linking with LLVM's linker
by commit 12d0d9, as clang has LTO enabled by default, so limiting
it to CLang is fine until GCC enables LTO too.

Signed-off-by: Indan Zupancic <indan@nul.nu>
2025-07-22 14:27:39 +01:00
julia 959d4c38b8 use LibPlatSupportHaveTimer instead of inverse
As suggested by Indan to be clearer to understand.
https://github.com/seL4/util_libs/pull/196#issuecomment-2918974119

Signed-off-by: julia <git.ts@trainwit.ch>
2025-05-30 22:07:41 +01:00
julia 2c86e18705 libsel4platsupport: don't link nonexistent ltimers
If there is no ltimer for a particular platform, then these functions
do not exist, so make the init_default_timer_ops() always return
errors.

The intended way to avoid this is to not use the timer when
  CONFIG_LIB_PLAT_SUPPORT_NO_PLATFORM_LTIMER
is set.

Signed-off-by: julia <git.ts@trainwit.ch>
2025-04-01 11:30:13 +11:00
Gerwin Klein c45e3d0f33 github: use central CI workflows
Use GitHub workflow_call feature to reduce workflow duplication.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2025-03-17 11:37:27 +11:00
Kent McLeod 06527c27c7 libsel4muslcsys: Return error if 0 len requested
mmap is expected to return an error if a length of 0 is ever requested.

The caller is likely doing something wrong if a 0 length is requested
and it leads for hard to find bugs if we just return the current address
of the end of available memory.

Signed-off-by: Kent McLeod <1759184+kent-mcleod@users.noreply.github.com>
2025-03-05 14:09:07 +11:00
Kent McLeod d28e409727 libsel4muslcsys: Increase max syscall count
More linux syscalls have been added.

Signed-off-by: Kent McLeod <kent@kry10.com>
2025-02-28 12:33:23 +11:00
Kent McLeod c6413da396 sel4muslcsys: Fix up llseek on 32-bit arch
riscv32 linux abi doesn't define lseek. Instead llseek uses 2 32bit
arguments for a 64bit offset and returns the value via a pointer to
64bit value in user memory.

Instead of calling a syscall within a syscall, just make a shared
internal function to call for both lseek and llseek.

Signed-off-by: Kent McLeod <kent@kry10.com>
2025-02-28 12:33:23 +11:00
Peter Chubb 54539a72db Bump minimum CMake version
Compatibility with versions <3.10 is going away.
As it happens, we're not using any CMake features that
have changed between 3.7 and 3.16, so bump the lowest
version to 3.16.

Signed-off-by: Peter Chubb <Peter.Chubb@unsw.edu.au>
2025-02-26 14:34:53 +11:00
Szymon Duchniewicz e02296e40d sel4bench: Do not disable counters for armv7-a
The same scenario as for aarch64: If the cycle counter is disabled
during a read, the operation can be preempted and lose the count of
cycles for the duration of the preemption.
Issue: #34

Signed-off-by: Szymon Duchniewicz <s.duchniewicz@unsw.edu.au>
2025-02-22 23:11:03 +00:00
Hesham Almatary 12d0d9739f libsel4test: retain _test_type and _test_case
unused attribute does not prevent the sections from being
garbage-collected during link-time optimisation. This may trigger
undefined references errors to [__start|__stop]_test_case symbols
that are expected to be emitted by the linker anyway.

Adding "retain" attribute makes sure that the section and its
associated symbols are kept regardless of linker's garbage
collection. Another fix could be adding "nostart-stop-gc" to the
linker flags, but since it is only one section (_test_case)
where its __start/__stop symbols are references, adding retain to
it makes more sense. This additional functionality requires
binutils version 2.36 or later.

Sponsored by: DARPA.

Signed-off-by: Hesham Almatary <hesham.almatary@cl.cam.ac.uk>
2025-02-06 09:38:21 +11:00
Hesham Almatary 30781dfc00 libsel4utils: Fix TLS page fault if PT_PHDR exists
PT_PHDR is emitted by ld.lld but not ld.bfd. This segment should only
exist if the program header *is* part of the program memory image itself
(which is not the case in seL4, as it copies the program header in the
stack). This is important as muslc’s TLS init is relying on the existence
of PT_PHDR to get the base address of the image in memory and from that,
it calculates the TLS base for the source ELF. The calculation will be
wrong in seL4 as the program header is copied in the stack; thus it may
trigger a page fault if the new TLS base is not mapped, or affects the
integrity of programs relying on TLS variables (e.g., those with
__thread).

By setting PT_PHDR's segment to PT_NULL, muslc will skip this search and
won't do any relocations for the TLS segment which is part of the
loaded ELF image itself, thus getting the correct mapped address.

Sponsored by: DARPA.

Signed-off-by: Hesham Almatary <hesham.almatary@cl.cam.ac.uk>
2025-02-06 09:38:21 +11:00
Indan Zupancic d3d24dd818 Avoid garbage on stdout for first print
Caused by recursive stdio function calling.

Just use seL4_DebugPutString() directly to avoid any problems.

Signed-off-by: Indan Zupancic <indan@nul.nu>
2024-11-19 19:13:50 +00:00
chao an 88c761538b libsel4utils: remove unused environment setup
It is unnecessary to writing environment to the stack since the
target environment size is always 0.

Signed-off-by: chao an <anchao@xiaomi.com>
2024-09-09 20:01:25 +10:00
Axel Heider fcabdef370 CI: use proper step name
Signed-off-by: Axel Heider <axel.heider@codasip.com>
2024-04-15 09:29:06 +10:00
Axel Heider d749931829 CI: cancel older concurrent PR runs
Signed-off-by: Axel Heider <axelheider@gmx.de>
2024-04-10 09:49:52 +10:00
Axel Heider 23477c7ab5 libsel4allocman: fix clang warnings for printing
Signed-off-by: Axel Heider <axelheider@gmx.de>
2024-02-23 07:46:36 +11:00
Axel Heider 68db84e22a libsel4allocman: fix style issues
Signed-off-by: Axel Heider <axelheider@gmx.de>
2024-02-23 07:46:36 +11:00
Axel Heider f344301511 CI: simulation and HW build with LLVM on RISCV
Signed-off-by: Axel Heider <axelheider@gmx.de>
2024-01-12 09:22:03 +11:00
chao an 043999f481 libsel4platsupport: check num_pages after alloc
To avoid null pointer reference

Signed-off-by: chao an <anchao@xiaomi.com>
2023-11-20 10:12:58 +00:00
chao an 30a915aea5 libsel4utils: fix null pointer reference
add sanity check after alloc irq_server_t

Signed-off-by: chao an <anchao@xiaomi.com>
2023-11-20 10:04:51 +00:00
chao an 180a1a3941 libsel4utils: fix use of uninitialized value
thread_created maybe uninitialized if failure before initialize

Signed-off-by: chao an <anchao@xiaomi.com>
2023-11-02 15:58:37 +00:00
chao an d5fa7fe8a1 libsel4muslcsys: fix va list leak in failure case
va_start/va_end should call in pair

Signed-off-by: chao an <anchao@xiaomi.com>
2023-11-01 15:59:21 +00:00
Robbie VanVossen f8aabb6d63 simple: Update cap skipping for SMC
Need to update skipping caps since the SMC cap is only included
conditionally.

Signed-off-by: Robbie VanVossen <robert.vanvossen@dornerworks.com>
2023-09-13 18:04:32 +02:00
Robbie VanVossen b154d15874 libsel4test: Add smc cap to test env
This allows tests to have the initial smc cap when that
support is enabled.

Signed-off-by: Robbie VanVossen <robert.vanvossen@dornerworks.com>
2023-09-13 18:04:32 +02:00
Axel Heider 1f0336504b use seL4_BootInfoFrameSize
Drop hard-coding the 4 KiB assumption.

Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
2023-08-23 15:10:49 +02:00
Robbie VanVossen 173c80c7f4 trivial: Fix style
Signed-off-by: Robbie VanVossen <robert.vanvossen@dornerworks.com>
2023-08-12 14:42:15 +10:00
Robbie VanVossen 3be9f9465f simple: Define SIMPLE_SKIPPED_INIT_CAPS better
Make sure this macro is defined based on all possible configurations.
Also update simple_default_nth_cap() to skip based on all features
correctly.

Signed-off-by: Robbie VanVossen <robert.vanvossen@dornerworks.com>
2023-08-12 14:42:15 +10:00
Kent McLeod 310eace71f aarch64: Minimal update for vspace API change
The aarch64 vspace API is changed to only have a single pagetable object
and capability type for all intermediate page table levels. The root
vspace object is still a separate object and capability type.

Signed-off-by: Kent McLeod <kent@kry10.com>
2023-08-10 08:20:30 +10:00
Kent McLeod 24921e85cc allocman: Add error message for misconfiguration
Mis-configuring the watermark reserve pools can cause the allocator to
get stuck when needing to perform nested allocation and won't have
sufficient resources. It's a good idea to return an error when the
configuration API is misused causing a configuration request to be
ignored.

Signed-off-by: Kent McLeod <kent@kry10.com>
2023-05-13 17:15:02 +10:00
Kent McLeod 35ac7dbc31 allocman: Add missing calls to _end_operation
If either allocman_configure_mspace_reserve or
allocman_configure_utspace_reserve returns early it still needs to
end the started operation otherwise the allocator will be left in an
invalid state leading to it's watermarks never being refilled.

Signed-off-by: Kent McLeod <kent@kry10.com>
2023-05-13 17:15:02 +10:00
Axel Heider 2ca525429e libsel4bench: add support for ARM Cortex-A55
Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
2022-12-03 09:05:28 +11:00
Gerwin Klein 19cd448e8d trivial: make comment style-checker stable
For some reason astyle wants to indent the second line of the comment
by always another increment if the line does not start with its own
comment start marker. This change avoids that trigger.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-27 11:14:25 +11:00
Chris Guikema 6e4084b54f muslcsys: print warning when munmap is called
This commit registers a __NR_munmap call, which prevents the
"libsel4muslcsys: Error attempting syscall 215" error from printing.
This syscall is called when a large malloc'd region is freed, since mmap
uses a bump allocator where free is never expected to be called. Instead
of printing a generic warning, a descriptive error is printed which can
alert the user of any potential issues.

Signed-off-by: Chris Guikema <chris.guikema@dornerworks.com>
2022-10-27 11:14:25 +11:00
Chris Guikema 688dbb32e3 trivial: reduce verbosity of untyped lookup fail
Signed-off-by: Chris Guikema <chris.guikema@dornerworks.com>
2022-10-27 06:54:52 +11:00
Chris Guikema 0aa8d43fe5 sel4utils: update ifdef around map_iospace_page
This commit matches the ifdefs around map_iospace_page. It also checks
for the presence of the IOMMU, SMMU, or TK1_SMMU instead of
checking against an architecture.

Signed-off-by: Chris Guikema <chris.guikema@dornerworks.com>
2022-10-21 12:52:22 +11:00
Axel Heider 793456649c libsel4utils: use seL4_Time instead of uint64_t
Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
2022-10-03 12:20:06 +11:00
Kent McLeod c5a599ef6c sel4muslcsys: Allocate aligned addr in static mmap
It's invalid to return regions that are not page aligned. We round
lengths up to the nearest page size. munmap and mremmap are not
supported with static mmap and so we don't need to track this rounding
difference anywhere.

Signed-off-by: Kent McLeod <kent@kry10.com>
2022-06-16 14:30:55 +10:00
Kent McLeod cf6f9177da libsel4muslcsys,mmap: Assert page aligned value
mmap creates mappings in multiples of the page size which is always at
least 4096. Assert that the return value is at least page size aligned.
Callers of mmap are allowed to assume that the memory returned is 4k
aligned and this can lead to subtle errors if non-aligned values are
returned.

Signed-off-by: Kent McLeod <kent@kry10.com>
2022-05-19 12:05:29 +10:00
Axel Heider f3a3cf4d4e libsel4muslcsys: use const for CPIO data
CPIO data cannot be modified, it's basically ROM. The CPIO APIs have
been changed some time back to use the const qualifier to properly
reflect this. Add the const qualifier here also to avoid compiler
warnings.

Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
2022-04-26 11:59:11 +02:00
Axel Heider d9e53b132c libsel4utils: remove obsolete includes
These include files are deprecated for a long time already.

Signed-off-by: Axel Heider <axelheider@gmx.de>
2022-03-24 15:52:42 +11:00
Axel Heider 2ff5819ebf trivial: fix style issues
Signed-off-by: Axel Heider <axelheider@gmx.de>
2022-03-24 15:52:42 +11:00
Carmelo Pintaudi d8ae2c44e9 Remove assert in sys_io.c::sys_close()
There we assert that the only file type admitted is FILE_TYPE_CPIO,
however libsel4camkes implements support to FILE_TYPE_SOCKET.

Signed-off-by: Carmelo Pintaudi <carmelo.pintaudi@hensoldt-cyber.de>
2021-12-20 09:47:13 +11:00
Kent McLeod 0e0cfb670d trivial: Fixup compiler warnings
- Use seL4_Word printf modifier for seL4_CPtr type.
- Cast return value to (seL4_Error) as the API defines custom error
  codes starting after the seL4_Error enum finishes.

Signed-off-by: Kent McLeod <kent@kry10.com>
2021-12-08 15:25:55 +11:00
Kent McLeod bc943c9917 sel4debug,caps: Use the write print modifer
Use the correct libsel4 print modifier for the seL4 type.

Signed-off-by: Kent McLeod <kent@kry10.com>
2021-11-28 15:01:43 +11:00
Kent McLeod e09ca43881 sel4debug,backtrace: Resolve attribute warning
Clang warns that this attribute was being ignored.

Signed-off-by: Kent McLeod <kent@kry10.com>
2021-11-28 15:01:43 +11:00
Kent McLeod 14d3c94f51 .github: Remove ARMv6 tests
ARMv6 is no longer supported.

Signed-off-by: Kent McLeod <kent@kry10.com>
2021-09-30 18:11:23 +10:00
Kent McLeod 1a065ff822 libsel4bench: Remove ARMv6 and arm1136jf-s support
Remove support for ARMv6 and the only CPU we support for that
architecture. This is because support is being removed from the kernel
after removal of the only ARMv6 platform, kzm/imx31.

Signed-off-by: Kent McLeod <kent@kry10.com>
2021-09-30 18:11:23 +10:00
Gerwin Klein 3678de2c63 github: style check on diff only for this repo
This repository is not yet fully style-clean, and the policy is to
update files as we touch them, not in one big go. Until we have reached
a fully style-clean state, we should check only the diff on push, not
all files.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2021-09-13 14:31:38 +10:00