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

Commit

Permalink
driver: Support booting via EFI on arm64 and x86_64
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
nathanchance committed Aug 16, 2019
1 parent 6ff45c2 commit d3c7c5b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.fd
*.swp
*.tar.gz
.ccache
Expand Down
14 changes: 13 additions & 1 deletion driver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,13 @@ setup_variables() {
qemu_cmdline=( -cpu cortex-a57
-drive "file=images/arm64/rootfs.ext4,format=raw,id=rootfs,if=none"
-device "virtio-blk-device,drive=rootfs"
-append "console=ttyAMA0 root=/dev/vda" )
-append "console=ttyAMA0 earlycon root=/dev/vda" )
aavmf=/usr/share/AAVMF
if [[ ${tree} != common && -f ${aavmf}/AAVMF_CODE.fd && -f ${aavmf}/AAVMF_VARS.fd ]]; then
cp ${aavmf}/AAVMF_VARS.fd images/arm64
qemu_cmdline+=( -drive "if=pflash,format=raw,readonly,file=${aavmf}/AAVMF_CODE.fd"
-drive "if=pflash,format=raw,file=images/arm64/AAVMF_VARS.fd" )
fi
export CROSS_COMPILE=aarch64-linux-gnu- ;;

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

0 comments on commit d3c7c5b

Please sign in to comment.