Skip to content

Commit 51256ab

Browse files
committed
resources: Scripts to build disk with gem5 driver
This change adds scripts to build disk-images that include an installation of gem5-bridge kernel object so that m5 memory can be mapped without the need for sudo access. This is necessary when benchmarks should not be run with sudo permission, e.g. when using MPI runtimes. Additionally, it further breaks down the installation steps to more granular steps that are easier to understand and potentially debug.
1 parent 6f8d494 commit 51256ab

33 files changed

+468
-256
lines changed

src/ubuntu-generic-diskimages/build-arm.sh renamed to src/ubuntu-generic-disk-images/build-arm.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,21 @@ if [[ "$ubuntu_version" != "22.04" && "$ubuntu_version" != "24.04" ]]; then
2929
exit 1
3030
fi
3131

32-
# make the flash0.sh file
32+
# Create a dictionary to store the path to the kernel modules for each Ubuntu version
33+
declare -A kernel_modules_paths
34+
kernel_modules_paths["22.04"]="modules/u2204"
35+
kernel_modules_paths["24.04"]="modules/u2404/"
36+
37+
# Get the path to the kernel modules for the specified Ubuntu version
38+
kernel_modules_path=${kernel_modules_paths[$ubuntu_version]}
39+
pushd $kernel_modules_path
40+
./copy_modules.sh
41+
popd
42+
43+
# Store the image name from the second command line argument or default to "arm-ubuntu"
44+
image_name="${2:-arm-ubuntu}"
45+
46+
# make the flash0.img file
3347
cd ./files
3448
dd if=/dev/zero of=flash0.img bs=1M count=64
3549
dd if=/usr/share/qemu-efi-aarch64/QEMU_EFI.fd of=flash0.img conv=notrunc
@@ -39,4 +53,4 @@ cd ..
3953
./packer init ./packer-scripts/arm-ubuntu.pkr.hcl
4054

4155
# Build the image with the specified Ubuntu version
42-
./packer build -var "ubuntu_version=${ubuntu_version}" ./packer-scripts/arm-ubuntu.pkr.hcl
56+
./packer build -var "ubuntu_version=${ubuntu_version}" -var "image_name=${image_name}" ./packer-scripts/arm-ubuntu.pkr.hcl

src/ubuntu-generic-diskimages/files/arm/gem5_init.sh renamed to src/ubuntu-generic-disk-images/files/arm/gem5_init.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,25 @@ mount -t sysfs /sys /sys
1515
cmdline=$(cat /proc/cmdline)
1616
no_systemd=false
1717

18+
# Load gem5_bridge driver
19+
## Default parameters (ARM64)
20+
gem5_bridge_baseaddr=0x10010000
21+
gem5_bridge_rangesize=0x10000
22+
## Try to read overloads from kernel arguments
23+
if [[ $cmdline =~ gem5_bridge_baseaddr=([[:alnum:]]+) ]]; then
24+
gem5_bridge_baseaddr=${BASH_REMATCH[1]}
25+
fi
26+
if [[ $cmdline =~ gem5_bridge_rangesize=([[:alnum:]]+) ]]; then
27+
gem5_bridge_rangesize=${BASH_REMATCH[1]}
28+
fi
29+
## Insert driver
30+
modprobe gem5_bridge \
31+
gem5_bridge_baseaddr=$gem5_bridge_baseaddr \
32+
gem5_bridge_rangesize=$gem5_bridge_rangesize
33+
34+
# see if this modprode fails or not
35+
# print warning if it fails, gem5-bridge module is not going to work, you will need sudo for running exit events
36+
1837
# gem5-bridge exit signifying that kernel is booted
1938
# This will cause the simulation to exit. Note that this will
2039
# cause qemu to fail.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[Service]
2+
ExecStart=
3+
ExecStart=-/sbin/agetty --autologin gem5 --keep-baud 115200,38400,9600 %I $TERM

src/ubuntu-generic-diskimages/http/arm-22-04/user-data renamed to src/ubuntu-generic-disk-images/http/arm-2204/user-data

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ autoinstall:
7070
type: format
7171
id: format-0
7272
- device: disk-vda
73-
size: 4257218560
73+
size: 20909654016
7474
wipe: superblock
7575
flag: ''
7676
number: 2
@@ -92,4 +92,4 @@ autoinstall:
9292
type: mount
9393
id: mount-0
9494
updates: security
95-
version: 1
95+
version: 1

0 commit comments

Comments
 (0)