# Linux Kernel Module Cheat

##### 27.7.1.3. Python gem5 user mode simulation

At LKMC 50ac89b779363774325c81157ec8b9a6bdb50a2f gem5 390a74f59934b85d91489f8a563450d8321b602da:

    ./run \
      --emulator gem5 \
      --userland "$(buildroot_target_dir)/usr/bin/python3" \
      --cli-args rootfs_overlay/lkmc/python/hello.py \
    ;

fails with:

    fatal: Syscall 318 out of range

which corresponds to the glorious `inotify_rm_watch` syscall: https://github.com/torvalds/linux/blob/v5.4/arch/arm/tools/syscall.tbl#L335

and aarch64:

    ./run \
      --arch aarch64 \
      --emulator gem5 \
      --userland "$(./getvar --arch aarch64 buildroot_target_dir)/usr/bin/python3" \
      --cli-args rootfs_overlay/lkmc/python/hello.py \
    ;

fails with:

    fatal: syscall unused#278 (#278) unimplemented.

which corresponds to the glorious `getrandom` syscall: https://github.com/torvalds/linux/blob/v4.17/include/uapi/asm-generic/unistd.h#L707

Bibliography:

- https://stackoverflow.com/questions/63999944/is-it-possible-to-run-python-code-in-gem5-syscall-emulation-mode