base-linux: 64-bit ARM support

This patch adds support for running Genode/Linux on the AARCH64
architecture.

- The kernel-agnostic startup code (crt0) had to be extended to
  capture the initial stack pointer, which the Linux kernel uses
  to pass the process environment. This is in line with the
  existing startup code for x86_32 and x86_64.

- The link order of the host libraries linked to lx_hybrid
  programs had to be adjusted such that libgcc appears at last
  because the other libraries depend on symbols provided by
  libgcc.

- When using AARCH64 Linux as host, one can execute run scripts
  via 'make run/<script> KERNEL=linux BOARD=linux' now.

Issue #4136
This commit is contained in:
Norman Feske
2021-05-05 19:20:37 +02:00
committed by Christian Helmuth
parent 718f44ae5b
commit 2f9d430c00
21 changed files with 126 additions and 8 deletions

View File

@ -60,6 +60,11 @@ inline int lx_open(char const *pathname, int flags, mode_t mode = 0)
inline int lx_stat_size(char const *path, Genode::uint64_t &out_size)
{
#ifdef __aarch64__
struct statx buf { };
int result = lx_syscall(SYS_statx, AT_FDCWD, path, 0, STATX_SIZE, &buf);
out_size = buf.stx_size;
#else
#ifdef _LP64
struct stat buf { };
int result = lx_syscall(SYS_stat, path, &buf);
@ -68,6 +73,7 @@ inline int lx_stat_size(char const *path, Genode::uint64_t &out_size)
struct stat64 buf { };
int result = lx_syscall(SYS_stat64, path, &buf);
out_size = buf.st_size;
#endif
#endif
return result;
}

View File

@ -356,7 +356,7 @@ inline int lx_sigaction(int signum, void (*handler)(int), bool altstack)
* with EINTR. We therefore set the SA_RESTART flag in signal handlers.
*/
#ifdef _LP64
#ifdef __x86_64__
/*
* The SA_RESTORER flag is not officially documented, but used internally
* by the glibc implementation of sigaction(). Without specifying this flag

View File

@ -0,0 +1,19 @@
/*
* \brief Linux clone() binding
* \author Norman Feske
* \date 2021-04-12
*/
#define SYS_clone 220
.text
.globl lx_clone
.type lx_clone, #function
lx_clone:
stp x29, x30, [sp, #-16]! /* save sp and link register */
stp x3, x0, [x1, #-16]! /* supply fn and argp at new thread's stack */
mov x0, x2 /* flags */
mov w8, #SYS_clone
svc #0 /* syscall, return value in x0 */
ldp x29, x30, [sp], #16 /* restore sp and link register */
ret

View File

@ -0,0 +1,21 @@
/*
* \brief Linux syscall() binding
* \author Norman Feske
* \date 2021-04-07
*/
.text
.globl lx_syscall
.type lx_syscall, #function
lx_syscall:
stp x29, x30, [sp, #-16]! /* save sp and link register */
mov x8, x0 /* system call number */
mov x0, x1 /* arguments ... */
mov x1, x2
mov x2, x3
mov x3, x4
mov x4, x5
mov x5, x6
svc #0 /* syscall, return value in x0 */
ldp x29, x30, [sp], #16 /* restore sp and link register */
ret