mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-13 20:12:26 +00:00
gem5: support variants
This commit is contained in:
20
build
20
build
@ -20,7 +20,7 @@ post_script_args=
|
||||
qemu_sdl='--enable-sdl --with-sdlabi=2.0'
|
||||
suffix=
|
||||
v=0
|
||||
while getopts 'a:B:b:C:c:fGgj:hIiK:kL:lp:qSs:v' OPT; do
|
||||
while getopts 'a:B:b:C:c:fGgj:hIiK:kL:lM:p:qSs:v' OPT; do
|
||||
case "$OPT" in
|
||||
a)
|
||||
arch="$OPTARG"
|
||||
@ -81,6 +81,9 @@ BR2_TARGET_ROOTFS_INITRAMFS=n
|
||||
extra_make_args="${extra_make_args} linux-reconfigure \\
|
||||
"
|
||||
;;
|
||||
M)
|
||||
common_gem5_variant="$OPTARG"
|
||||
;;
|
||||
p)
|
||||
post_script_args="$OPTARG"
|
||||
;;
|
||||
@ -104,7 +107,7 @@ BR2_TARGET_ROOTFS_INITRAMFS=n
|
||||
done
|
||||
shift $(($OPTIND - 1))
|
||||
extra_make_args="${extra_make_args} $@"
|
||||
set_common_vars -L "$common_linux_variant" "$arch" "$gem5" "$suffix"
|
||||
set_common_vars -L "$common_linux_variant" -M "$common_gem5_variant" "$arch" "$gem5" "$suffix"
|
||||
config_file="${buildroot_out_dir}/.config"
|
||||
case "$arch" in
|
||||
x86_64)
|
||||
@ -170,6 +173,8 @@ BR2_ROOTFS_POST_SCRIPT_ARGS=\"${post_script_args}\"
|
||||
fi
|
||||
|
||||
common_mkdir
|
||||
|
||||
# Manage Linux kernel variants.
|
||||
if [ -h "$common_linux_custom_dir" ]; then
|
||||
rm "$common_linux_custom_dir"
|
||||
elif [ -d "$common_linux_custom_dir" ]; then
|
||||
@ -178,6 +183,16 @@ elif [ -d "$common_linux_custom_dir" ]; then
|
||||
fi
|
||||
mkdir -p "$common_linux_variant_dir"
|
||||
ln -s "$common_linux_variant_dir" "$common_linux_custom_dir"
|
||||
|
||||
# Manage gem5 variants.
|
||||
if "$gem5"; then
|
||||
if [ -e "${gem5_out_dir}/.git" ]; then
|
||||
git -C "$gem5_out_dir" checkout "$(git -C "$common_gem5_src_dir" log -n 1 --format='%H')"
|
||||
else
|
||||
git -C "$common_gem5_src_dir" worktree add -b "${common_gem5_variant}" "${gem5_out_dir}"
|
||||
fi
|
||||
fi
|
||||
|
||||
cd "$buildroot_dir"
|
||||
# HOST_QEMU_OPTS is a hack that happens to work because the QEMU package luckly uses += at all times.
|
||||
# It shouldn't be necessary in the first place: https://bugs.busybox.net/show_bug.cgi?id=9936
|
||||
@ -193,6 +208,7 @@ env \\
|
||||
make \\
|
||||
O='${buildroot_out_dir}' \\
|
||||
HOST_QEMU_OPTS='--enable-debug --enable-trace-backends=simple ${qemu_sdl}' \\
|
||||
GEM5_LKMC_OUTDIR="$gem5_out_dir" \\
|
||||
V='${v}' \\
|
||||
${extra_make_args} \
|
||||
all \\
|
||||
|
||||
11
common
11
common
@ -21,12 +21,16 @@ common_bench_cmd() (
|
||||
)
|
||||
set_common_vars() {
|
||||
linux_variant=
|
||||
gem5_variant=
|
||||
OPTIND=1
|
||||
while getopts L: OPT; do
|
||||
while getopts L:M: OPT; do
|
||||
case "$OPT" in
|
||||
L)
|
||||
linux_variant="$OPTARG"
|
||||
;;
|
||||
M)
|
||||
gem5_variant="$OPTARG"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
echo $OPTIND
|
||||
@ -75,6 +79,7 @@ set_common_vars() {
|
||||
common_linux_custom_dir="${build_dir}/linux-custom"
|
||||
common_linux_variant_dir="${common_linux_custom_dir}.${linux_variant}"
|
||||
common_vmlinux="${common_linux_variant_dir}/vmlinux"
|
||||
gem5_out_dir="${common_dir}/gem5.${gem5_variant}"
|
||||
case "$arch" in
|
||||
arm)
|
||||
common_linux_image=arch/arm/boot/zImage
|
||||
@ -100,6 +105,7 @@ common_mkdir() (
|
||||
;
|
||||
)
|
||||
common_linux_variant=default
|
||||
common_gem5_variant=default
|
||||
root_dir="$(pwd)"
|
||||
out_dir="${root_dir}/out"
|
||||
common_bench_boot="${out_dir}/bench-boot.txt"
|
||||
@ -107,7 +113,8 @@ data_dir="${root_dir}/data"
|
||||
p9_dir="${data_dir}/9p"
|
||||
readfile_file="${data_dir}/readfile"
|
||||
common_dir="${out_dir}/common"
|
||||
gem5_out_dir="${common_dir}/gem5"
|
||||
gem5_variant=default
|
||||
common_gem5_src_dir="${root_dir}/gem5/gem5"
|
||||
f="${data_dir}/cli"
|
||||
if [ -f "$f" ]; then
|
||||
. "$f"
|
||||
|
||||
@ -3,7 +3,7 @@ set -eu
|
||||
arch=x86_64
|
||||
cross_compile=
|
||||
j=
|
||||
outdir="$(pwd)/out"
|
||||
outdir="$(pwd)"
|
||||
while getopts a:c:j:o: OPT; do
|
||||
case "$OPT" in
|
||||
a)
|
||||
@ -28,7 +28,6 @@ system_dir="${outdir}/system"
|
||||
binaries_dir="${system_dir}/binaries"
|
||||
disks_dir="${system_dir}/disks"
|
||||
mkdir -p "$binaries_dir" "$disks_dir"
|
||||
cd "gem5"
|
||||
if [ "$arch" = x86_64 ]; then
|
||||
scons -j "$j" --ignore-style "${outdir}/build/X86/gem5.opt"
|
||||
f="${disks_dir}/linux-bigswap2.img"
|
||||
|
||||
@ -16,7 +16,13 @@ endif
|
||||
|
||||
define GEM5_BUILD_CMDS
|
||||
# Cannot pass "-c '$(TARGET_CROSS)'" here because the ARM build uses aarch64 for the bootloader...
|
||||
cd '$(GEM5_SITE)' && ./build -a '$(ARCH)' -j '$(BR2_JLEVEL)' -o '$(GEM5_SITE)/../out/common/gem5'
|
||||
cd '$(GEM5_LKMC_OUTDIR)' && '$(GEM5_SITE)/build' -a '$(ARCH)' -j '$(BR2_JLEVEL)'
|
||||
|
||||
# This would build using the submodule source out of tree.
|
||||
# We gave up on it because in the end we still need the python scripts to match:
|
||||
# we need to have an entire copy of the tree somwhere to switch between them.
|
||||
#cd '$(GEM5_SITE)/gem5' && ../build -a '$(ARCH)' -j '$(BR2_JLEVEL)' -o '$(GEM5_SITE)/../out/common/gem5'
|
||||
|
||||
# This would build inside the buildroot directory as a more normal package.
|
||||
#cd '$(@D)' && ./build -a '$(ARCH)' -j '$(BR2_JLEVEL)'
|
||||
|
||||
|
||||
11
run
11
run
@ -34,7 +34,7 @@ trace_enabled=false
|
||||
# just to prevent QEMU from emitting a warning that '' is not valid.
|
||||
trace_type=pr_manager_run
|
||||
vnc=
|
||||
while getopts a:c:DdE:e:F:f:G:ghIiKkL:m:PT:U:uVx OPT; do
|
||||
while getopts a:c:DdE:e:F:f:G:ghIiKkL:M:m:PT:U:uVx OPT; do
|
||||
case "$OPT" in
|
||||
a)
|
||||
arch="$OPTARG"
|
||||
@ -94,6 +94,9 @@ while getopts a:c:DdE:e:F:f:G:ghIiKkL:m:PT:U:uVx OPT; do
|
||||
L)
|
||||
common_linux_variant="$OPTARG"
|
||||
;;
|
||||
M)
|
||||
common_gem5_variant="$OPTARG"
|
||||
;;
|
||||
m)
|
||||
memory="$OPTARG"
|
||||
;;
|
||||
@ -124,7 +127,7 @@ while getopts a:c:DdE:e:F:f:G:ghIiKkL:m:PT:U:uVx OPT; do
|
||||
done
|
||||
shift "$(($OPTIND - 1))"
|
||||
extra_flags="$extra_flags $@"
|
||||
set_common_vars -L "$common_linux_variant" "$arch" "$gem5"
|
||||
set_common_vars -L "$common_linux_variant" -M "$common_gem5_variant" "$arch" "$gem5"
|
||||
images_dir="${buildroot_out_dir}/images"
|
||||
if "$debug" && "$kvm"; then
|
||||
echo 'error: -d and -K are incompatible' 1>&2
|
||||
@ -156,8 +159,6 @@ if [ -n "$extra_append_after_dash" ]; then
|
||||
fi
|
||||
|
||||
if "$gem5"; then
|
||||
gem5_build_dir="${buildroot_out_dir}/build/gem5-1.0"
|
||||
gem5_src_dir="${root_dir}/gem5/gem5"
|
||||
gem5_system_dir="${gem5_out_dir}/system"
|
||||
memory="${memory}B"
|
||||
if [ "$arch" = x86_64 ]; then
|
||||
@ -176,7 +177,7 @@ ${debug_vm} \
|
||||
--debug-file=trace.txt \\
|
||||
${gem5opts} \
|
||||
-d '${m5out_dir}' \\
|
||||
'${gem5_src_dir}/configs/example/fs.py' \\
|
||||
'${gem5_out_dir}/configs/example/fs.py' \\
|
||||
--disk-image='${images_dir}/rootfs.ext2' \\
|
||||
--kernel='${common_vmlinux}' \\
|
||||
--mem-size='${memory}' \\
|
||||
|
||||
Reference in New Issue
Block a user