# Linux Kernel Module Cheat

#### 24.8.1. gem5 m5 executable

`m5` is a guest command line utility that is installed and run on the guest, that serves as a CLI front-end for the m5ops

Its source is present in the gem5 tree: https://github.com/gem5/gem5/blob/6925bf55005c118dc2580ba83e0fa10b31839ef9/util/m5/m5.c

It is possible to guess what most tools do from the corresponding m5ops, but let’s at least document the less obvious ones here.

In LKMC we build `m5` with:

    ./build-m5 --arch aarch64

The `m5` executable can be run on User mode simulation as normal with:

    ./run --arch aarch64 --emulator gem5 --userland "$(./getvar --arch aarch64 out_rootfs_overlay_bin_dir)/m5" --cli-args dumpstats

This can be a good test m5ops since it executes very quickly.

- m5 exit

- m5 dumpstats

- m5 fail

- m5 writefile

- m5 readfile

- m5 initparam

- m5 execfile