# Linux Kernel Module Cheat
The perfect emulation setup to study and develop the <<linux-kernel>> v5.9.2, kernel modules, <<qemu-buildroot-setup,QEMU>>, <<gem5-buildroot-setup,gem5>> and x86_64, ARMv7 and ARMv8 <<userland-assembly,userland>> and <<baremetal-setup,baremetal>> assembly, <<c,ANSI C>>, <<cpp,C++>> and <<posix,POSIX>>. <<gdb>> and <<kgdb>> just work. Powered by <<about-the-qemu-buildroot-setup,Buildroot>> and <<about-the-baremetal-setup,crosstool-NG>>. Highly automated. Thoroughly documented. Automated <<test-this-repo,tests>>.

### 11.7. gem5 syscall emulation mode

Less robust than QEMU’s, but still usable:

- https://stackoverflow.com/questions/48986597/when-should-you-use-full-system-fs-vs-syscall-emulation-se-with-userland-program

There are much more unimplemented syscalls in gem5 than in QEMU. Many of those are trivial to implement however.

So let’s just play with some static ones:

    ./build-userland --arch aarch64
    ./run \
      --arch aarch64 \
      --emulator gem5 \
      --userland userland/c/command_line_arguments.c \
      --cli-args 'asdf "qw er"' \
    ;

TODO: how to escape spaces on the command line arguments?

GDB step debug also works normally on gem5:

    ./run \
      --arch aarch64 \
      --emulator gem5 \
      --gdb-wait \
      --userland userland/c/command_line_arguments.c \
      --cli-args 'asdf "qw er"' \
    ;
    ./run-gdb \
      --arch aarch64 \
      --emulator gem5 \
      --userland userland/c/command_line_arguments.c \
      main \
    ;

- gem5 dynamic linked executables in syscall emulation

- gem5 syscall emulation exit status

- gem5 syscall emulation mode syscall tracing

- gem5 syscall emulation multithreading

- gem5 syscall emulation multiple executables