Giter Club home page Giter Club logo

sel4runtime's Introduction

The seL4 Run-time

This provides a minimal runtime for running a C or C-compatible process, i.e. one with a C-like main, in a minimal seL4 environment.

This runtime provides mechanisms for accessing everything a standard process would expect to need at start and provides additional utilities for delegating the creation of processes and threads.

Standard Processes

All processes (except for the root task) will use the entry-points provided here as normal and require the _start entry-point provided in the architecture-dependant crt0.S. This will then bootstrap into the runtime entry-point __sel4_start_c which simply processes the stack to find the argument, environment, and auxiliary vectors.

The found vectors, along withmain, are passed into __sel4_start_main which configures the runtime before starting main.

Root Task

The root task requires an alternate entry-point _sel4_start which assumes that the seL4_BootInfo argument has been passed to it and that it has not been given a stack.

This entry-point moves onto a static 16 kilobyte stack before invoking __sel4_start_root, which constructs the argument, environment, and auxiliary vectors. It then passes the constructed vectors, along with main, into __sel4_start_main which configures the runtime before starting main.

Thread-local storage layout

There are two standard layouts for thread local storage commonly used. One where the TLS base address refers to the first address in memory of the region and one where it refers to the address that immediately follows the region. Intel's x86_64 and ia32 architectures use the latter method as it aligns with the segmentation view of memory presented by the processor. Most other platforms use former method, where the TLS can be said to be 'above' the thread pointer.

In order to store metadata for the current thread in the same memory allocation as the TLS, the run-time utilises memory on the other side of the thread pointer for it's thread structure.

sel4runtime's People

Contributors

axel-h avatar heshamelmatary avatar kent-mcleod avatar lsf37 avatar marwit avatar pingerino avatar sorear avatar xurtis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sel4runtime's Issues

[ARM64] Failed to compile with error "operand 1 should be an integer register"

[PATCH] [ARM64] Use x29 and x30 instead of fp and lr to make GCC
 happy

GCC will abort the compilation with errors:
   "operand 1 should be an integer register ..."

See also https://bugs.webkit.org/show_bug.cgi?id=175512
---
 crt/sel4_arch/aarch64/crt0.S | 4 ++--
 crt/sel4_arch/aarch64/crti.S | 8 ++++----
 crt/sel4_arch/aarch64/crtn.S | 4 ++--
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/crt/sel4_arch/aarch64/crt0.S b/crt/sel4_arch/aarch64/crt0.S
index 3bd28b7..d265d06 100644
--- a/crt/sel4_arch/aarch64/crt0.S
+++ b/crt/sel4_arch/aarch64/crt0.S
@@ -12,8 +12,8 @@
 .section .text
 .global _start
 _start:
-	mov fp, #0
-	mov lr, #0
+	mov x29, #0
+	mov x30, #0
 
 	mov x0, sp
 	bl __sel4_start_c
diff --git a/crt/sel4_arch/aarch64/crti.S b/crt/sel4_arch/aarch64/crti.S
index 1119b90..3b85d67 100644
--- a/crt/sel4_arch/aarch64/crti.S
+++ b/crt/sel4_arch/aarch64/crti.S
@@ -12,11 +12,11 @@
 .section .init
 .global _init
 _init:
-	stp fp, lr, [sp, -16]!
-	mov fp, sp
+	stp x29, x30, [sp, -16]!
+	mov x29, sp
 
 .section .fini
 .global _fini
 _fini:
-	stp fp, lr, [sp, -16]!
-	mov fp, sp
+	stp x29, x30, [sp, -16]!
+	mov x29, sp
diff --git a/crt/sel4_arch/aarch64/crtn.S b/crt/sel4_arch/aarch64/crtn.S
index 734ccdc..4af13dc 100644
--- a/crt/sel4_arch/aarch64/crtn.S
+++ b/crt/sel4_arch/aarch64/crtn.S
@@ -10,9 +10,9 @@
  * @TAG(DATA61_BSD)
  */
 .section .init
-	ldp fp, lr, [sp], #16
+	ldp x29, x30, [sp], #16
 	ret
 
 .section .fini
-	ldp fp, lr, [sp], #16
+	ldp x29, x30, [sp], #16
 	ret
-- 
2.25.0

Build instructions

It would be nice if some build instructions were provided in the README of this repo. For example, is it expected that this will always be built via the build system in https://github.com/seL4/seL4_tools/tree/master/cmake-tool, or is it possible to build this standalone?

When attempting a standalone build, with:

cmake -G Ninja -C config.cmake path/to/sel4runtime/

(config.cmake just sets things like KernelSel4Arch.)

I get the following error:

CMake Error at CMakeLists.txt:20 (config_string):
  Unknown CMake command "config_string".

It seems that config_string is defined over in the kernel repo: https://github.com/seL4/seL4/blob/master/tools/helpers.cmake#L322

I'm new to CMake so it's possible that I've misunderstood, but it seems to me that the build system of this repo expects this function to have already been defined for it, and so to be built via a larger build system (seL4_tools?). Including this from my config.cmake doesn't seem to have any effect.

Any help/advice on any of the above would be appreciated.

sel4runtime should provide default exit handlers instead of raising a cap fault.

It is less confusing if the exit handler printed out an error message before cap faulting, or provided an alternative default implementation that suspends the current thread if an initial_thread_tcb is saved in the current runtime environment before triggering a fault.
The current implementation:

    /* If the exit is never set this will try and call a NULL function
     * pointer which should result in a fault. This is as good a way as
     * any to exit the process if we don't know anything better about
     * the environment. */
    env.exit_cb(code);

Will raise this fault:

 Caught cap fault in send phase at address 0
while trying to handle:
vm fault on data at address 0 with status 0x4
in thread 0xffffff801fe08400 "rootserver" at address 0
With stack:
0x41ce98: 0x401740
0x41cea0: 0x0
0x41cea8: 0x401100
0x41ceb0: 0x41cef0
0x41ceb8: 0x40121b
0x41cec0: 0x0
0x41cec8: 0x41cf30
0x41ced0: 0x41cf20
0x41ced8: 0x41cf10
0x41cee0: 0x1
0x41cee8: 0x4010f2
0x41cef0: 0x41cff0
0x41cef8: 0x401394
0x41cf00: 0x0
0x41cf08: 0x525000
0x41cf10: 0x41201c

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.