Skip to content

Update disk image source to addhypercall and gem5bridge-driver #69

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: stable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
8459cdf
resources: Add hypercall for x86 base disk image
Harshil2107 Feb 4, 2025
e6c5228
resources: Update scripts to add and build gem5 bridge driver for x86…
Harshil2107 Feb 4, 2025
fa35116
resources: Update exit event call to hypercall for the arm disk images
Harshil2107 Feb 4, 2025
c6e44ec
resources: Add dockerfile to make kernel and modules for arm disk image
Harshil2107 Feb 4, 2025
ef1b6ef
resources: Update serial-getty service to override service section
Harshil2107 Feb 5, 2025
0f24310
resources: split post-installation.sh to smaller scripts
Harshil2107 Feb 5, 2025
c4bd6eb
resources: update arm packer file to run correct shell script
Harshil2107 Feb 5, 2025
bfb74f1
resources: update gem5_init to insert the gem5 bridge driver
Harshil2107 Feb 5, 2025
17e8740
resources: Add a script to increase system entropy for arm
Harshil2107 Feb 5, 2025
c2b0f3b
resources: Update documentation for building disk images
Harshil2107 Feb 5, 2025
ec7c7b6
resources: Update github clone link to clone from staging branch
Harshil2107 Feb 5, 2025
6edc682
resources: Update the increase-system-entropy script
Harshil2107 Feb 5, 2025
695c7dd
resources: Update make command in dockerfile to use nproc
Harshil2107 Feb 5, 2025
05d7bce
resources: update NPB disk image to use hypercall instead of workbegi…
Harshil2107 Feb 6, 2025
f26c38b
resources: Update Dockerfile for building kernel and modules for 22.0…
Harshil2107 Feb 6, 2025
819ed59
resources: Update documentation for building base disk images
Harshil2107 Feb 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/npb-24.04-imgs/arm-npb.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ source "qemu" "initialize" {
format = "raw"
headless = "true"
disk_image = "true"
iso_checksum = "sha256:eb94422a3908c6c5183c03666b278b6e8bcfbde04da3d7c3bb5374bc82e0ef48"
iso_urls = ["./arm-ubuntu-24.04-20240823"]
iso_checksum = "sha256:50cd77b981f149ef291a0ad36ad7f7f03fb9f31236c7969fe0b91151fdda768f"
iso_urls = ["../ubuntu-generic-diskimages/arm-disk-image-24-04/arm-ubuntu"]
memory = "8192"
output_directory = "disk-image-arm-npb"
qemu_binary = "/usr/bin/qemu-system-aarch64"
Expand Down
4 changes: 2 additions & 2 deletions src/npb-24.04-imgs/npb-with-roi/NPB/NPB3.4-OMP/common/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ void m5_work_begin_interface_()
{

printf(" -------------------- ROI BEGIN -------------------- \n");
m5_work_begin_addr(0,0);
m5_hypercall_addr(4);
}

void m5_work_end_interface_()
{
m5_work_end_addr(0,0);
m5_hypercall_addr(5);
printf(" -------------------- ROI END -------------------- \n");
}
4 changes: 2 additions & 2 deletions src/npb-24.04-imgs/x86-npb.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ source "qemu" "initialize" {
format = "raw"
headless = "true"
disk_image = "true"
iso_checksum = "sha256:6cedf26ebf281b823b24722341d3a2ab1f1ba26b10b536916d3f23cf92a8f4b5"
iso_urls = ["./x86-ubuntu-24-04-v2"]
iso_checksum = "sha256:b1f8421956d374207ebca70f176374ff9e1e8c46f74bfb2c47a6583e4eae758e"
iso_urls = ["../ubuntu-generic-diskimages/x86-disk-image-24-04/x86-ubuntu"]
memory = "8192"
output_directory = "disk-image-x86-npb"
qemu_binary = "/usr/bin/qemu-system-x86_64"
Expand Down
230 changes: 130 additions & 100 deletions src/ubuntu-generic-diskimages/BUILDING.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/ubuntu-generic-diskimages/files/arm/after_boot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# gem5-bridge exit signifying that after_boot.sh is running
printf "In after_boot.sh...\n"
gem5-bridge --addr=0x10010000 exit # TODO: Make this a specialized event.
gem5-bridge --addr=0x10010000 hypercall 2

# Read /proc/cmdline and parse options

Expand Down Expand Up @@ -51,7 +51,7 @@ else
/tmp/script
printf "Done running script from gem5-bridge, exiting.\n"
rm -f /tmp/script
gem5-bridge --addr=0x10010000 exit
gem5-bridge --addr=0x10010000 hypercall 3
fi
fi
fi
18 changes: 17 additions & 1 deletion src/ubuntu-generic-diskimages/files/arm/gem5_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,27 @@ mount -t sysfs /sys /sys
cmdline=$(cat /proc/cmdline)
no_systemd=false

# Load gem5_bridge driver
## Default parameters (ARM64)
gem5_bridge_baseaddr=0x10010000
gem5_bridge_rangesize=0x10000
## Try to read overloads from kernel arguments
if [[ $cmdline =~ gem5_bridge_baseaddr=([[:alnum:]]+) ]]; then
gem5_bridge_baseaddr=${BASH_REMATCH[1]}
fi
if [[ $cmdline =~ gem5_bridge_rangesize=([[:alnum:]]+) ]]; then
gem5_bridge_rangesize=${BASH_REMATCH[1]}
fi
## Insert driver
modprobe gem5_bridge \
gem5_bridge_baseaddr=$gem5_bridge_baseaddr \
gem5_bridge_rangesize=$gem5_bridge_rangesize

# gem5-bridge exit signifying that kernel is booted
# This will cause the simulation to exit. Note that this will
# cause qemu to fail.
printf "Kernel booted, In gem5 init...\n"
gem5-bridge --addr=0x10010000 exit # TODO: Make this a specialized event.
gem5-bridge --addr=0x10010000 hypercall 1

if [[ $cmdline == *"no_systemd"* ]]; then
no_systemd=true
Expand Down
46 changes: 0 additions & 46 deletions src/ubuntu-generic-diskimages/files/[email protected]

This file was deleted.

4 changes: 4 additions & 0 deletions src/ubuntu-generic-diskimages/files/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin gem5 --keep-baud 115200,38400,9600 %I $TERM
4 changes: 2 additions & 2 deletions src/ubuntu-generic-diskimages/files/x86/after_boot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# gem5-bridge exit signifying that after_boot.sh is running
printf "In after_boot.sh...\n"
gem5-bridge exit # TODO: Make this a specialized event.
gem5-bridge hypercall 2

# Read /proc/cmdline and parse options

Expand Down Expand Up @@ -51,7 +51,7 @@ else
/tmp/script
printf "Done running script from gem5-bridge, exiting.\n"
rm -f /tmp/script
gem5-bridge exit
gem5-bridge hypercall 3
fi
fi
fi
18 changes: 17 additions & 1 deletion src/ubuntu-generic-diskimages/files/x86/gem5_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,27 @@ mount -t sysfs /sys /sys
cmdline=$(cat /proc/cmdline)
no_systemd=false

# Load gem5_bridge driver
## Default parameters (x86_64)
gem5_bridge_baseaddr=0xffff0000
gem5_bridge_rangesize=0x10000
## Try to read overloads from kernel arguments
if [[ $cmdline =~ gem5_bridge_baseaddr=([[:alnum:]]+) ]]; then
gem5_bridge_baseaddr=${BASH_REMATCH[1]}
fi
if [[ $cmdline =~ gem5_bridge_rangesize=([[:alnum:]]+) ]]; then
gem5_bridge_rangesize=${BASH_REMATCH[1]}
fi
## Insert driver
modprobe gem5_bridge \
gem5_bridge_baseaddr=$gem5_bridge_baseaddr \
gem5_bridge_rangesize=$gem5_bridge_rangesize

# gem5-bridge exit signifying that kernel is booted
# This will cause the simulation to exit. Note that this will
# cause qemu to fail.
printf "Kernel booted, In gem5 init...\n"
gem5-bridge exit # TODO: Make this a specialized event.
gem5-bridge hypercall 1

if [[ $cmdline == *"no_systemd"* ]]; then
no_systemd=true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
FROM ubuntu:22.04 AS stage1

# Install necessary packages for kernel build
RUN apt update && apt install -y \
build-essential \
libncurses-dev \
bison \
flex \
libssl-dev \
libelf-dev \
bc \
wget \
git \
kmod \
apt-src \
vim \
curl \
file

RUN sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list
RUN apt update
RUN mkdir /workspace
RUN cd /workspace && apt source linux-image-unsigned-5.15.0-25-generic

RUN cd /workspace/linux-5.15.0 && \
cd scripts && \
chmod +x pahole-version.sh && \
cd .. && \
make defconfig && \
make -j $(nproc) && \
make INSTALL_MOD_PATH=/workspace/output modules_install

RUN git clone https://github.com/gem5/gem5.git --depth=1 --filter=blob:none --no-checkout --sparse --single-branch --branch=release-staging-v24-1-1-0 && \
Copy link
Contributor

@erin-le erin-le Feb 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once the minor release staging branch is merged, remember to change this to stable.

cd gem5 && \
git sparse-checkout add util/m5 && \
git sparse-checkout add util/gem5_bridge && \
git sparse-checkout add include && \
git checkout

RUN cd gem5/util/gem5_bridge && \
make KMAKEDIR=/workspace/linux-5.15.0 INSTALL_MOD_PATH=/workspace/output build install

RUN cd /workspace/output/lib/modules/5.15.168 && \
rm -rf build source

FROM scratch AS export-stage
COPY --from=stage1 /workspace/output/lib/modules .
COPY --from=stage1 workspace/linux-5.15.0/vmlinux .
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

# Copyright (c) 2025 The Regents of the University of California.
# SPDX-License-Identifier: BSD 3-Clause

DOCKERFILE="Dockerfile"
OUTPUT="my-arm-5.15.168-kernel"

# Build the Docker image
DOCKER_BUILDKIT=1 docker build --no-cache \
--file "$DOCKERFILE" \
--output "$OUTPUT" .

echo "Build completed for $1: Output directory is $OUTPUT"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now, this message is printed even if the build fails. It would be nice if a different message could be printed for a failure, but it's not high priority.

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Start from Ubuntu 24.04 base image
FROM ubuntu:24.04 AS stage1

# Install necessary packages for kernel and module build
RUN apt update && apt install -y \
build-essential \
libncurses-dev \
bison \
flex \
libssl-dev \
libelf-dev \
bc \
wget \
git \
kmod


RUN sed -i 's/^Types: deb$/Types: deb deb-src/' /etc/apt/sources.list.d/ubuntu.sources
RUN apt update
RUN mkdir /workspace
RUN cd /workspace && apt source linux-image-unsigned-6.8.0-47-generic

RUN cd /workspace/linux-6.8.0 && \
make defconfig && \
make -j $(nproc) && \
make INSTALL_MOD_PATH=/workspace/output modules_install

RUN git clone https://github.com/gem5/gem5.git --depth=1 --filter=blob:none --no-checkout --sparse --single-branch --branch=release-staging-v24-1-1-0 && \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once the minor release staging branch is merged, remember to change this to stable.

cd gem5 && \
git sparse-checkout add util/m5 && \
git sparse-checkout add util/gem5_bridge && \
git sparse-checkout add include && \
git checkout

RUN cd gem5/util/gem5_bridge && \
make KMAKEDIR=/workspace/linux-6.8.0 INSTALL_MOD_PATH=/workspace/output build install

RUN cd /workspace/output/lib/modules/6.8.12 && \
rm -rf build

FROM scratch AS export-stage
COPY --from=stage1 /workspace/output/lib/modules .
COPY --from=stage1 /workspace/linux-6.8.0/vmlinux .
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

# Copyright (c) 2025 The Regents of the University of California.
# SPDX-License-Identifier: BSD 3-Clause

DOCKERFILE="./Dockerfile"
OUTPUT="my-arm-6.8.12-kernel"

# Build the Docker image
DOCKER_BUILDKIT=1 docker build --no-cache \
--file "$DOCKERFILE" \
--output "$OUTPUT" .

echo "Build completed for $1: Output directory is $OUTPUT"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now, this message is printed even if the build fails. It would be nice if a different message could be printed for a failure, but it's not high priority.

28 changes: 26 additions & 2 deletions src/ubuntu-generic-diskimages/packer-scripts/arm-ubuntu.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ locals {
iso_checksum = "sha256:c209ab013280d3cd26a344def60b7b19fbb427de904ea285057d94ca6ac82dd5"
output_dir = "arm-disk-image-22-04"
http_directory = "http/arm-22-04"
modules_dir = "kernel-and-modules/arm-ubuntu-22.04/my-arm-5.15.168-kernel/5.15.168"
}
"24.04" = {
iso_url = "https://cdimage.ubuntu.com/releases/24.04/release/ubuntu-24.04-live-server-arm64.iso"
iso_checksum = "sha256:d2d9986ada3864666e36a57634dfc97d17ad921fa44c56eeaca801e7dab08ad7"
output_dir = "arm-disk-image-24-04"
http_directory = "http/arm-24-04"
modules_dir = "kernel-and-modules/arm-ubuntu-24.04/my-arm-6.8.12-kernel/6.8.12"
}
}
}
Expand Down Expand Up @@ -130,13 +132,35 @@ build {

provisioner "file" {
destination = "/home/gem5/"
source = "files/[email protected]"
source = "files/[email protected]"
}

provisioner "file" {
destination = "/home/gem5/"
source = "${local.iso_data[var.ubuntu_version].modules_dir}"
}

provisioner "shell" {
execute_command = "echo '${var.ssh_password}' | {{ .Vars }} sudo -E -S bash '{{ .Path }}'"
scripts = ["scripts/post-installation.sh"]
scripts = ["scripts/install-common-packages.sh",
"scripts/increase-system-entropy-for-arm-disk.sh",
"scripts/update-modules-arm-${var.ubuntu_version}.sh",
"scripts/update-gem5-init.sh",
"scripts/install-gem5-bridge.sh",
"scripts/install-user-packages.sh",
]
environment_vars = ["ISA=arm64"]
expect_disconnect = true
}

provisioner "shell" {
scripts = ["scripts/install-user-benchmarks.sh"]
}

provisioner "shell" {
execute_command = "echo '${var.ssh_password}' | {{ .Vars }} sudo -E -S bash '{{ .Path }}'"
scripts = ["scripts/disable-network.sh"]
expect_disconnect = true
}

}
Loading