Updating the gem5 Linux Kernel for x86

I was recently pointed to a GitHub repository for setting up a disk image for gem5 that contains the PARSEC Benchmarks. Unfortunately the steps listed to create a disk image did not work for me when booting with gem5. However, the repo does contain a kernel configuration for linux version 3.4.112, which I have saved in a gist just in case.

To compile the kernel, head over to The Linux Kernel Archives and download the appropriate version (in this case 3.4.112). Extract the kernel, and copy over the kernel configuration into the extracted directory with the .config filename. Now typing make vmlinux should give you a kernel that you can boot just fine with gem5, even while using their (very old) disk images.

The following steps should produce a binary called vmlinux:

1
2
3
4
5
6
> wget https://cdn.kernel.org/pub/linux/kernel/v3.x/linux-3.4.112.tar.xz
> tar -xJf linux-3.4.112.tar.xz
> cd linux-3.4.112
> wget https://gist.githubusercontent.com/mariobadr/8f12d7fd5794e6b219d8cc9c193c0874/raw/3e529e91b341597697ec1364a0a7766296e54632/X86_64-vmlinux-3.4.112
> mv X86_64-vmlinux-3.4.112 .config
> make vmlinux

In order to load the kernel add it to your binaries directory in M5_PATH -- I renamed it to x86_64-vmlinux-3.4.112. Because of the way the full system python scripts work, you'll need to add the full system files from the gem5 website to their respective binaries and disks folders. That is, $M5_PATH/binaries should contain x86_64-vm-linux-2.6.22.9 and in addition to the kernel we created above. Also, M5_PATH/disks should contain x86root.img and linux-bigswap2.img (the latter is actually in the ALPHA full system tarball) disk images. Ideally the python scripts should be updated... but that's a different post entirely. Assuming your directories are setup as above and you have compiled an X86 version of gem5, you can run gem5 in full system mode like so:

1
> ./build/X86_MESI_Two_Level/gem5.opt configs/example/fs.py --kernel=x86_64-vmlinux-3.4.112