mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
Automate failed gem5 x86 attempt
This commit is contained in:
15
build
15
build
@@ -37,14 +37,17 @@ case "$arch" in
|
||||
x86_64)
|
||||
defconfig=qemu_x86_64_defconfig
|
||||
;;
|
||||
x86_64-gem5)
|
||||
defconfig=qemu_x86_64_defconfig
|
||||
;;
|
||||
arm)
|
||||
# qemu_arm_vexpress_defconfig required a newer QEMU than 2.0.0 on a Ubuntu host.
|
||||
# so let's stick to versatile for now.
|
||||
defconfig=qemu_arm_versatile_defconfig
|
||||
;;
|
||||
arm-gem5)
|
||||
# qemu_arm_vexpress_defconfig required a newer QEMU than 2.0.0 on a Ubuntu host.
|
||||
# so let's stick to versatile for now.
|
||||
# Ideally we should use a custom clean config here.
|
||||
# But let's just use this one as a starting point for now.
|
||||
defconfig=qemu_arm_versatile_defconfig
|
||||
post_script_args="$post_script_args -n"
|
||||
;;
|
||||
@@ -67,9 +70,9 @@ make O="$outdir" BR2_EXTERNAL="$(pwd)/../kernel_module" "$defconfig"
|
||||
# TODO Can't get rid of this for now.
|
||||
# http://stackoverflow.com/questions/44078245/is-it-possible-to-use-config-fragments-with-buildroots-config
|
||||
cat ../buildroot_config_fragment >> "${outdir}/.config"
|
||||
if [ "$arch" = 'arm-gem5' ]; then
|
||||
if echo "$arch" | grep -Eq -- '-gem5$'; then
|
||||
echo "\
|
||||
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE=\"../kernel_config_gem5\"
|
||||
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE=\"../kernel_config_${arch}\"
|
||||
" >> "${outdir}/.config"
|
||||
else
|
||||
echo "\
|
||||
@@ -99,6 +102,6 @@ time \
|
||||
all \
|
||||
;
|
||||
cd ..
|
||||
if [ "$arch" = 'arm-gem5' ]; then
|
||||
./build-gem5
|
||||
if echo "$arch" | grep -Eq -- '-gem5$'; then
|
||||
./build-gem5 -a "$arch"
|
||||
fi
|
||||
|
||||
46
build-gem5
46
build-gem5
@@ -1,18 +1,38 @@
|
||||
#/usr/bin/env bash
|
||||
set -e
|
||||
set -eu
|
||||
arch='arm-gem5'
|
||||
while getopts 'a:' OPT; do
|
||||
case "$OPT" in
|
||||
a)
|
||||
arch="$OPTARG"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift "$(($OPTIND - 1))"
|
||||
if [ ! -d 'gem5' ]; then
|
||||
git clone https://gem5.googlesource.com/public/gem5
|
||||
git clone https://gem5.googlesource.com/public/gem5
|
||||
fi
|
||||
cd gem5
|
||||
git checkout da79d6c6cde0fbe5473ce868c9be4771160a003b
|
||||
# Compilation fails with gcc 7 on that commit.
|
||||
# There were some recent portability patches, so it will likely get there soon.
|
||||
CC=gcc-6 CXX=g++-6 scons -j"$(nproc)" --ignore-style build/ARM/gem5.opt
|
||||
make -C system/arm/dt
|
||||
make -C system/arm/simple_bootloader
|
||||
make -C system/arm/aarch64_bootloader/
|
||||
# TODO use local paths. The search path can be changed with M5_PATH="$(pwd)",
|
||||
# but the annoying "binaries/" is added in front of it.
|
||||
mkdir -p ../gem5-system/binaries
|
||||
cp ./system/arm/simple_bootloader/boot_emm.arm ../gem5-system/binaries
|
||||
cp ./system/arm/aarch64_bootloader/boot_emm.arm64 ../gem5-system/binaries
|
||||
system_dir='../gem5-system'
|
||||
binaries_dir="${system_dir}/binaries"
|
||||
disks_dir="${system_dir}/disks"
|
||||
mkdir -p "$binaries_dir" "$disks_dir"
|
||||
if [ "$arch" = 'x86_64-gem5' ]; then
|
||||
CC=gcc-6 CXX=g++-6 scons -j"$(nproc)" --ignore-style build/X86/gem5.opt
|
||||
f="${disks_dir}/linux-bigswap2.img"
|
||||
dd if=/dev/zero of="$f" bs=1024 count=65536
|
||||
mkswap "$f"
|
||||
# This file must always be present, despite --kernel overriding that default and selecting the kernel.
|
||||
# I'm not even joking. No one has ever built x86 gem5 without the magic dist dir present.
|
||||
touch "${binaries_dir}/x86_64-vmlinux-2.6.22.9"
|
||||
elif [ "$arch" = 'arm-gem5' ]; then
|
||||
# Compilation fails with gcc 7 on that commit.
|
||||
# There were some recent portability patches, so it will likely get there soon.
|
||||
CC=gcc-6 CXX=g++-6 scons -j"$(nproc)" --ignore-style build/ARM/gem5.opt
|
||||
make -C system/arm/dt
|
||||
make -C system/arm/simple_bootloader
|
||||
make -C system/arm/aarch64_bootloader/
|
||||
cp ./system/arm/simple_bootloader/boot_emm.arm "$binaries_dir"
|
||||
cp ./system/arm/aarch64_bootloader/boot_emm.arm64 "$binaries_dir"
|
||||
fi
|
||||
|
||||
26
gem5.md
26
gem5.md
@@ -27,7 +27,7 @@ Vs QEMU:
|
||||
## ARM
|
||||
|
||||
./configure && ./build -a arm-gem5
|
||||
./rungem5
|
||||
./rungem5 -a arm-gem5
|
||||
|
||||
On another shell:
|
||||
|
||||
@@ -92,8 +92,28 @@ Related threads:
|
||||
|
||||
- <https://www.mail-archive.com/gem5-users@gem5.org/msg11384.html>
|
||||
- <https://stackoverflow.com/questions/37906425/booting-gem5-x86-ubuntu-full-system-simulation>
|
||||
- <http://www.lowepower.com/jason/creating-disk-images-for-gem5.html> claims to have a working config for x86_64 kernel 4.8.13
|
||||
|
||||
### Working baseline
|
||||
### Our best attempt
|
||||
|
||||
./configure && ./build -a x86_64-gem5
|
||||
./rungem5 -a x86_64-gem5
|
||||
|
||||
telnet:
|
||||
|
||||
i8042: PNP: No PS/2 controller found.
|
||||
i8042: Probing ports directly.
|
||||
Connection closed by foreign host.
|
||||
|
||||
stdout:
|
||||
|
||||
panic: Data written for unrecognized command 0xd1
|
||||
Memory Usage: 1235908 KBytes
|
||||
Program aborted at tick 427627410500
|
||||
|
||||
The same failure happens if we use the working QEMU Linux kernel, and / or if we use the kernel 4.8.13 as proposed in lowepower's post..
|
||||
|
||||
### Working baseline with magic image
|
||||
|
||||
Working x86 with the pre-built magic image with an ancient 2.6.22.9 kernel starting point:
|
||||
|
||||
@@ -124,7 +144,7 @@ On another shell:
|
||||
|
||||
telnet localhost 3456
|
||||
|
||||
### Unmodified Buildroot images
|
||||
### Unmodified Buildroot images 2
|
||||
|
||||
bzImage fails, so we always try with vmlinux obtained from inside build/.
|
||||
|
||||
|
||||
2819
kernel_config_x86_64-gem5
Normal file
2819
kernel_config_x86_64-gem5
Normal file
File diff suppressed because it is too large
Load Diff
42
rungem5
42
rungem5
@@ -1,11 +1,35 @@
|
||||
#!/usr/bin/env bash
|
||||
outdir="$(pwd)/buildroot/output.arm-gem5~"
|
||||
M5_PATH="$(pwd)/gem5-system" \
|
||||
arch='arm-gem5'
|
||||
while getopts 'a:' OPT; do
|
||||
case "$OPT" in
|
||||
a)
|
||||
arch="$OPTARG"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift "$(($OPTIND - 1))"
|
||||
outdir="$(pwd)/buildroot/output.${arch}~"
|
||||
echo $arch
|
||||
if echo "$arch" | grep -Eq '^x86_64(-|$)'; then
|
||||
cmd="\
|
||||
M5_PATH=\"$(pwd)/gem5-system\" \
|
||||
./gem5/build/X86/gem5.opt \
|
||||
gem5/configs/example/fs.py \
|
||||
--disk-image=\"${outdir}/images/rootfs.ext2\" \
|
||||
--kernel=\"${outdir}/build/linux-custom/vmlinux\" \
|
||||
--root-device='/dev/sda' \
|
||||
"
|
||||
elif echo "$arch" | grep -Eq '^arm-'; then
|
||||
cmd="\
|
||||
M5_PATH=\"$(pwd)/gem5-system\" \
|
||||
./gem5/build/ARM/gem5.opt \
|
||||
gem5/configs/example/fs.py \
|
||||
--disk-image="${outdir}/images/rootfs.ext2" \
|
||||
--dtb-file="$(pwd)/gem5/system/arm/dt/armv7_gem5_v1_1cpu.dtb" \
|
||||
--kernel="${outdir}/build/linux-custom/vmlinux" \
|
||||
--machine-type='VExpress_GEM5_V1' \
|
||||
--root-device='/dev/sda' \
|
||||
;
|
||||
gem5/configs/example/fs.py \
|
||||
--disk-image=\"${outdir}/images/rootfs.ext2\" \
|
||||
--dtb-file=\"$(pwd)/gem5/system/arm/dt/armv7_gem5_v1_1cpu.dtb\" \
|
||||
--kernel=\"${outdir}/build/linux-custom/vmlinux\" \
|
||||
--machine-type='VExpress_GEM5_V1' \
|
||||
--root-device='/dev/sda' \
|
||||
"
|
||||
fi
|
||||
echo "$cmd"
|
||||
eval "$cmd"
|
||||
|
||||
Reference in New Issue
Block a user