# Linux Kernel Module Cheat

### 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