Commit graph

69 commits

Author SHA1 Message Date
Anna Lyons
cb7cbd84dc boot: allocate rootserver objects last
This change allows us to know, from just the kernel and dtb, where user
level untyped objects start being allocated from.

- allocate rootserver objects from last available freemem region.
- move create_rootserver_objects call into init_freemem.
2019-06-20 14:11:50 +10:00
Japheth Lim
4a3685df33 ARM boot: abort if out of freemem slots
This fails early if the build process failed to calculate a suitable
MAX_NUM_FREEMEM_REG.
2019-06-20 14:11:50 +10:00
Japheth Lim
e42700a444 ARM boot: MAX_NUM_FREEMEM_REG++ for new allocator
Previously, the boot allocator would do dynamic calculations to
minimise fragmentation, then throw away the smallest regions.
With the new boot allocator, we can reasonably predict that
fragmentation will create at most one extra region, so this commit
adds one freemem slot for ARM.
2019-06-20 14:11:50 +10:00
Anna Lyons
8586b7f2b8 boot: refactor allocation of rootserver objects
Prior to this change, the boot process would dynamically allocate
memory for root server objects based on the order of initialisation.
Allocation was a best-fit algorithm.

This change preallocates all memory for root server objects to an
aligned untyped just after the user image. By allocating the objects in
order of size, allocation is greatly simplified and the ability to
reproduce the allocation offline based on the kernel and user image
sizes is increased.
2019-06-20 14:11:50 +10:00
Anna Lyons
5fac9e8198 config: make root cnode size 4k minimum
The previous minimum (4) was actually too small to fit more than 1
capability, which would not allow the kernel to boot. A 4K minimum means
on 32-bit, an 8 size is the minimum (256 slots) and on 64-bit, 7 (128
slots).

In addition to being a more practical minimum, this also allows for
simplification of the boot code for future commits.
2019-06-17 17:36:11 +10:00
Japheth Lim
210c5c2157 boot: revert binary verification workaround in init_freemem
The toolchain has been tweaked to accept the original code, so the
workaround is no longer required.

This reverts commit d0d97779cb.
2019-05-29 14:23:51 +10:00
Matthew Brecknell
d0d97779cb boot: avoid array access in init_freemem
This works around an issue in the binary correctness proofs. The `if`
conditions become assumptions when proving refinement of the branches.
Currently, a simplification step is slow when these assumptions contain
certain modes of array access. The slowdown apparently becomes
dramatically worse when multiple such assumptions are present, such as
in the final `else` branch. Hopefully, this limitation can be addressed
in future work.
2019-05-15 14:03:40 +10:00
Anna Lyons
0c4da6fb5d boot: use static array rather than stack array
Binary verification cannot parse the instructions produced by the stack
array, likely because none of the existing kernel code declares arrays
on the stack. Given all boot code and data is unmapped, wiped and made
available to the user after boot, moving the array to static data isn't
a problem.
2019-05-15 14:03:40 +10:00
Anna Lyons
d967aa0d91 boot: pass the c-parser
- use constant array size on stack
- cast arrays to pointers to match function return types
2019-05-15 14:03:40 +10:00
Anna Lyons
e3a83035f8 boot: consolidate init_freemem
init_freemem sets up available regions of memory for the hardware that
seL4 is booting on. Previously this function was duplicated across
architectures, with minor duplication.

This change provides a top-level init_freemem suitable for all
architectures.

- arm/riscv: change get_avail_p_reg to return whole p_reg array
- update all architectures to use new init_freemem.
- wrap init_freemem calls with arch_init_freemem for each arch, where
arch_init_freemem sets up the available and reserved regions of memory
which are passed to init_freemem.
2019-05-15 14:03:40 +10:00
Jasper Lowell
69339d4203 Boot code: Statically allocate idle thread
The idle thread is not managed at user-level and so it can instead be
statically allocated. This simplifies the boot code and increments
towards being easier to formally verify.
2019-05-07 12:21:31 +10:00
Anna Lyons
a6b4cf739d boot: allocate irq cnode statically
The memory used for the irq cnode is never available to the user. As a
result this memory can be allocated statically, simplifying the
bootcode.

- remove allocation of irq cnode
- add static init
- generate irq cnode size from cmake for arm
- add static constants for riscv, x86 as there is no variability at the
moment.
2019-05-03 16:18:39 +10:00
Simon Shields
b7c053f93f Add support for extra bootinfo larger than a page
The current code may not always allocate enough -
change the logic to over-allocate memory rather than under-allocate.
2019-05-01 12:18:52 +10:00
Anna Lyons
7fc45c4ef1 style: set code width to 120 2019-03-19 14:05:44 +11:00
Anna Lyons
306453e347 style: set min-conditional-indent to 0
Given we use braces all the time conditional indents do not make code
cleaner.
2019-03-19 14:05:44 +11:00
Anna Lyons
d0930f67de style: consistently attach return type
Add attach-return-type to astyle
2019-03-19 14:05:36 +11:00
Anna Lyons
761006e03b style: consistently align pointer with name
Run astyle with align-pointer=name
2019-03-19 14:04:54 +11:00
Anna Lyons
3d10ef0c4d style: correct parenthesis padding
Use astyle's unpad-paren to unpad all parentheses that are not included
by pad-header, pad-oper, and pad-comma.
2019-03-19 14:02:59 +11:00
Anna Lyons
e5bb674594 Calculate IRQ_CNODE_BITS from maxIRQ
IRQ_CNODE_BITS is determined by the maxIRQ on the platform. Calculate
this value from maxIRQ instead of hardcoding for each platform.
2018-12-12 16:24:31 +11:00
Thomas Sewell
f6a88c6bad Retire boot_ctzl.
This was a workaround for a problem that was properly fixed in
f8606c86 however the boot_ctzl version somehow persisted.
2018-08-13 15:03:31 +10:00
Adrian Danis
5505266a74 Remove irrelavant changes from riscv commit to non riscv arch code 2018-04-18 10:10:14 +10:00
Hesham Almatary
83ba084713 [SELFOUR-1156] RISC-V Port
Experimental release that supports both RV32 and RV64
2018-04-18 10:10:14 +10:00
Anna Lyons
9f3fc38c84 Assign correct affinity to idle thread 2018-02-16 14:46:00 +11:00
Adrian Danis
61f8f4d033 Avoid repeatedly appending idle threads to debug list
Each node calls `init_core_state` and so can be relied upon to append their own idle
thread. Having every core enqueue all the cores idle threads is not correct as it will
result in attempting to enqueue a thread more than once.
2018-01-10 16:01:27 +11:00
Hesham Almatary
57fa0e0f85 Share linker.h between architectures 2017-08-10 08:38:36 +10:00
Hesham Almatary
ee28936d48 SMP: Introduce ENABLE_SMP_SUPPORT
- Make it more readable and less confusing compared to the 'CONFIG_MAX_NUM_NODES > 1' check
2017-06-29 16:23:39 +10:00
Hesham Almatary
318ead8fab Call Arch_setTCBIPCBuffer from kernel/boot.c 2017-06-17 23:04:19 +10:00
Anna Lyons
bb5ecb1b3e SELFOUR-880: add seL4_DebugDumpScheduler
- when CONFIG_DEBUG is enabled, track all threads
- when CONFIG_PRINTING is enabled, provide seL4_DebugDumpScheduler which
allows the user to dump the state of the kernel scheduler.
2017-05-30 15:22:23 +10:00
Anna Lyons
ac9ea51629 SELFOUR-880: name the idle thread 2017-05-30 15:22:23 +10:00
Kent McLeod
3b2b64a094 SELFOUR-864: Fix alignment calculation 2017-05-02 12:18:07 +10:00
Anna Lyons
f42d63631b refactor: initialise common core state in one place 2017-03-16 11:15:04 +11:00
Adrian Danis
c43954252c Remove assumption on 32-bit memory offsets
On 64-bit platforms physical address could be >2^32 offset from a virtual address. This
changes offsets to match the word size of the target architecture
2017-02-28 08:28:01 +11:00
Adrian Danis
f8606c86ad Provide spec for CTZL
Provides a spec for the __builtin_ctzl function and changes existing
code to use this wrapper
2017-02-22 17:22:17 +11:00
Bamboo
0a93c3a2a0 [STYLE_FIX] 2017-02-16 03:41:56 +00:00
Adrian Danis
c574f4fc48 Helper for allocating the extra boot info region 2017-02-16 14:34:52 +11:00
Adrian Danis
7836f76cf9 Extend bootinfo to support potentially arbitrary additional structures
This provides a future proof interface for extending the bootinfo region with additional
kinds of optional architecture and platform specific information. The basic idea is to
report the size of a region directly following the bootinfo frame, which is made up of
a series of 'chunks'. Each chunk has an identifier (describing what it is) and a length,
allowing unknown chunks to be skipped in favor of examining the remaining of the chunks.
2017-02-16 14:34:52 +11:00
Adrian Danis
f3d62531b5 Use same constant for clearing and allocating bootinfo frame
Closes #56
2017-01-27 09:54:54 +11:00
Thomas Sewell
f658276abb Remove many DONT_TRANSLATE markers.
The vast majority of the DONT_TRANSLATE markers in the kernel are used
to hide __asm__ statements and builtin functions
(e.g. __builtin_unreachable ()) from the C-to-Isabelle parser.

The parser now supports underscore identifiers and many __asm__ statements,
and the builtin functions are prototyped, meaning the vast majority of the
DONT_TRANSLATE markers can be dropped. The remaining markers cover functions
that must be treated specially.
2016-12-12 17:30:50 +11:00
Bamboo
198a830504 [STYLE_FIX] 2016-11-22 00:50:52 +00:00
Adrian Danis
e78cdf9b64 SELFOUR-553: Support alternate IPC buffer locations without globals frame
This commit adds support for using the ThreadID registers of the ARM MPCore
platforms for storing the address of the IPC buffer instead of the globals
frame. The choice of using the user readable/writeable ThreadID register
is chosen, even though it means the user cannot use it for its own
purposes, as it leaves room in the future for doing TLS support in the
user read only register, where compilers expect it.
2016-11-22 11:49:52 +11:00
Adrian Danis
828a14d853 SELFOUR-222: Configure IRQ cnode size per platform 2016-11-08 11:48:31 +11:00
Thomas Sewell
03c71b63e1 SELFOUR-444: Preemptible zeroing for retype.
Change to the order of operations and timing behaviour of
invokeUntyped_Retype. The Retype operation now zeroes the
entire range of the Untyped cap (if it is being used for
the first time) before installing any objects. This avoids
the need for long-running initialisation of large objects,
whose initial contents are always zero. The initial zeroing
phase is preemptible, and may take multiple timeslices to
complete.
2016-11-01 17:05:36 +11:00
amrzar
2d462d4ad9 add basic api for setting affinity 2016-10-19 08:35:37 +11:00
amrzar
1887ae9dce Update SMP idle thread handling 2016-10-14 11:15:39 +11:00
Adrian Danis
7d50c439a8 Defined untyped size ranges in libsel4 2016-10-12 12:22:32 +11:00
amrzar
3f9eb7c873 SELFOUR-632: implement cores non-architecture dependent structres 2016-10-10 16:33:48 +11:00
Anna Lyons
7336303b7f SELFOUR-276: Add MCP field to threads.
Where MCP = Maximum Controlled Priority

This commit adds:

* seL4_TCB_SetMCPriority

and changes the arguments to

* seL4_TCB_Configure

As of this commit, a thread cannot create or set a threads
priority (including itself) above its mcp. Previously the kernel
did this check against a threads priority, which prevented a thread
from setting it's own priority down and then up again.
2016-10-05 11:11:19 +11:00
Adrian Danis
8e77cdb5e9 SELFOUR-421: Add padding for untyped in bootinfo 2016-09-23 14:15:09 +10:00
Adrian Danis
d507b2d39e SELFOUR-421 Introduce explicit device frames and untypeds
Kernel objects cannot be created from device untypeds, with the
exception of frames, which do not get zeroed and cannot be used
as an IPC buffer. Device untypeds additionally cannot be used
in the construction of ASID pools.

This then changes the API to the rootserver (i.e. bootinfo) to
send device untypeds instead of device frames. On ARM these
device untypeds are the same as the previously exported device
frame regions. On x86 PCI scanning is removed and all physical
memory addresses (that are not important for kernel integrity)
are released to the user.

In order to have bits in the frame and untyped caps on ARM the
number of software ASIDs had to be reduced from 2^18 to 2^17,
and the maximum untyped size reduced from 2^31 to 2^30
2016-09-23 14:15:08 +10:00
Hesham Almatary
d97603bd84 SELFOUR-566: Decouble seL4_DebugNameThread from CONFIG_PRINTING 2016-07-15 12:30:17 +10:00