Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kernel: add linux compatibility layer #552

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

willdurand
Copy link
Owner

@willdurand willdurand commented Feb 10, 2022

It does not quite work yet, although binaries built for ArvernOS run on
Linux... "Just" need to make the opposite to happen now.

It totally works on x86_64 (because other archs don't have support for loading executing ELFs), although there are hacks everywhere! There are also many limitations, e.g., Linux binaries should be:

  • executable and not shared objects (-fno-pie)
  • compiled statically and with musl because glibc does weird stuff before calling a main() function...

Other limitations are related to ArvernOS itself:

  • no good multi-tasking (so no fork/clone)
  • no heap memory for user processes but I managed to fake that
  • no dedicated virtual memory for user processes so we can only execute a (user) binary once as long as it does not want to be loaded in memory areas already used by the kernel
  • no good sleep implementation

Screenshots

Screen Shot 2022-02-14 at 13 50 54

Screen Shot 2022-02-13 at 17 12 31

@willdurand
Copy link
Owner Author

(rebased)

It isn't working anymore since the x86_64 "process" code has been removed in the main branch.

@willdurand willdurand force-pushed the linux-compat branch 3 times, most recently from a50c764 to 972a964 Compare April 2, 2022 13:09
@willdurand
Copy link
Owner Author

I updated this POC to run unmodified binaries in kernel mode.

@willdurand willdurand force-pushed the linux-compat branch 8 times, most recently from 430c599 to 6c4ffe3 Compare April 3, 2022 12:24
@willdurand
Copy link
Owner Author

Screen Shot 2022-04-03 at 14 26 01

@willdurand willdurand force-pushed the linux-compat branch 6 times, most recently from ad976d8 to b16f574 Compare April 4, 2022 19:20
@willdurand
Copy link
Owner Author

The same program compiled for Linux on two different (64bit) architectures and running on ArvernOS:

Screen Shot 2022-04-04 at 21 17 21

Screen Shot 2022-04-04 at 21 13 23

@willdurand
Copy link
Owner Author

(BusyBox) uname -a:

Screen Shot 2022-04-04 at 21 50 03

src/kernel/sys/k_socket.c Outdated Show resolved Hide resolved
src/kernel/sys/k_syscall.c Outdated Show resolved Hide resolved
@willdurand willdurand force-pushed the linux-compat branch 3 times, most recently from 5392782 to 4b2c915 Compare April 6, 2022 08:13
@willdurand willdurand force-pushed the linux-compat branch 6 times, most recently from 4fa5150 to 2fd5de9 Compare July 17, 2022 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant