# Linux Kernel Module Cheat

##### 24.8.2.1. m5ops magic addresses

These are magic addresses that when accessed lead to an m5op.

The base address is given by `system.m5ops_base`, and then each m5op happens at a different address offset form that base.

If `system.m5ops_base` is 0, then the memory m5ops are disabled.

Note that the address is physical, and therefore when running in full system on top of the Linux kernel, you must first map a virtual to physical address with `/dev/mem` as mentioned at: Userland physical address experiments.

One advantage of this method is that it can work with gem5 KVM, whereas the magic instructions don’t, since the host cannot handle them and it is hard to hook into that.

A Baremetal example of that can be found at: baremetal/arch/aarch64/no_bootloader/m5_exit_addr.S.

As of gem5 0d5a80cb469f515b95e03f23ddaf70c9fd2ecbf2, `fs.py --baremetal` disables the memory m5ops however for some reason, therefore you should run that program as:

    ./run --arch aarch64 --baremetal baremetal/arch/aarch64/no_bootloader/m5_exit_addr.S --emulator gem5 --trace-insts-stdout -- --param 'system.m5ops_base=0x10010000'

TODO failing with:

    info: Entering event queue @ 0.  Starting simulation...
    fatal: Unable to find destination for [0x10012100:0x10012108] on system.iobus