Skip to content
This repository was archived by the owner on Apr 13, 2024. It is now read-only.

Commit d3c7c5b

Browse files
committed
driver: Support booting via EFI on arm64 and x86_64
If the ovmf or qemu-efi-aarch64 packages are installed on Debian or Ubuntu, use those files to boot up via EFI. This will help prevent regressions like ClangBuiltLinux/linux#634. This is disabled for kernel/common because the kernel does not shut down cleanly; I don't think this is worth exploring because Android does not care about EFI as far as I am aware. I considered checking in the fd files so that other distributions could take advantage of this but these files are over 50MB, which is too much of a burden to force on everyone. Presubmit: https://travis-ci.com/nathanchance/continuous-integration/builds/123450697 [skip ci] Suggested-by: Kees Cook <[email protected]> Signed-off-by: Nathan Chancellor <[email protected]>
1 parent 6ff45c2 commit d3c7c5b

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
*.fd
12
*.swp
23
*.tar.gz
34
.ccache

driver.sh

+13-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,13 @@ setup_variables() {
8787
qemu_cmdline=( -cpu cortex-a57
8888
-drive "file=images/arm64/rootfs.ext4,format=raw,id=rootfs,if=none"
8989
-device "virtio-blk-device,drive=rootfs"
90-
-append "console=ttyAMA0 root=/dev/vda" )
90+
-append "console=ttyAMA0 earlycon root=/dev/vda" )
91+
aavmf=/usr/share/AAVMF
92+
if [[ ${tree} != common && -f ${aavmf}/AAVMF_CODE.fd && -f ${aavmf}/AAVMF_VARS.fd ]]; then
93+
cp ${aavmf}/AAVMF_VARS.fd images/arm64
94+
qemu_cmdline+=( -drive "if=pflash,format=raw,readonly,file=${aavmf}/AAVMF_CODE.fd"
95+
-drive "if=pflash,format=raw,file=images/arm64/AAVMF_VARS.fd" )
96+
fi
9197
export CROSS_COMPILE=aarch64-linux-gnu- ;;
9298

9399
"mipsel")
@@ -148,6 +154,12 @@ setup_variables() {
148154
qemu_cmdline=( -drive "file=images/x86_64/rootfs.ext4,format=raw,if=virtio"
149155
-append "console=ttyS0 root=/dev/vda" ) ;;
150156
esac
157+
ovmf=/usr/share/OVMF
158+
if [[ ${tree} != common && -f ${ovmf}/OVMF_CODE.fd && -f ${ovmf}/OVMF_VARS.fd ]]; then
159+
cp ${ovmf}/OVMF_VARS.fd images/x86_64
160+
qemu_cmdline+=( -drive "if=pflash,format=raw,readonly,file=${ovmf}/OVMF_CODE.fd"
161+
-drive "if=pflash,format=raw,file=images/x86_64/OVMF_VARS.fd" )
162+
fi
151163
# Use KVM if the processor supports it (first part) and the KVM module is loaded (second part)
152164
[[ $(grep -c -E 'vmx|svm' /proc/cpuinfo) -gt 0 && $(lsmod 2>/dev/null | grep -c kvm) -gt 0 ]] && qemu_cmdline=( "${qemu_cmdline[@]}" -enable-kvm )
153165
image_name=bzImage

0 commit comments

Comments
 (0)