Commit graph

3983 commits

Author SHA1 Message Date
Axel Heider
699a4cd803 boot: define NUM_RESERVED_REGIONS
- define NUM_RESERVED_REGIONS to align ARM and RSIC-V code
- add runtime checks to catch errors. These checks can't be static or
  use assert(), as the parameters are passed by a kernel loader. They
  must be considered dynamic and can potentially change any time out
  of the kernel's control.

Signed-off-by: Axel Heider <axelheider@gmx.de>
2021-09-26 09:50:53 +10:00
Axel Heider
415fb2090c boot/arm: add missing includes
Signed-off-by: Axel Heider <axelheider@gmx.de>
2021-09-26 09:50:53 +10:00
Axel Heider
d76f9f93a6 boot: improve comments
Signed-off-by: Axel Heider <axelheider@gmx.de>
2021-09-26 09:50:53 +10:00
Qiao Yongchang
e1fce5122e Change QEMU version check to FATAL_ERROR
Low version QEMU dump dts not have intc location information
and make subsequent generate dtb failed.

Error information:
Reference to non-existent node or label "/intc@8000000"

So when the QEMU version does not meet the requirements there
should be FATAL_ERROR to notice user early and immediately exit

Signed-off-by: Qiao Yongchang <qiaoyongchang@gmail.com>
2021-09-24 11:31:09 +10:00
Axel Heider
b384dc02af add missing includes
Using LIBSEL4_BIT() requires including sel4/macros.h.

Signed-off-by: Axel Heider <axelheider@gmx.de>
2021-09-22 12:15:37 +10:00
Axel Heider
d6b63832d1 remove goto in printf_core() and return directly
There is no need to keep an option for potentially debugging the error.

Signed-off-by: Axel Heider <axelheider@gmx.de>
2021-09-21 10:25:04 +10:00
laokz
2c64a01c26 trivial: fix warning of multiboot_mmap_length
In x86/boot_sys.c, we output a warning when `multiboot_mmap_length`
exceed limit. So we should correct its value after the `printf`.

close: #177

Signed-off-by: laokz <laokz@foxmail.com>
2021-09-20 17:22:51 +10:00
Axel Heider
91bfdf4b1c boot: simplify create_untypeds_for_region()
Simplify code and add comments.

Signed-off-by: Axel Heider <axelheider@gmx.de>
2021-09-20 16:49:11 +10:00
Axel Heider
5a47047233 boot: change order to improve debug output
Print the available physical memory regions before printing the reserved
virtual memory regions, because as this order is more intuitive. For the
checks the order does not make any difference. Factor out the checks
into separate function to improve code readability.

Signed-off-by: Axel Heider <axel.heider@hensoldt-cyber.de>
2021-09-14 21:09:10 +10:00
Ben Leslie
94269ed5be Remove unused PYTHON tool definition
python2 is not used in the kernel build anymore so the tool
definition is unnecessary.

python2 is also end-of-line so there is no reason to think
we would ever depend on it again.

Signed-off-by: Ben Leslie <benno@brkawy.com>
2021-09-14 16:09:33 +10:00
Ben Leslie
e11ef82663 Ensure execute_process is error checked
Check the return value from execute_process calls and fail
with an appropriate message.

This makes debugging of cmake failures much easier.

Signed-off-by: Ben Leslie <benno@brkawy.com>
2021-09-14 16:03:51 +10:00
Axel Heider
502dec1cd3 trivial: formatting, improve comments
Signed-off-by: Axel Heider <axel.heider@hensoldt-cyber.de>
2021-09-14 08:41:09 +10:00
Axel Heider
751198038a boot/risc-v: grab BKL on primary core for SMP
Ensure the primary core grabs the BKL once the generic kernel init is
done and the secondary cores are running. Improve the comments to
clarify that this is done to play safe.

Signed-off-by: Axel Heider <axel.heider@hensoldt-cyber.de>
2021-09-13 15:53:09 +10:00
Indan Zupancic
f3addaa0fb Trivial: Remove now incorrect comment
Signed-off-by: Indan Zupancic <Indan.Zupancic@mep-info.com>
2021-09-10 20:48:04 +10:00
Gerwin Klein
863ee83ca8 github: drop python2 tests
Since the build system defaults to python3 now, these have not worked
as advertised in a while now (they have test py3 twice).

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2021-09-09 08:43:56 +10:00
Indan Zupancic
e18e32e28e Allow Lazy SC Rebind
Before, binding a scheduling context to a TCB was not allowed if the
SC was bound to a notification object. Also, binding a SC to a NF was
not allowed if that scheduling context was already bound to a TCB.

Without these restriction it is much easier to move scheduling contexts
around: In effect having a SC bound on both the TCB and a NF acts as if
the thread is running on a donated SC which will be returned when the
tasks calls Recv/Wait, which is done by maybeReturnSchedContext().

This greatly simplifies startup and time-out exception handling for
passive threads having a NF with a SC bound to it.

Signed-off-by: Indan Zupancic <Indan.Zupancic@mep-info.com>
2021-09-08 07:56:47 +10:00
Indan Zupancic
fbb11221cf Document Lazy SC Rebind
Signed-off-by: Indan Zupancic <Indan.Zupancic@mep-info.com>
2021-09-08 07:56:47 +10:00
Indan Zupancic
0d2fac8b0a Fix spelling mistakes in threads.tex
Signed-off-by: Indan Zupancic <Indan.Zupancic@mep-info.com>
2021-09-08 07:56:47 +10:00
Bertrand Virfollet
b32b9568b2 tools: merge adjacent memory regions
Merge memory regions before checking for reserved areas

Co-authored-by: Gerwin Klein <gerwin.klein@proofcraft.systems>

Signed-off-by: Bertrand Virfollet <bvirfollet@silicom.fr>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2021-09-08 07:53:53 +10:00
Axel Heider
975f86b742 boot: unify insert_region() behavior
Unify ARM and RISC-V behavior for insert_region(). Print a message and
return an error in release builds, so the caller must decide what to do.
Debug build trigger an assert(),  because this is usually something that
should not happen.

Signed-off-by: Axel Heider <axelheider@gmx.de>
2021-09-07 20:10:14 +10:00
Axel Heider
6b8cbc96d1 risc-v: add comment about SBI constants
Explan the origin of the SBI constants.

Signed-off-by: Axel Heider <axel.heider@hensoldt-cyber.de>
2021-09-07 20:09:26 +10:00
Axel Heider
1bdf8d5a1b boot: improve user image location check
- On ARM systems, the UART must be set up first before any error
  messages are visible. Move the user image location check after
  the platform init that brings up the UART.
- Add the user image location check on RISC-V systems also.
- Make the error message more verbose to clearly show the problem.

Signed-off-by: Axel Heider <axel.heider@hensoldt-cyber.de>
2021-09-07 18:56:44 +10:00
Axel Heider
f8054d41dc risc-v: fix signature for Arch_setTLSRegister()
Signed-off-by: Axel Heider <axel.heider@hensoldt-cyber.de>
2021-09-07 15:56:31 +10:00
Gerwin Klein
646deeb4d4 trivial: update comment
The whole reason we have this comparison is that the user input has
not been checked yet when we get here.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2021-09-06 16:18:23 +10:00
Chris Guikema
805a031d55 libsel4: add EPT attributes
In x86, EPT and normal mappings have different cache attributes. This
commit adds an enum for the EPT attributes.

Signed-off-by: Chris Guikema <chris.guikema@dornerworks.com>
2021-09-06 16:18:23 +10:00
Ben Leslie
7f6f0008a9 Add additional cmake checks
Verify that KernelArch and KernelWordSize have been correctly
set after including the platform cmake files.

Signed-off-by: Ben Leslie <benno@brkawy.com>
2021-09-06 13:14:20 +10:00
Axel Heider
2f18705be0 boot: use helper variable to simplify code
- Improve comments about macros
- use helper variable to simplify code

Signed-off-by: Axel Heider <axelheider@gmx.de>
2021-09-06 09:22:04 +10:00
Axel Heider
543a09f435 trivial: style
Signed-off-by: Axel Heider <axelheider@gmx.de>
2021-09-06 09:22:04 +10:00
Axel Heider
dbda7046b9 Clarify assumptions about boot info frame size
- Improve comments
- allocate BI_FRAME_SIZE_BITS and not seL4_PageBits

Signed-off-by: Axel Heider <axelheider@gmx.de>
2021-09-06 09:22:04 +10:00
Kent McLeod
6bc0b06338 CMake: Add support for cmake install <dir> cmd
When using CMake to only build the kernel, an install target is now
provided to copy important outputs into an installation directory.

Currently only the following files are installed:
- ./bin/kernel.elf: Location of kernel.elf binary
- ./libsel4/include: The include root for libsel4
- ./libsel4/src: The c source files for the libsel4 library

To build and install this project to an installation directory should
now only require the following from a clean build directory:
```
export CMAKE_GENERATOR=Ninja
cmake -DCMAKE_INSTALL_PREFIX=<path-to-install> -DOption=Val <src-dir>;
cmake --build .;
cmake --install .;
```

Signed-off-by: Kent McLeod <kent@kry10.com>
2021-09-06 08:23:17 +10:00
Kent McLeod
fe96ceba17 gcc.cmake: Remove unused CMAKE_STAGING_PREFIX var
This path variable overrides the destination that installation files are
copied to. It was set according to an example CMake toolchain file.
Instead it would be better to allow it to be optionally set by some
caller.

Signed-off-by: Kent McLeod <kent@kry10.com>
2021-09-06 08:23:17 +10:00
Kent McLeod
87f5992d12 libsel4: def. CONFIG_KERNEL_LOG_BUFFER in autoconf
Define CONFIG_KERNEL_LOG_BUFFER in the same way as all other kernel
config options so that it is present in autoconf.h

Signed-off-by: Kent McLeod <kent@kry10.com>
2021-09-06 08:08:54 +10:00
Kent McLeod
c7d5bb0ed4 libsel4: Fix name for AARCH64_VSPACE_S2_START_L1
CONFIG_AARCH64_VSPACE_S2_START_L1 has the correct namespace for a kernel
config option.

Signed-off-by: Kent McLeod <kent@kry10.com>
2021-09-06 08:08:54 +10:00
Kent McLeod
b6de9db07a libsel4: Fix Config name for ENABLE_SMP_SUPPORT
CONFIG_ENABLE_SMP_SUPPORT has the correct namespace for a kernel config
option.

Signed-off-by: Kent McLeod <kent@kry10.com>
2021-09-06 08:08:54 +10:00
Kent McLeod
1d2a588bbf libsel4,config.h: Remove misleading #defines
autoconf.h is expected to contain all defined config options for an seL4
build configuration. Having these redefinitions were leftover from when
the verification build system didn't produce an autoconf.h file and set
the config separately.  Its more likely that these defaults would
incorrectly hide an include path misconfiguration and produce settings
that are inconsistent with the kernel's configuration.

Signed-off-by: Kent McLeod <kent@kry10.com>
2021-09-06 08:08:54 +10:00
Ben Leslie
5fb0a945bd Add 'x' bit to *verified.cmake
The verified.cmake files are designed to be executable scripts.
Ensure all have the 'x' bit.

Signed-off-by: Ben Leslie <benno@brkawy.com>
2021-09-03 14:39:28 +10:00
Alexander Fasching
560f215489
tools: Fix regex for ignore pattern (#535)
Signed-off-by: Alexander Fasching <fasching.a91@gmail.com>
2021-09-03 12:54:17 +10:00
Kent McLeod
e4262a90d2 arm,gic: GICv3 only supports max 16 list registers
Update GIC_VCPU_MAX_NUM_LR constant to reflect that only 16 list
registers are supported on GICv3. The kernel still reads the actual
number of supported list registers out of the GICH_VTR register so the
kernel would still do the right thing before this change.

Signed-off-by: Kent McLeod <kent@kry10.com>
2021-09-03 10:23:06 +10:00
Ben Leslie
0c6229d598 Add support for GICv3 virtualization
This adds sufficient kernel support for the GICv3 interrupt controller
to be used in a virtualization context on aarch64.

This set of changes has some limitations, however it is still an
improvement on the status quo.

Limitations:

1: This only provides support for aarch64. Anyone wanting support
for aarch32 + GICv3 + virtualization would need to add additional
code.

2: This code only supports 32 priority levels. Support for more
than 32 priority requires changing the get/set_gic_vcpu_ctrl_apr
interface. This is feasible, but requires a more invasive set of
changes. 32 priority levels has been shown to be sufficient in
practise.

Impacts on verification:

This set of changes should only impact Aarch64 Hypervisor
configurations. This is not yet verified so should not have
an impact on verification.

Level of testing:

This has been tested on an iMX8QXP based board. Testing
has at this point in time been limited to a single virtual
machine.

Note: support for this board is not yet upstrea, but is
currently being prepared.

Explanation of changes:

Ideally a new config item would not be required and this
could be driven purely by DTS and hardware.yml configuration.
However, the structures.bf requires changes. This can only
deal with config.h header files, not other more complex
header files. As such it was necessary to introduce a config
item which can be used for this purpose.

The appropriate platforms (as determined by examination of
DTS files) have been updated with the appropriate config
setting. This config setting only has any relevance if
hypervisor mode is already enabled, so should not cause
any difficulty for existing code or configuration.

Note: No testing has been performed on the updated
platforms.

There may be alternative factorings of this, which could
be considered in future work.

Signed-off-by: Ben Leslie <benno@brkawy.com>
2021-09-03 10:23:06 +10:00
Jimmy Brush
d653d9b2c6
Add missing error code in ARM IRQControlGetTrigger (#534)
Fixes #529

Signed-off-by: Jimmy Brush <code@jimmah.com>
2021-09-02 10:03:49 +10:00
Axel Heider
f46aac30b8 boot: remove ndks_boot.slot_pos_max
- The field 'slot_pos_max' from 'ndks_boot' is not needed, the value
  stored there is the constant BIT(CONFIG_ROOT_CNODE_SIZE_BITS).
- Improve the error message if the limit has been reached

Signed-off-by: Axel Heider <axelheider@gmx.de>
2021-09-02 08:44:24 +10:00
Gerwin Klein
a7b88f9378 x86 ioapic: make sure array is non-empty
CONFIG_MAX_NUM_IOAPIC can end up being 0 when the kernel is configured
as PIC-only. This code is then unreachable, but gcc-10 can't figure
that out and fails on array-out-of-bounds access (which would be
correct if the code were reachable).

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2021-09-01 16:34:26 +10:00
Gerwin Klein
2d0410b1ee vtx: fix EPT cache attribute setting
Credits for this one should go to clang-11, which correctly flags that
the big `||` always yielded true and was not doing what was intended.

This means, previously the only possible cache attribute for EPT was
EPTWriteBack.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2021-09-01 15:18:46 +10:00
Gerwin Klein
aec0f5a3f0 aarch64: make gcc-10 happy
The option -mno-outline-atomics used to be default before gcc-10 and
now needs to be provided explicitly. Without it gcc will produce
references to `__aarch64_ldadd8_acq_rel` which it expects to exist
in libgcc which we are not linking against.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2021-08-31 16:37:11 +10:00
Gerwin Klein
e3c2dbb26b docs: add link explaining license implications
Adding a link to Gernot's blog post that explains what GPL on seL4
means for other code. This is mainly intended for people who aren't
that familiar with what all of these licenses mean.

Closes #524

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2021-08-31 14:31:11 +10:00
Gerwin Klein
55cf30c8b1 trivial: use #ifdef instead of #if
`#if` fails if the symbol is not defined

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2021-08-31 11:59:17 +10:00
Axel Heider
a7194c1927 add comment about handleUnknownSyscall()
The function name handleUnknownSyscall() is slightly misleading, it
handles all non-standard seL4 syscalls used in debug builds also.

Signed-off-by: Axel Heider <axelheider@gmx.de>
2021-08-31 10:53:31 +10:00
Axel Heider
f8c3ad0c58 add comment about empty Arch_finaliseInterrupt()
Signed-off-by: Axel Heider <axelheider@gmx.de>
2021-08-31 10:53:31 +10:00
Axel Heider
7a4da705f0 boot/arm: clarify comment about cache flush
Signed-off-by: Axel Heider <axelheider@gmx.de>
2021-08-31 10:53:31 +10:00
Axel Heider
54ae03f951 trivial: improve style for code and comments
Signed-off-by: Axel Heider <axelheider@gmx.de>
2021-08-31 10:53:31 +10:00