Skip to content

Commit 1e3a072

Browse files
committed
x86_64: edk2 + linux + ubuntu
There is no support for virtualization emulation on this platform.
1 parent 8105738 commit 1e3a072

File tree

15 files changed

+111
-200
lines changed

15 files changed

+111
-200
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ jobs:
2424
- run: sudo sed -i -e "s/ deb$/ deb deb-src/" /etc/apt/sources.list.d/ubuntu.sources
2525
- run: sudo apt update && sudo apt build-dep -y qemu
2626
- run: git clone https://gitlab.com/qemu-project/qemu --branch v10.0.2 --single-branch --depth 1
27-
- run: cd qemu && ./configure --target-list=aarch64-softmmu && ninja -C build && cd ..
27+
- run: cd qemu && ./configure --target-list=x86_64-softmmu && ninja -C build && cd ..
2828

2929
- run: echo "----- build stack -----"
3030
- run: sudo apt update && sudo apt install -y podman qemu-user-static
3131
- run: ./build.sh
3232

33-
- run: echo "----- run nested guest and exit -----"
34-
- run: INIT='env INIT=true /host/guest.sh qemu-system-aarch64' ./run.sh ./qemu/build/qemu-system-aarch64
33+
- run: echo "----- run guest and exit -----"
34+
- run: INIT='true' ./run.sh ./qemu/build/qemu-system-x86_64
3535

3636
- run: echo "----- create artifacts ------"
3737
- run: echo $(basename ${{github.ref}}) > branch

Dockerfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ FROM docker.io/debian:trixie
33
RUN apt update && apt install -y \
44
build-essential \
55
git \
6-
gcc-aarch64-linux-gnu \
7-
g++-aarch64-linux-gnu \
6+
gcc-x86-64-linux-gnu \
7+
g++-x86-64-linux-gnu \
88
bison \
99
flex \
1010
bc \
@@ -23,10 +23,14 @@ libgnutls28-dev
2323
RUN apt update && apt install -y ccache
2424
RUN apt update && apt install -y clang-tools
2525
RUN ln -s /usr/bin/intercept-build-* /usr/bin/intercept-build
26+
RUN apt update && apt install -y \
27+
libelf-dev
28+
RUN apt update && \
29+
apt install -y uuid-dev python-is-python3 nasm acpica-tools
2630

2731
# wrap compilers to call ccache, keep frame pointer, and enable debug info
2832
RUN mkdir /opt/compiler_wrappers && \
29-
for c in gcc g++ aarch64-linux-gnu-gcc aarch64-linux-gnu-g++; do \
33+
for c in gcc g++ x86_64-linux-gnu-gcc x86_64-linux-gnu-g++; do \
3034
f=/opt/compiler_wrappers/$c && \
3135
echo '#!/usr/bin/env bash' >> $f && \
3236
echo 'args="-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ggdb3"' >> $f && \

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ Thus, update or switch branches should not require any ``git clean -ffdx``.
2828
./build.sh
2929
3030
# run system using:
31-
./run.sh /path/to/qemu-system-aarch64
31+
./run.sh /path/to/qemu-system-x86_64
3232
# exit QEMU with ctrl-a + x
3333
3434
# debug kernel, firmwares and bootloader using:
35-
./debug.sh /path/to/qemu-system-aarch64
36-
# additional gdb commands were added, like arm-exception-level. See gdb.py.
35+
./debug.sh /path/to/qemu-system-x86_64
36+
# additional gdb commands were added, like x64-privilege-level. See gdb.py.
3737
3838
# to debug qemu itself:
39-
./run.sh gdb --args /path/to/qemu-system-aarch64
39+
./run.sh gdb --args /path/to/qemu-system-x86_64
4040
4141
# to create an archive containing the whole stack:
4242
./build.sh
@@ -50,11 +50,11 @@ It's possible to automate execution of commands in the VM:
5050
# A script named guest.sh can be used to launch a nested guest
5151
# Finally, a custom command can be passed to init script using INIT env var
5252
53-
# To boot a nested guest, and call hostname:
54-
INIT='env INIT=hostname /host/guest.sh qemu-system-aarch64' ./run.sh qemu-system-aarch64
53+
# To boot a guest, and call hostname:
54+
INIT=hostname ./run.sh qemu-system-x86_64
5555
5656
# In case command fail, init will trigger a Kernel panic
57-
INIT='false' ./run.sh qemu-system-aarch64
57+
INIT='false' ./run.sh qemu-system-x86_64
5858
```
5959

6060
---

build.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ rm -rf out
88

99
./build_kernel.sh
1010
echo '-------------------------------------------------------------------------'
11-
./build_uboot.sh
12-
echo '-------------------------------------------------------------------------'
13-
./build_arm_trusted_firmware.sh
11+
./build_edk2.sh
1412
echo '-------------------------------------------------------------------------'
1513
./build_rootfs.sh
1614
echo '-------------------------------------------------------------------------'

build_arm_trusted_firmware.sh

Lines changed: 0 additions & 51 deletions
This file was deleted.

build_edk2.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
set -x
5+
6+
if [ -z "${DISABLE_CONTAINER_CHECK:-}" ]; then
7+
./container.sh ./build_edk2.sh
8+
exit 0
9+
fi
10+
11+
clone()
12+
{
13+
rm -f edk2
14+
url=https://github.com/tianocore/edk2.git
15+
version=edk2-stable202505
16+
src=$version-x86_64
17+
if [ ! -d $src ]; then
18+
git clone $url --single-branch --branch $version --depth 1 $src
19+
pushd $src
20+
git submodule update --init --depth 1
21+
popd
22+
fi
23+
ln -s $src edk2
24+
}
25+
26+
build()
27+
{
28+
pushd edk2
29+
make -C BaseTools -j $(nproc)
30+
export GCC5_X64_PREFIX=x86_64-linux-gnu-
31+
# always build in debug to enable traces
32+
intercept-build --append \
33+
bash -c ". edksetup.sh &&
34+
build -q -n $(nproc) \
35+
-a X64 -b DEBUG -t GCC5 \
36+
-D DEBUG_ON_SERIAL_PORT -p OvmfPkg/OvmfPkgX64.dsc"
37+
sed -i compile_commands.json -e 's/"cc"/"x86_64-linux-gnu-gcc"/'
38+
popd
39+
}
40+
41+
output()
42+
{
43+
mkdir -p output
44+
rsync -a edk2/Build/OvmfX64/DEBUG_GCC5/FV/OVMF.fd out/
45+
}
46+
47+
clone
48+
build
49+
output

build_kernel.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ clone()
1313
rm -f linux
1414
url=https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
1515
version=v6.15
16-
src=linux_$version
16+
src=linux_${version}_x86_64
1717
if [ ! -d $src ]; then
1818
git clone $url --single-branch --branch $version --depth 1 $src
1919
pushd $src
@@ -27,23 +27,23 @@ build()
2727
{
2828
pushd linux
2929
rm -f .config
30-
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- defconfig -j$(nproc)
30+
make ARCH=x86_64 CROSS_COMPILE=x86_64-linux-gnu- defconfig -j$(nproc)
3131
# reduce number of timer interrupts
32-
scripts/config --disable CONFIG_HZ_250
32+
scripts/config --disable CONFIG_NO_HZ
33+
scripts/config --disable CONFIG_HZ_1000
3334
scripts/config --enable CONFIG_HZ_100
3435
# nvme
3536
scripts/config --enable BLK_DEV_NVME
3637
# iommufd
3738
# https://docs.kernel.org/driver-api/vfio.html#vfio-device-cdev
3839
scripts/config --enable IOMMUFD
3940
scripts/config --enable VFIO_DEVICE_CDEV
40-
scripts/config --enable ARM_SMMU_V3_IOMMUFD
4141

4242
# disable all modules
4343
sed -i -e 's/=m$/=n/' .config
4444

45-
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- olddefconfig -j$(nproc)
46-
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- all -j$(nproc)
45+
make ARCH=x86_64 CROSS_COMPILE=x86_64-linux-gnu- olddefconfig -j$(nproc)
46+
make ARCH=x86_64 CROSS_COMPILE=x86_64-linux-gnu- all -j$(nproc)
4747

4848
# compile commands
4949
./scripts/clang-tools/gen_compile_commands.py
@@ -52,15 +52,15 @@ build()
5252
-e 's/-fconserve-stack//' \
5353
-e 's/-fno-allow-store-data-races//' \
5454
-e 's/-mabi=lp64//' \
55-
-e 's/aarch64-linux-gnu-gcc/clang -target aarch64-pc-none-gnu -Wno-unknown-warning-option -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang/'
55+
-e 's/x86_64-linux-gnu-gcc/clang -target x86_64-pc-none-gnu -Wno-unknown-warning-option -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang/'
5656

5757
popd
5858
}
5959

6060
output()
6161
{
6262
mkdir -p out
63-
rsync ./linux/arch/arm64/boot/Image.gz out/
63+
rsync ./linux/arch/x86/boot/bzImage out/
6464
}
6565

6666
clone

build_uboot.sh

Lines changed: 0 additions & 39 deletions
This file was deleted.

debug.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
set -euo pipefail
44

55
if [ $# -lt 1 ]; then
6-
echo "usage: qemu_aarch64_cmd"
6+
echo "usage: qemu_x86_64_cmd"
77
exit 1
88
fi
99

10-
qemu_aarch64_cmd=$*
10+
qemu_x86_64_cmd=$*
1111

1212
tmux_session()
1313
{
@@ -22,4 +22,4 @@ if [ -z "$(which tmux)" ]; then
2222
echo "debug.sh: tmux needs to be installed on your machine"
2323
exit 1
2424
fi
25-
tmux_session ./run.sh $qemu_aarch64_cmd -S -s
25+
tmux_session ./run.sh $qemu_x86_64_cmd -S -s

0 commit comments

Comments
 (0)