gem5: support variants

This commit is contained in:
Ciro Santilli
2018-06-08 17:50:26 +01:00
parent cadb92f2df
commit c7155d0e6f
5 changed files with 41 additions and 12 deletions

20
build
View File

@@ -20,7 +20,7 @@ post_script_args=
qemu_sdl='--enable-sdl --with-sdlabi=2.0' qemu_sdl='--enable-sdl --with-sdlabi=2.0'
suffix= suffix=
v=0 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 case "$OPT" in
a) a)
arch="$OPTARG" arch="$OPTARG"
@@ -81,6 +81,9 @@ BR2_TARGET_ROOTFS_INITRAMFS=n
extra_make_args="${extra_make_args} linux-reconfigure \\ extra_make_args="${extra_make_args} linux-reconfigure \\
" "
;; ;;
M)
common_gem5_variant="$OPTARG"
;;
p) p)
post_script_args="$OPTARG" post_script_args="$OPTARG"
;; ;;
@@ -104,7 +107,7 @@ BR2_TARGET_ROOTFS_INITRAMFS=n
done done
shift $(($OPTIND - 1)) shift $(($OPTIND - 1))
extra_make_args="${extra_make_args} $@" 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" config_file="${buildroot_out_dir}/.config"
case "$arch" in case "$arch" in
x86_64) x86_64)
@@ -170,6 +173,8 @@ BR2_ROOTFS_POST_SCRIPT_ARGS=\"${post_script_args}\"
fi fi
common_mkdir common_mkdir
# Manage Linux kernel variants.
if [ -h "$common_linux_custom_dir" ]; then if [ -h "$common_linux_custom_dir" ]; then
rm "$common_linux_custom_dir" rm "$common_linux_custom_dir"
elif [ -d "$common_linux_custom_dir" ]; then elif [ -d "$common_linux_custom_dir" ]; then
@@ -178,6 +183,16 @@ elif [ -d "$common_linux_custom_dir" ]; then
fi fi
mkdir -p "$common_linux_variant_dir" mkdir -p "$common_linux_variant_dir"
ln -s "$common_linux_variant_dir" "$common_linux_custom_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" cd "$buildroot_dir"
# HOST_QEMU_OPTS is a hack that happens to work because the QEMU package luckly uses += at all times. # 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 # It shouldn't be necessary in the first place: https://bugs.busybox.net/show_bug.cgi?id=9936
@@ -193,6 +208,7 @@ env \\
make \\ make \\
O='${buildroot_out_dir}' \\ O='${buildroot_out_dir}' \\
HOST_QEMU_OPTS='--enable-debug --enable-trace-backends=simple ${qemu_sdl}' \\ HOST_QEMU_OPTS='--enable-debug --enable-trace-backends=simple ${qemu_sdl}' \\
GEM5_LKMC_OUTDIR="$gem5_out_dir" \\
V='${v}' \\ V='${v}' \\
${extra_make_args} \ ${extra_make_args} \
all \\ all \\

11
common
View File

@@ -21,12 +21,16 @@ common_bench_cmd() (
) )
set_common_vars() { set_common_vars() {
linux_variant= linux_variant=
gem5_variant=
OPTIND=1 OPTIND=1
while getopts L: OPT; do while getopts L:M: OPT; do
case "$OPT" in case "$OPT" in
L) L)
linux_variant="$OPTARG" linux_variant="$OPTARG"
;; ;;
M)
gem5_variant="$OPTARG"
;;
esac esac
done done
echo $OPTIND echo $OPTIND
@@ -75,6 +79,7 @@ set_common_vars() {
common_linux_custom_dir="${build_dir}/linux-custom" common_linux_custom_dir="${build_dir}/linux-custom"
common_linux_variant_dir="${common_linux_custom_dir}.${linux_variant}" common_linux_variant_dir="${common_linux_custom_dir}.${linux_variant}"
common_vmlinux="${common_linux_variant_dir}/vmlinux" common_vmlinux="${common_linux_variant_dir}/vmlinux"
gem5_out_dir="${common_dir}/gem5.${gem5_variant}"
case "$arch" in case "$arch" in
arm) arm)
common_linux_image=arch/arm/boot/zImage common_linux_image=arch/arm/boot/zImage
@@ -100,6 +105,7 @@ common_mkdir() (
; ;
) )
common_linux_variant=default common_linux_variant=default
common_gem5_variant=default
root_dir="$(pwd)" root_dir="$(pwd)"
out_dir="${root_dir}/out" out_dir="${root_dir}/out"
common_bench_boot="${out_dir}/bench-boot.txt" common_bench_boot="${out_dir}/bench-boot.txt"
@@ -107,7 +113,8 @@ data_dir="${root_dir}/data"
p9_dir="${data_dir}/9p" p9_dir="${data_dir}/9p"
readfile_file="${data_dir}/readfile" readfile_file="${data_dir}/readfile"
common_dir="${out_dir}/common" 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" f="${data_dir}/cli"
if [ -f "$f" ]; then if [ -f "$f" ]; then
. "$f" . "$f"

View File

@@ -3,7 +3,7 @@ set -eu
arch=x86_64 arch=x86_64
cross_compile= cross_compile=
j= j=
outdir="$(pwd)/out" outdir="$(pwd)"
while getopts a:c:j:o: OPT; do while getopts a:c:j:o: OPT; do
case "$OPT" in case "$OPT" in
a) a)
@@ -28,7 +28,6 @@ system_dir="${outdir}/system"
binaries_dir="${system_dir}/binaries" binaries_dir="${system_dir}/binaries"
disks_dir="${system_dir}/disks" disks_dir="${system_dir}/disks"
mkdir -p "$binaries_dir" "$disks_dir" mkdir -p "$binaries_dir" "$disks_dir"
cd "gem5"
if [ "$arch" = x86_64 ]; then if [ "$arch" = x86_64 ]; then
scons -j "$j" --ignore-style "${outdir}/build/X86/gem5.opt" scons -j "$j" --ignore-style "${outdir}/build/X86/gem5.opt"
f="${disks_dir}/linux-bigswap2.img" f="${disks_dir}/linux-bigswap2.img"

View File

@@ -16,7 +16,13 @@ endif
define GEM5_BUILD_CMDS define GEM5_BUILD_CMDS
# Cannot pass "-c '$(TARGET_CROSS)'" here because the ARM build uses aarch64 for the bootloader... # 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. # This would build inside the buildroot directory as a more normal package.
#cd '$(@D)' && ./build -a '$(ARCH)' -j '$(BR2_JLEVEL)' #cd '$(@D)' && ./build -a '$(ARCH)' -j '$(BR2_JLEVEL)'

11
run
View File

@@ -34,7 +34,7 @@ trace_enabled=false
# just to prevent QEMU from emitting a warning that '' is not valid. # just to prevent QEMU from emitting a warning that '' is not valid.
trace_type=pr_manager_run trace_type=pr_manager_run
vnc= 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 case "$OPT" in
a) a)
arch="$OPTARG" arch="$OPTARG"
@@ -94,6 +94,9 @@ while getopts a:c:DdE:e:F:f:G:ghIiKkL:m:PT:U:uVx OPT; do
L) L)
common_linux_variant="$OPTARG" common_linux_variant="$OPTARG"
;; ;;
M)
common_gem5_variant="$OPTARG"
;;
m) m)
memory="$OPTARG" memory="$OPTARG"
;; ;;
@@ -124,7 +127,7 @@ while getopts a:c:DdE:e:F:f:G:ghIiKkL:m:PT:U:uVx OPT; do
done done
shift "$(($OPTIND - 1))" shift "$(($OPTIND - 1))"
extra_flags="$extra_flags $@" 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" images_dir="${buildroot_out_dir}/images"
if "$debug" && "$kvm"; then if "$debug" && "$kvm"; then
echo 'error: -d and -K are incompatible' 1>&2 echo 'error: -d and -K are incompatible' 1>&2
@@ -156,8 +159,6 @@ if [ -n "$extra_append_after_dash" ]; then
fi fi
if "$gem5"; then 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" gem5_system_dir="${gem5_out_dir}/system"
memory="${memory}B" memory="${memory}B"
if [ "$arch" = x86_64 ]; then if [ "$arch" = x86_64 ]; then
@@ -176,7 +177,7 @@ ${debug_vm} \
--debug-file=trace.txt \\ --debug-file=trace.txt \\
${gem5opts} \ ${gem5opts} \
-d '${m5out_dir}' \\ -d '${m5out_dir}' \\
'${gem5_src_dir}/configs/example/fs.py' \\ '${gem5_out_dir}/configs/example/fs.py' \\
--disk-image='${images_dir}/rootfs.ext2' \\ --disk-image='${images_dir}/rootfs.ext2' \\
--kernel='${common_vmlinux}' \\ --kernel='${common_vmlinux}' \\
--mem-size='${memory}' \\ --mem-size='${memory}' \\