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)
|
x86_64)
|
||||||
defconfig=qemu_x86_64_defconfig
|
defconfig=qemu_x86_64_defconfig
|
||||||
;;
|
;;
|
||||||
|
x86_64-gem5)
|
||||||
|
defconfig=qemu_x86_64_defconfig
|
||||||
|
;;
|
||||||
arm)
|
arm)
|
||||||
# qemu_arm_vexpress_defconfig required a newer QEMU than 2.0.0 on a Ubuntu host.
|
# qemu_arm_vexpress_defconfig required a newer QEMU than 2.0.0 on a Ubuntu host.
|
||||||
# so let's stick to versatile for now.
|
# so let's stick to versatile for now.
|
||||||
defconfig=qemu_arm_versatile_defconfig
|
defconfig=qemu_arm_versatile_defconfig
|
||||||
;;
|
;;
|
||||||
arm-gem5)
|
arm-gem5)
|
||||||
# qemu_arm_vexpress_defconfig required a newer QEMU than 2.0.0 on a Ubuntu host.
|
# Ideally we should use a custom clean config here.
|
||||||
# so let's stick to versatile for now.
|
# But let's just use this one as a starting point for now.
|
||||||
defconfig=qemu_arm_versatile_defconfig
|
defconfig=qemu_arm_versatile_defconfig
|
||||||
post_script_args="$post_script_args -n"
|
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.
|
# TODO Can't get rid of this for now.
|
||||||
# http://stackoverflow.com/questions/44078245/is-it-possible-to-use-config-fragments-with-buildroots-config
|
# http://stackoverflow.com/questions/44078245/is-it-possible-to-use-config-fragments-with-buildroots-config
|
||||||
cat ../buildroot_config_fragment >> "${outdir}/.config"
|
cat ../buildroot_config_fragment >> "${outdir}/.config"
|
||||||
if [ "$arch" = 'arm-gem5' ]; then
|
if echo "$arch" | grep -Eq -- '-gem5$'; then
|
||||||
echo "\
|
echo "\
|
||||||
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE=\"../kernel_config_gem5\"
|
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE=\"../kernel_config_${arch}\"
|
||||||
" >> "${outdir}/.config"
|
" >> "${outdir}/.config"
|
||||||
else
|
else
|
||||||
echo "\
|
echo "\
|
||||||
@@ -99,6 +102,6 @@ time \
|
|||||||
all \
|
all \
|
||||||
;
|
;
|
||||||
cd ..
|
cd ..
|
||||||
if [ "$arch" = 'arm-gem5' ]; then
|
if echo "$arch" | grep -Eq -- '-gem5$'; then
|
||||||
./build-gem5
|
./build-gem5 -a "$arch"
|
||||||
fi
|
fi
|
||||||
|
|||||||
46
build-gem5
46
build-gem5
@@ -1,18 +1,38 @@
|
|||||||
#/usr/bin/env bash
|
#/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
|
if [ ! -d 'gem5' ]; then
|
||||||
git clone https://gem5.googlesource.com/public/gem5
|
git clone https://gem5.googlesource.com/public/gem5
|
||||||
fi
|
fi
|
||||||
cd gem5
|
cd gem5
|
||||||
git checkout da79d6c6cde0fbe5473ce868c9be4771160a003b
|
git checkout da79d6c6cde0fbe5473ce868c9be4771160a003b
|
||||||
# Compilation fails with gcc 7 on that commit.
|
system_dir='../gem5-system'
|
||||||
# There were some recent portability patches, so it will likely get there soon.
|
binaries_dir="${system_dir}/binaries"
|
||||||
CC=gcc-6 CXX=g++-6 scons -j"$(nproc)" --ignore-style build/ARM/gem5.opt
|
disks_dir="${system_dir}/disks"
|
||||||
make -C system/arm/dt
|
mkdir -p "$binaries_dir" "$disks_dir"
|
||||||
make -C system/arm/simple_bootloader
|
if [ "$arch" = 'x86_64-gem5' ]; then
|
||||||
make -C system/arm/aarch64_bootloader/
|
CC=gcc-6 CXX=g++-6 scons -j"$(nproc)" --ignore-style build/X86/gem5.opt
|
||||||
# TODO use local paths. The search path can be changed with M5_PATH="$(pwd)",
|
f="${disks_dir}/linux-bigswap2.img"
|
||||||
# but the annoying "binaries/" is added in front of it.
|
dd if=/dev/zero of="$f" bs=1024 count=65536
|
||||||
mkdir -p ../gem5-system/binaries
|
mkswap "$f"
|
||||||
cp ./system/arm/simple_bootloader/boot_emm.arm ../gem5-system/binaries
|
# This file must always be present, despite --kernel overriding that default and selecting the kernel.
|
||||||
cp ./system/arm/aarch64_bootloader/boot_emm.arm64 ../gem5-system/binaries
|
# 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
|
## ARM
|
||||||
|
|
||||||
./configure && ./build -a arm-gem5
|
./configure && ./build -a arm-gem5
|
||||||
./rungem5
|
./rungem5 -a arm-gem5
|
||||||
|
|
||||||
On another shell:
|
On another shell:
|
||||||
|
|
||||||
@@ -92,8 +92,28 @@ Related threads:
|
|||||||
|
|
||||||
- <https://www.mail-archive.com/gem5-users@gem5.org/msg11384.html>
|
- <https://www.mail-archive.com/gem5-users@gem5.org/msg11384.html>
|
||||||
- <https://stackoverflow.com/questions/37906425/booting-gem5-x86-ubuntu-full-system-simulation>
|
- <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:
|
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
|
telnet localhost 3456
|
||||||
|
|
||||||
### Unmodified Buildroot images
|
### Unmodified Buildroot images 2
|
||||||
|
|
||||||
bzImage fails, so we always try with vmlinux obtained from inside build/.
|
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
|
#!/usr/bin/env bash
|
||||||
outdir="$(pwd)/buildroot/output.arm-gem5~"
|
arch='arm-gem5'
|
||||||
M5_PATH="$(pwd)/gem5-system" \
|
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/build/ARM/gem5.opt \
|
||||||
gem5/configs/example/fs.py \
|
gem5/configs/example/fs.py \
|
||||||
--disk-image="${outdir}/images/rootfs.ext2" \
|
--disk-image=\"${outdir}/images/rootfs.ext2\" \
|
||||||
--dtb-file="$(pwd)/gem5/system/arm/dt/armv7_gem5_v1_1cpu.dtb" \
|
--dtb-file=\"$(pwd)/gem5/system/arm/dt/armv7_gem5_v1_1cpu.dtb\" \
|
||||||
--kernel="${outdir}/build/linux-custom/vmlinux" \
|
--kernel=\"${outdir}/build/linux-custom/vmlinux\" \
|
||||||
--machine-type='VExpress_GEM5_V1' \
|
--machine-type='VExpress_GEM5_V1' \
|
||||||
--root-device='/dev/sda' \
|
--root-device='/dev/sda' \
|
||||||
;
|
"
|
||||||
|
fi
|
||||||
|
echo "$cmd"
|
||||||
|
eval "$cmd"
|
||||||
|
|||||||
Reference in New Issue
Block a user