# Linux Kernel Module Cheat

### 24.9. gem5 arm Linux kernel patches

https://gem5.googlesource.com/arm/linux/ contains an ARM Linux kernel forks with a few gem5 specific Linux kernel patches on top of mainline created by ARM Holdings on top of a few upstream kernel releases.

Our build script automatically adds that remote for us as `gem5-arm`.

The patches are optional: the vanilla kernel does boot. But they add some interesting gem5-specific optimizations, instrumentations and device support.

The patches also add defconfigs that are known to work well with gem5.

E.g. for arm v4.9 there is: https://gem5.googlesource.com/arm/linux/+/917e007a4150d26a0aa95e4f5353ba72753669c7/arch/arm/configs/gem5_defconfig.

In order to use those patches and their associated configs, and, we recommend using Linux kernel build variants as:

    git -C "$(./getvar linux_source_dir)" fetch gem5-arm:gem5/v4.15
    git -C "$(./getvar linux_source_dir)" checkout gem5/v4.15
    ./build-linux \
      --arch aarch64 \
      --custom-config-file-gem5 \
      --linux-build-id gem5-v4.15 \
    ;
    git -C "$(./getvar linux_source_dir)" checkout -
    ./run \
      --arch aarch64 \
      --emulator gem5 \
      --linux-build-id gem5-v4.15 \
    ;

QEMU also boots that kernel successfully:

    ./run \
      --arch aarch64 \
      --linux-build-id gem5-v4.15 \
    ;

but glibc kernel version checks make init fail with:

    FATAL: kernel too old

because glibc was built to expect a newer Linux kernel as shown at: Section 11.4.1, “FATAL: kernel too old failure in userland simulation”. Your choices to solve this are:

- see if there is a more recent gem5 kernel available, or port your patch of interest to the newest kernel

- modify this repo to use uClibc, which is not hard because of Buildroot

- patch glibc to remove that check, which is easy because glibc is in a submodule of this repo

It is obviously not possible to understand what the Linux kernel fork commits actually do from their commit message, so let’s explain them one by one here as we understand them:

- `drm: Add component-aware simple encoder` allows you to see images through VNC, see: Section 14.3, “gem5 graphic mode”

- `gem5: Add support for gem5’s extended GIC mode` adds support for more than 8 cores, see: Section 24.3.1.2, “gem5 ARM full system with more than 8 cores”

Tested on 649d06d6758cefd080d04dc47fd6a5a26a620874 + 1.

- gem5 arm Linux kernel patches boot speedup