UEFI + Secure Boot + qemu
v2 cover UEFI + Secure Boot + qemu
There seems to be a consensus that supporting UEFI in OE-core for qemu would be valuable, and there have been some (stalled) attempts to add it. For reference, see:
[OE-core] [PATCH V3 0/3] Add UEFI firmware for qemux86*
[OE-core] Add ovmf-native to make qemu-native/runqemu support boot UEFI image?
https://bugzilla.yoctoproject.org/show_bug.cgi?id=5654
https://github.com/01org/luv-yocto/issues/38
This patch set includes the necessary recipes (ovmf from meta-luv, acpica from meta-oe), some improvements to them (in particular, enabling Secure Boot), and changes to runqemu to make it easier to boot with UEFI. A special image recipes builds an image which can be used to lock down a virtual machine by enrolling the "normal" pre-installed certificates.
In contrast to the first version of this patch series, one can now use both a single OVMF firmware file as well as set up persistent variables for a virtual machine by using two files.
Eduardo promised to add automated testing for this once it is in OE-core. As it stands now, ovmf-shell-image and ovmf without Secure Boot enabled should at least be part of a world build.
As discussed on this list, Ricardo and Fathi volunteered to help with maintaining the ovmf and acpica recipes in OE-core.
Beware that "git am --keep-cr" must be used to import the ovmf patches correctly.
Changes since V1:
- support both combined code+vars ("ovmf") and separate code
and vars flash drives ("ovmf.code ovmf.vars")
- OVMF firmware no longer installed in the target sysroot
- slightly simpler renaming from OVMF (uppercase, underscore)
to OE naming convention (lowercase, dots): now the different
ln invocation directly create files with the final name
- DEPLOYDIR needs to be cleaned explicitly (done via cleandirs varflag)
- Secure Boot support in ovmf is controlled by a PACKAGECONFIG option,
off by default
- distros and developers can add additional Secure Boot compile flags
with OVMF_SECURE_BOOT_EXTRA_FLAGS
- explain how to get ovmf built for use with runqemu via MACHINE_ESSENTIAL_EXTRA_RDEPENDS
- IMAGE_FSTYPES_forcevariable = "wic" used in ovmf-shell-image
- remove OVMF BGRT patch
- location of "inherit deploy"
The following changes since commit acce512a0b85853b5acf2ef07e4163a3b4f33a98:
selftest/devtool: update test to work with new mtd-utils (2017-01-09 13:34:32 +0000)
are available in the git repository at:
git://github.com/pohly/openembedded-core secure-boot
https://github.com/pohly/openembedded-core/tree/secure-boot
Fathi Boudra (1):
acpica: move from meta-oe to OE-core
Patrick Ohly (9):
ovmf: explicitly depend on nasm-native
ovmf: deploy firmware in image directory ovmf_git.bb: enable parallel compilation ovmf_git.bb: enable Secure Boot
runqemu: also accept -image suffix for rootfs parameter
runqemu: fix undefined variable reference in check_arg_path()
runqemu: support UEFI with OVMF firmware
ovmf: build image which enrolls standard keys
ovmf: remove BGRT patch
meta-luv (1):
ovmf: move from meta-luv to OE-core
meta/recipes-core/ovmf/ovmf-shell-image.bb | 17 + ...s-Force-tools-variables-to-host-toolchain.patch | 48 + ...0002-ovmf-update-path-to-native-BaseTools.patch | 32 + ...makefile-adjust-to-build-in-under-bitbake.patch | 39 + ...ollDefaultKeys-application-for-enrolling-.patch | 1124 ++++++++++++++++++++ meta/recipes-core/ovmf/ovmf/ovmf-shell-image.wks | 4 + meta/recipes-core/ovmf/ovmf_git.bb | 201 ++++ meta/recipes-extended/acpica/acpica_20150515.bb | 46 + .../acpica/acpitests/aapits-linux.patch | 336 ++++++ .../acpica/acpitests/aapits-makefile.patch | 34 + meta/recipes-extended/acpica/acpitests_20140828.bb | 35 + meta/recipes-extended/acpica/files/no-werror.patch | 32 + scripts/runqemu | 50 +- 13 files changed, 1993 insertions(+), 5 deletions(-) create mode 100644 meta/recipes-core/ovmf/ovmf-shell-image.bb create mode 100644 meta/recipes-core/ovmf/ovmf/0001-BaseTools-Force-tools-variables-to-host-toolchain.patch create mode 100644 meta/recipes-core/ovmf/ovmf/0002-ovmf-update-path-to-native-BaseTools.patch create mode 100644 meta/recipes-core/ovmf/ovmf/0003-BaseTools-makefile-adjust-to-build-in-under-bitbake.patch create mode 100644 meta/recipes-core/ovmf/ovmf/0007-OvmfPkg-EnrollDefaultKeys-application-for-enrolling-.patch create mode 100644 meta/recipes-core/ovmf/ovmf/ovmf-shell-image.wks create mode 100644 meta/recipes-core/ovmf/ovmf_git.bb create mode 100644 meta/recipes-extended/acpica/acpica_20150515.bb create mode 100644 meta/recipes-extended/acpica/acpitests/aapits-linux.patch create mode 100644 meta/recipes-extended/acpica/acpitests/aapits-makefile.patch create mode 100644 meta/recipes-extended/acpica/acpitests_20140828.bb create mode 100644 meta/recipes-extended/acpica/files/no-werror.patch
Signature · 1 line
2.1.4
PATCH v2 1/11 acpica: move from meta-oe to OE-core
From: Fathi Boudra <[email protected]>
qemu support for UEFI in OE-core depends on OVMF, which needs the iasl tools provided by this recipe. There's also an iasl recipe in meta-luv, but than can and will be replaced by this one, thus reducing overall maintenance work.
Copied from meta-openembedded rev fa65be9ba (current master).
--- meta/recipes-extended/acpica/acpica_20150515.bb | 46 +++ .../acpica/acpitests/aapits-linux.patch | 336 +++++++++++++++++++++ .../acpica/acpitests/aapits-makefile.patch | 34 +++ meta/recipes-extended/acpica/acpitests_20140828.bb | 35 +++ meta/recipes-extended/acpica/files/no-werror.patch | 32 ++ 5 files changed, 483 insertions(+) create mode 100644 meta/recipes-extended/acpica/acpica_20150515.bb create mode 100644 meta/recipes-extended/acpica/acpitests/aapits-linux.patch create mode 100644 meta/recipes-extended/acpica/acpitests/aapits-makefile.patch create mode 100644 meta/recipes-extended/acpica/acpitests_20140828.bb create mode 100644 meta/recipes-extended/acpica/files/no-werror.patch
meta/recipes-extended/acpica/acpica_20150515.bb new file +46 -0
@@ -0,0 +1,46 @@ +SUMMARY = "ACPICA tools for the development and debug of ACPI tables" +DESCRIPTION = "The ACPI Component Architecture (ACPICA) project provides an \ +OS-independent reference implementation of the Advanced Configuration and \ +Power Interface Specification (ACPI). ACPICA code contains those portions of \ +ACPI meant to be directly integrated into the host OS as a kernel-resident \ +subsystem, and a small set of tools to assist in developing and debugging \ +ACPI tables." + +HOMEPAGE = "http://www.acpica.org/" +SECTION = "console/tools" + +LICENSE = "BSD | GPLv2" +LIC_FILES_CHKSUM = "file://generate/unix/readme.txt;md5=204407e197c1a01154a48f6c6280c3aa" + +COMPATIBLE_HOST = "(i.86|x86_64|arm|aarch64).*-linux" + +DEPENDS = "bison flex" + +SRC_URI = "https://acpica.org/sites/acpica/files/acpica-unix2-${PV}.tar.gz \ + file://no-werror.patch \ + " +SRC_URI[md5sum] = "2bc4a7ccc82de9df9fa964f784ecb29c" +SRC_URI[sha256sum] = "61204ec56d71bc9bfa2ee2ade4c66f7e8541772ac72ef8ccc20b3f339cc96374" + +S = "${WORKDIR}/acpica-unix2-${PV}" + +EXTRA_OEMAKE = "CC='${CC}' 'OPT_CFLAGS=-Wall'" + +do_install() { + install -D -p -m0755 generate/unix/bin*/iasl ${D}${bindir}/iasl + install -D -p -m0755 generate/unix/bin*/acpibin ${D}${bindir}/acpibin + install -D -p -m0755 generate/unix/bin*/acpiexec ${D}${bindir}/acpiexec + install -D -p -m0755 generate/unix/bin*/acpihelp ${D}${bindir}/acpihelp + install -D -p -m0755 generate/unix/bin*/acpinames ${D}${bindir}/acpinames + install -D -p -m0755 generate/unix/bin*/acpisrc ${D}${bindir}/acpisrc + install -D -p -m0755 generate/unix/bin*/acpixtract ${D}${bindir}/acpixtract +} + +# iasl*.bb is a subset of this recipe, so RREPLACE it +PROVIDES = "iasl" +RPROVIDES_${PN} += "iasl" +RREPLACES_${PN} += "iasl" +RCONFLIGHTS_${PN} += "iasl" + +NATIVE_INSTALL_WORKS = "1" +BBCLASSEXTEND = "native"
meta/recipes-extended/acpica/acpitests/aapits-linux.patch new file +336 -0
336 lines not on this page · raw message
meta/recipes-extended/acpica/acpitests/aapits-makefile.patch new file +34 -0
@@ -0,0 +1,34 @@ +From: Al Stone <[email protected]> +Date: Mon, 7 Apr 2014 19:09:37 +0000 +Subject: [PATCH 1/2] Fixup aapits build + +From http://git.linaro.org/people/al.stone/acpica-tools.git +Upstream-status: Unknown + +diff -urN acpica-unix2-20140325/tests/aapits/Makefile acpica-unix2-20140325/tests/aapits/Makefile +--- acpica-unix2-20140325/tests/aapits/Makefile 2014-04-05 14:23:14.683636794 -0600 ++++ acpica-unix2-20140325-aapits/tests/aapits/Makefile 2014-04-05 15:10:57.879184598 -0600 +@@ -16,6 +16,7 @@ + atosxfwrap.c \ + osunixxf.c \ + ../../source/common/ahids.c \ ++ ../../source/common/ahuuids.c \ + ../../source/common/cmfsize.c \ + ../../source/common/getopt.c \ + ../../source/components/hardware/hwtimer.c \ +@@ -174,6 +175,7 @@ + ../../source/components/utilities/utexcep.c \ + ../../source/components/utilities/utfileio.c \ + ../../source/components/utilities/utglobal.c \ ++ ../../source/components/utilities/uthex.c \ + ../../source/components/utilities/utids.c \ + ../../source/components/utilities/utinit.c \ + ../../source/components/utilities/utlock.c \ +@@ -189,6 +191,7 @@ + ../../source/components/utilities/utstate.c \ + ../../source/components/utilities/utstring.c \ + ../../source/components/utilities/uttrack.c \ ++ ../../source/components/utilities/utuuid.c \ + ../../source/components/utilities/utxface.c \ + ../../source/components/utilities/utxferror.c \ + ../../source/components/utilities/utxfinit.c \
meta/recipes-extended/acpica/acpitests_20140828.bb new file +35 -0
@@ -0,0 +1,35 @@ +SUMMARY = "Test suite used to validate ACPICA" +HOMEPAGE = "http://www.acpica.org/" + +LICENSE = "Intel" +LIC_FILES_CHKSUM = "file://tests/aapits/atexec.c;beginline=1;endline=115;md5=e92bcdfcd01d117d1bda3e814bb2030a" + +DEPENDS = "bison flex" + +SRC_URI = "https://acpica.org/sites/acpica/files/acpitests-unix-${PV}.tar.gz;name=acpitests \ + https://acpica.org/sites/acpica/files/acpica-unix2-${PV}.tar.gz;name=acpica \ + file://aapits-linux.patch \ + file://aapits-makefile.patch \ +" +SRC_URI[acpitests.md5sum] = "db9d6fdaa8e3eb101d700ee5ba4938ed" +SRC_URI[acpitests.sha256sum] = "e576c74bf1bf1c9f7348bf9419e05c8acfece7105abcdc052e66670c7af2cf00" +SRC_URI[acpica.md5sum] = "6f05f0d10166a1b1ff6107f3d1cdf1e5" +SRC_URI[acpica.sha256sum] = "01d8867656c5ba41dec307c4383ce676196ad4281ac2c9dec9f5be5fac6d888e" + +S = "${WORKDIR}/acpitests-unix-${PV}" + +EXTRA_OEMAKE = "'CC=${TARGET_PREFIX}gcc ${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS}' 'OPT_CFLAGS=-Wall'" + +# The Makefiles expect a specific layout +do_compile() { + cp -af ${WORKDIR}/acpica-unix2-${PV}/source ${S} + cd tests/aapits + oe_runmake +} + +do_install() { + install -d ${D}${bindir} + install -m0755 tests/aapits/bin/aapits ${D}${bindir} +} + +COMPATIBLE_HOST = "(i.86|x86_64|arm|aarch64).*-linux"
meta/recipes-extended/acpica/files/no-werror.patch new file +32 -0
@@ -0,0 +1,32 @@ +Description: remove -Werror flag +Forwarded: not-needed +Author: Fathi Boudra <[email protected]> + +--- + generate/unix/iasl/Makefile | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +--- a/generate/unix/iasl/Makefile ++++ b/generate/unix/iasl/Makefile +@@ -266,19 +266,19 @@ $(OBJDIR)/prparser.y.h: $(OBJDIR)/prpars + # by the utilities above and they are not necessarily ANSI C, etc. + # + $(OBJDIR)/aslcompilerlex.o : $(OBJDIR)/aslcompilerlex.c +- $(CC) -c $(CFLAGS) -Wall -Werror -o$@ $< ++ $(CC) -c $(CFLAGS) -Wall -o$@ $< + + $(OBJDIR)/aslcompilerparse.o : $(OBJDIR)/aslcompilerparse.c +- $(CC) -c $(CFLAGS) -Wall -Werror -o$@ $< ++ $(CC) -c $(CFLAGS) -Wall -o$@ $< + + $(OBJDIR)/dtparserlex.o : $(OBJDIR)/dtparserlex.c +- $(CC) -c $(CFLAGS) -Wall -Werror -o$@ $< ++ $(CC) -c $(CFLAGS) -Wall -o$@ $< + + $(OBJDIR)/dtparserparse.o : $(OBJDIR)/dtparserparse.c +- $(CC) -c $(CFLAGS) -Wall -Werror -o$@ $< ++ $(CC) -c $(CFLAGS) -Wall -o$@ $< + + $(OBJDIR)/prparserlex.o : $(OBJDIR)/prparserlex.c +- $(CC) -c $(CFLAGS) -Wall -Werror -o$@ $< ++ $(CC) -c $(CFLAGS) -Wall -o$@ $<
Signature · 1 line
2.1.4
PATCH v2 2/11 ovmf: move from meta-luv to OE-core
In reply to Patrick OhlyFrom: meta-luv <[email protected]>
This is an unmodified copy of github.com/01org/luv-yocto/meta-luv/recipes-core/ovmf revision 4be4329.
--- ...s-Force-tools-variables-to-host-toolchain.patch | 48 ++++++++ .../ovmf/0001-OvmfPkg-Enable-BGRT-in-OVMF.patch | 110 +++++++++++++++++++ ...0002-ovmf-update-path-to-native-BaseTools.patch | 32 ++++++ ...makefile-adjust-to-build-in-under-bitbake.patch | 39 +++++++ meta/recipes-core/ovmf/ovmf_git.bb | 121 +++++++++++++++++++++ 5 files changed, 350 insertions(+) create mode 100644 meta/recipes-core/ovmf/ovmf/0001-BaseTools-Force-tools-variables-to-host-toolchain.patch create mode 100644 meta/recipes-core/ovmf/ovmf/0001-OvmfPkg-Enable-BGRT-in-OVMF.patch create mode 100644 meta/recipes-core/ovmf/ovmf/0002-ovmf-update-path-to-native-BaseTools.patch create mode 100644 meta/recipes-core/ovmf/ovmf/0003-BaseTools-makefile-adjust-to-build-in-under-bitbake.patch create mode 100644 meta/recipes-core/ovmf/ovmf_git.bb
meta/recipes-core/ovmf/ovmf/0001-BaseTools-Force-tools-variables-to-host-toolchain.patch new file +48 -0
@@ -0,0 +1,48 @@ +From 6e24bde1979c2d7149b37d142fb882dfde0e9770 Mon Sep 17 00:00:00 2001 +From: Matt Fleming <[email protected]> +Date: Fri, 27 Jun 2014 11:12:18 +0100 +Subject: [PATCH] BaseTools: Force tools variables to host toolchain + +Signed-off-by: Matt Fleming <[email protected]> +--- + BaseTools/Source/C/Makefiles/app.makefile | 7 +++++++ + BaseTools/Source/C/VfrCompile/GNUmakefile | 5 +++++ + 2 files changed, 12 insertions(+) + +diff --git a/BaseTools/Source/C/Makefiles/app.makefile b/BaseTools/Source/C/Makefiles/app.makefile +index 19269a1..62aad0f 100644 +--- a/BaseTools/Source/C/Makefiles/app.makefile ++++ b/BaseTools/Source/C/Makefiles/app.makefile +@@ -16,6 +16,13 @@ include $(MAKEROOT)/Makefiles/header.makefile + + APPLICATION = $(MAKEROOT)/bin/$(APPNAME) + ++CC = gcc ++CXX = g++ ++AS = gcc ++AR = ar ++LD = ld ++LINKER = $(CC) ++ + .PHONY:all + all: $(MAKEROOT)/bin $(APPLICATION) + +diff --git a/BaseTools/Source/C/VfrCompile/GNUmakefile b/BaseTools/Source/C/VfrCompile/GNUmakefile +index 82005e1..5ac5f7e 100644 +--- a/BaseTools/Source/C/VfrCompile/GNUmakefile ++++ b/BaseTools/Source/C/VfrCompile/GNUmakefile +@@ -26,6 +26,11 @@ OBJECTS = AParser.o DLexerBase.o ATokenBuffer.o EfiVfrParser.o VfrLexer.o VfrSyn + + VFR_CPPFLAGS = -DPCCTS_USE_NAMESPACE_STD $(CPPFLAGS) + ++CC = gcc ++CXX = g++ ++AS = gcc ++AR = ar ++LD = ld + LINKER = $(BUILD_CXX) + + EXTRA_CLEAN_OBJECTS = EfiVfrParser.cpp EfiVfrParser.h VfrParser.dlg VfrTokens.h VfrLexer.cpp VfrLexer.h VfrSyntax.cpp tokens.h +-- +1.9.0 +
meta/recipes-core/ovmf/ovmf/0001-OvmfPkg-Enable-BGRT-in-OVMF.patch new file +110 -0
110 lines not on this page · raw message
meta/recipes-core/ovmf/ovmf/0002-ovmf-update-path-to-native-BaseTools.patch new file +32 -0
@@ -0,0 +1,32 @@ +From 9e632e3f9edd09632cc877dff6ea57608f979aab Mon Sep 17 00:00:00 2001 +From: Ricardo Neri <[email protected]> +Date: Thu, 9 Jun 2016 02:23:01 -0700 +Subject: [PATCH] ovmf: update path to native BaseTools + +BaseTools is a set of utilities to build EDK-based firmware. These utilities +are used during the build process. Thus, they need to be built natively. +When cross-compiling, we need to provide a path to the location of these +tools. The BBAKE_EDK_TOOLS_PATH string is used as a pattern to be replaced +with the appropriate location before building. + +Signed-off-by: Ricardo Neri <[email protected]> +--- + OvmfPkg/build.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/OvmfPkg/build.sh b/OvmfPkg/build.sh +index eb5eb73..9058fca 100755 +--- a/OvmfPkg/build.sh ++++ b/OvmfPkg/build.sh +@@ -30,7 +30,7 @@ then + # this assumes svn pulls have the same root dir + # export EDK_TOOLS_PATH=`pwd`/../BaseTools + # This version is for the tools source in edk2 +- export EDK_TOOLS_PATH=`pwd`/BaseTools ++ export EDK_TOOLS_PATH=BBAKE_EDK_TOOLS_PATH/BaseTools + echo $EDK_TOOLS_PATH + source edksetup.sh BaseTools + else +-- +2.8.1 +
meta/recipes-core/ovmf/ovmf/0003-BaseTools-makefile-adjust-to-build-in-under-bitbake.patch new file +39 -0
@@ -0,0 +1,39 @@ +From 2320650c6d381b914fe91b2dedaa5870279a8bcf Mon Sep 17 00:00:00 2001 +From: Ricardo Neri <[email protected]> +Date: Sun, 27 Nov 2016 18:42:55 -0800 +Subject: [PATCH] BaseTools: makefile: adjust to build in under bitbake + +Prepend the build flags with those of bitbake. This is to build +using the bitbake native sysroot include and library directories. + +Signed-off-by: Ricardo Neri <[email protected]> +--- + BaseTools/Source/C/Makefiles/header.makefile | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/BaseTools/Source/C/Makefiles/header.makefile b/BaseTools/Source/C/Makefiles/header.makefile +index 821d114..fe0f08b 100644 +--- a/BaseTools/Source/C/Makefiles/header.makefile ++++ b/BaseTools/Source/C/Makefiles/header.makefile +@@ -44,14 +44,14 @@ ARCH_INCLUDE = -I $(MAKEROOT)/Include/AArch64/ + endif + + INCLUDE = $(TOOL_INCLUDE) -I $(MAKEROOT) -I $(MAKEROOT)/Include/Common -I $(MAKEROOT)/Include/ -I $(MAKEROOT)/Include/IndustryStandard -I $(MAKEROOT)/Common/ -I .. -I . $(ARCH_INCLUDE) +-BUILD_CPPFLAGS = $(INCLUDE) -O2 ++BUILD_CPPFLAGS := $(BUILD_CPPFLAGS) $(INCLUDE) -O2 + ifeq ($(DARWIN),Darwin) + # assume clang or clang compatible flags on OS X +-BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-self-assign -Wno-unused-result -nostdlib -c -g ++BUILD_CFLAGS := $(BUILD_CFLAGS) -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-self-assign -Wno-unused-result -nostdlib -c -g + else +-BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-unused-result -nostdlib -c -g ++BUILD_CFLAGS := $(BUILD_CFLAGS) -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-unused-result -nostdlib -c -g + endif +-BUILD_LFLAGS = ++BUILD_LFLAGS := $(LDFLAGS) + BUILD_CXXFLAGS = + + ifeq ($(ARCH), IA32) +-- +2.9.3 +
meta/recipes-core/ovmf/ovmf_git.bb new file +121 -0
121 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v2 3/11 ovmf: explicitly depend on nasm-native
In reply to Patrick OhlyFixes a build issue when nasm was not build already because of something else.
--- meta/recipes-core/ovmf/ovmf_git.bb | 2 ++ 1 file changed, 2 insertions(+)
meta/recipes-core/ovmf/ovmf_git.bb +2 -0
@@ -20,6 +20,8 @@ DEPENDS_class-native="util-linux-native iasl-native ossp-uuid-native" DEPENDS_class-target="ovmf-native" +DEPENDS_append = " nasm-native" + EDK_TOOLS_DIR="edk2_basetools" # OVMF has trouble building with the default optimization of -O2.
Signature · 1 line
2.1.4
PATCH v2 4/11 ovmf: deploy firmware in image directory
In reply to Patrick OhlyWhen used with '-drive if=pflash', qemu will store UEFI variables inside the firmware image file. That is unexpected for a file located in the sysroot, which should be read-only, while it is normal for image files in the deploy/images directory. Therefore that directory is a better place for use with runqemu.
The name was chose so that "runqemu ovmf" can be used as shorthand for "runqemu <full path>/ovmf.qcow2" by treating "ovmf" as the base name of the BIOS file. "ovmf.secboot.qcow2" is meant to be used for the Secure Boot enabled firmware.
qcow2 is used because it is needed for "savevm" snapshots of a virtual machine.
With code and variables stored in the same ovmf.qcow2 it is not possible to update the firmware code without also overwriting the variables. For users who care about persistent variables, the code and variables are also provided as separate files, in ovmf.code.qcow2 and ovmf.vars.qcow2.
The traditional usage of ovmf via the qemu bios parameter is no longer supported and therefore it is not necessary to create a "bios.bin" file in the target sysroot.
--- meta/recipes-core/ovmf/ovmf_git.bb | 42 ++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 11 deletions(-)
meta/recipes-core/ovmf/ovmf_git.bb +31 -11
@@ -12,11 +12,13 @@ SRC_URI = "git://github.com/tianocore/edk2.git;branch=master \ SRCREV="4575a602ca6072ee9d04150b38bfb143cbff8588" +inherit deploy + PARALLEL_MAKE = "" S = "${WORKDIR}/git" -DEPENDS_class-native="util-linux-native iasl-native ossp-uuid-native" +DEPENDS_class-native="util-linux-native iasl-native ossp-uuid-native qemu-native" DEPENDS_class-target="ovmf-native"
@@ -97,9 +99,22 @@ do_compile_class-target() { OVMF_ARCH="IA32" fi + # ${WORKDIR}/ovmf is a well-known location where do_install and + # do_deploy will be able to find the files. + rm -rf ${WORKDIR}/ovmf + mkdir ${WORKDIR}/ovmf + OVMF_DIR_SUFFIX="X64" + if [ "${TARGET_ARCH}" != "x86_64" ] ; then + OVMF_DIR_SUFFIX="Ia32" # Note the different capitalization + fi FIXED_GCCVER=$(fixup_target_tools ${GCC_VER}) - echo FIXED_GCCVER is ${FIXED_GCCVER} + bbnote FIXED_GCCVER is ${FIXED_GCCVER} + build_dir="${S}/Build/Ovmf$OVMF_DIR_SUFFIX/RELEASE_${FIXED_GCCVER}" + ${S}/OvmfPkg/build.sh -a $OVMF_ARCH -b RELEASE -t ${FIXED_GCCVER} + ln ${build_dir}/FV/OVMF.fd ${WORKDIR}/ovmf/ovmf.fd + ln ${build_dir}/FV/OVMF_CODE.fd ${WORKDIR}/ovmf/ovmf.code.fd + ln ${build_dir}/FV/OVMF_VARS.fd ${WORKDIR}/ovmf/ovmf.vars.fd } do_install_class-native() {
@@ -108,16 +123,21 @@ do_install_class-native() { } do_install_class-target() { - OVMF_DIR_SUFFIX="X64" - if [ "${TARGET_ARCH}" != "x86_64" ] ; then - OVMF_DIR_SUFFIX="Ia32" # Note the different capitalization - fi - install -d ${D}${datadir}/ovmf +} - FIXED_GCCVER=$(fixup_target_tools ${GCC_VER}) - build_dir="${S}/Build/Ovmf$OVMF_DIR_SUFFIX/RELEASE_${FIXED_GCCVER}" - install -m 0755 ${build_dir}/FV/OVMF.fd \ - ${D}${datadir}/ovmf/bios.bin +do_deploy() { +} +do_deploy[cleandirs] = "${DEPLOYDIR}" +do_deploy_class-target() { + # For use with "runqemu ovmf". + for i in \ + ovmf \ + ovmf.code \ + ovmf.vars \ + ; do + qemu-img convert -f raw -O qcow2 ${WORKDIR}/ovmf/$i.fd ${DEPLOYDIR}/$i.qcow2 + done } +addtask do_deploy after do_compile before do_build BBCLASSEXTEND = "native"
Signature · 1 line
2.1.4
PATCH v2 5/11 ovmf_git.bb: enable parallel compilation
In reply to Patrick OhlyThe Fedora srpm [1] seems to have no problems with parallel compilation, so let's also use that for the target. The native tools however indeed have dependency problems:
| test_Ecc_CParser (CheckPythonSyntax.Tests) ... gcc -o ../bin/EfiRom -L/fast/build/ostro/x86/tmp-glibc/sysroots/x86_64-linux/usr/lib -L/fast/build/ostro/x86/tmp-glibc/sysroots/x86_64-linux/lib -Wl,-rpath-link,/fast/build/ostro/x86/tmp-glibc/sysroots/x86_64-linux/usr/lib -Wl,-rpath-link,/fast/build/ostro/x86/tmp-glibc/sysroots/x86_64-linux/lib -Wl,-rpath,/fast/build/ostro/x86/tmp-glibc/sysroots/x86_64-linux/usr/lib -Wl,-rpath,/fast/build/ostro/x86/tmp-glibc/sysroots/x86_64-linux/lib -Wl,-O1 EfiRom.o -L../libs -lCommon | /usr/bin/ld: cannot find -lCommon | collect2: error: ld returned 1 exit status
ERROR: Task (virtual:native:.../meta/recipes-core/ovmf/ovmf_git.bb:do_compile) failed with exit code '1'
[1] https://src.fedoraproject.org/cgit/rpms/edk2.git/tree/edk2.spec
--- meta/recipes-core/ovmf/ovmf_git.bb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
meta/recipes-core/ovmf/ovmf_git.bb +3 -2
@@ -14,7 +14,7 @@ SRCREV="4575a602ca6072ee9d04150b38bfb143cbff8588" inherit deploy -PARALLEL_MAKE = "" +PARALLEL_MAKE_class-native = "" S = "${WORKDIR}/git"
@@ -94,6 +94,7 @@ do_compile_class-native() { do_compile_class-target() { export LFLAGS="${LDFLAGS}" + PARALLEL_JOBS="${@ '${PARALLEL_MAKE}'.replace('-j', '-n')}" OVMF_ARCH="X64" if [ "${TARGET_ARCH}" != "x86_64" ] ; then OVMF_ARCH="IA32"
@@ -111,7 +112,7 @@ do_compile_class-target() { bbnote FIXED_GCCVER is ${FIXED_GCCVER} build_dir="${S}/Build/Ovmf$OVMF_DIR_SUFFIX/RELEASE_${FIXED_GCCVER}" - ${S}/OvmfPkg/build.sh -a $OVMF_ARCH -b RELEASE -t ${FIXED_GCCVER} + ${S}/OvmfPkg/build.sh $PARALLEL_JOBS -a $OVMF_ARCH -b RELEASE -t ${FIXED_GCCVER} ln ${build_dir}/FV/OVMF.fd ${WORKDIR}/ovmf/ovmf.fd ln ${build_dir}/FV/OVMF_CODE.fd ${WORKDIR}/ovmf/ovmf.code.fd ln ${build_dir}/FV/OVMF_VARS.fd ${WORKDIR}/ovmf/ovmf.vars.fd
Signature · 1 line
2.1.4
PATCH v2 6/11 ovmf_git.bb: enable Secure Boot
In reply to Patrick OhlyWhen enabled via PACCKAGECONFIG = "secureboot" (off by default because of the extra work and license change), the recipe compiles OVMF twice, once without Secure Boot, once with. This is the same approach as in
https://src.fedoraproject.org/cgit/rpms/edk2.git/tree/edk2.spec
The results are "ovmf.qcow2" and "ovmf.secboot.qcow2" in the image deploy directory, so
runqemu <machine> <image> ovmf.secboot
will boot with Secure Boot enabled.
ovmf.secboot.code.qcow2 is provided for those who want separate code and variable flash drives. The normal ovmf.vars.qcow2 can be used with it.
In contrast to Fedora, no attempt is made to strip potentially patent encumbered algorithms out of the OpenSSL archive. OVMF does not use the ones considered problematic for Fedora, so this shouldn't be a problem.
--- meta/recipes-core/ovmf/ovmf_git.bb | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
meta/recipes-core/ovmf/ovmf_git.bb +36 -0
@@ -1,8 +1,15 @@ DESCRIPTION = "OVMF - UEFI firmware for Qemu and KVM" HOMEPAGE = "http://sourceforge.net/apps/mediawiki/tianocore/index.php?title=OVMF" LICENSE = "BSD" +LICENSE_class-target = "${@bb.utils.contains('PACKAGECONFIG', 'secureboot', 'BSD & OpenSSL', 'BSD', d)}" LIC_FILES_CHKSUM = "file://OvmfPkg/License.txt;md5=343dc88e82ff33d042074f62050c3496" +# Enabling Secure Boot adds a dependency on OpenSSL and implies +# compiling OVMF twice, so it is disabled by default. Distros +# may change that default. +PACKAGECONFIG ??= "" +PACKAGECONFIG[secureboot] = ",,," + SRC_URI = "git://github.com/tianocore/edk2.git;branch=master \ file://0001-BaseTools-Force-tools-variables-to-host-toolchain.patch \ file://0001-OvmfPkg-Enable-BGRT-in-OVMF.patch \
@@ -10,7 +17,13 @@ SRC_URI = "git://github.com/tianocore/edk2.git;branch=master \ file://0003-BaseTools-makefile-adjust-to-build-in-under-bitbake.patch \ " +SRC_URI_append_class-target = " \ + ${@bb.utils.contains('PACKAGECONFIG', 'secureboot', 'http://www.openssl.org/source/openssl-1.0.2j.tar.gz;name=openssl;subdir=${S}/CryptoPkg/Library/OpensslLib', '', d)} \ +" + SRCREV="4575a602ca6072ee9d04150b38bfb143cbff8588" +SRC_URI[openssl.md5sum] = "96322138f0b69e61b7212bc53d5e912b" +SRC_URI[openssl.sha256sum] = "e7aff292be21c259c6af26469c7a9b3ba26e9abaaffd325e3dccc9785256c431" inherit deploy
@@ -32,6 +45,11 @@ BUILD_OPTIMIZATION="-pipe" # OVMF supports IA only, although it could conceivably support ARM someday. COMPATIBLE_HOST='(i.86|x86_64).*' +# Additional build flags for OVMF with Secure Boot. +# Fedora also uses "-D SMM_REQUIRE -D EXCLUDE_SHELL_FROM_FD". +OVMF_SECURE_BOOT_EXTRA_FLAGS ??= "" +OVMF_SECURE_BOOT_FLAGS = "-DSECURE_BOOT_ENABLE=TRUE ${OVMF_SECURE_BOOT_EXTRA_FLAGS}" + do_patch_append_class-native() { bb.build.exec_func('do_fix_iasl', d) bb.build.exec_func('do_fix_toolchain', d)
@@ -112,10 +130,27 @@ do_compile_class-target() { bbnote FIXED_GCCVER is ${FIXED_GCCVER} build_dir="${S}/Build/Ovmf$OVMF_DIR_SUFFIX/RELEASE_${FIXED_GCCVER}" + bbnote "Building without Secure Boot." + rm -rf ${S}/Build/Ovmf$OVMF_DIR_SUFFIX ${S}/OvmfPkg/build.sh $PARALLEL_JOBS -a $OVMF_ARCH -b RELEASE -t ${FIXED_GCCVER} ln ${build_dir}/FV/OVMF.fd ${WORKDIR}/ovmf/ovmf.fd ln ${build_dir}/FV/OVMF_CODE.fd ${WORKDIR}/ovmf/ovmf.code.fd ln ${build_dir}/FV/OVMF_VARS.fd ${WORKDIR}/ovmf/ovmf.vars.fd + + if ${@bb.utils.contains('PACKAGECONFIG', 'secureboot', 'true', 'false', d)}; then + # See CryptoPkg/Library/OpensslLib/Patch-HOWTO.txt and + # https://src.fedoraproject.org/cgit/rpms/edk2.git/tree/ for + # building with Secure Boot enabled. + bbnote "Building with Secure Boot." + rm -rf ${S}/Build/Ovmf$OVMF_DIR_SUFFIX + if ! [ -f ${S}/CryptoPkg/Library/OpensslLib/openssl-*/edk2-patch-applied ]; then + ( cd ${S}/CryptoPkg/Library/OpensslLib/openssl-* && patch -p1 <$(echo ../EDKII_openssl-*.patch) && touch edk2-patch-applied ) + fi + ( cd ${S}/CryptoPkg/Library/OpensslLib/ && ./Install.sh ) + ${S}/OvmfPkg/build.sh $PARALLEL_JOBS -a $OVMF_ARCH -b RELEASE -t ${FIXED_GCCVER} ${OVMF_SECURE_BOOT_FLAGS} + ln ${build_dir}/FV/OVMF.fd ${WORKDIR}/ovmf/ovmf.secboot.fd + ln ${build_dir}/FV/OVMF_CODE.fd ${WORKDIR}/ovmf/ovmf.secboot.code.fd + fi } do_install_class-native() {
@@ -135,6 +170,7 @@ do_deploy_class-target() { ovmf \ ovmf.code \ ovmf.vars \ + ${@bb.utils.contains('PACKAGECONFIG', 'secureboot', 'ovmf.secboot ovmf.secboot.code', '', d)} \ ; do qemu-img convert -f raw -O qcow2 ${WORKDIR}/ovmf/$i.fd ${DEPLOYDIR}/$i.qcow2 done
Signature · 1 line
2.1.4
PATCH v2 7/11 runqemu: also accept -image suffix for rootfs parameter
In reply to Patrick OhlyThe magic detection of the rootfs parameter only worked for image recipes which embedd the "image" string in the middle, as in "core-image-minimal".
Sometimes it is more natural to call an image "something-image". To get such an image detected by runqemu, "-image" at the end of a parameter must also cause that parameter to be treated as the rootfs parameter.
Inside the image directory, "something-image" has an -<arch> suffix and thus no change is needed for those usages of re.search('-image-'). However, while at it also enhance those string searches a bit (no need for re; any()+map() a bit closer to the intended logic).
--- scripts/runqemu | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
scripts/runqemu +3 -3
@@ -218,7 +218,7 @@ class BaseConfig(object): if not re.search('.qemuboot.conf$', '\n'.join(os.listdir(p)), re.M): logger.info("Can't find required *.qemuboot.conf in %s" % p) return False - if not re.search('-image-', '\n'.join(os.listdir(p))): + if not any(map(lambda name: '-image-' in name, os.listdir(p))): logger.info("Can't find *-image-* in %s" % p) return False return True
@@ -267,7 +267,7 @@ class BaseConfig(object): re.search('zImage', p) or re.search('vmlinux', p) or \ re.search('fitImage', p) or re.search('uImage', p): self.kernel = p - elif os.path.exists(p) and (not os.path.isdir(p)) and re.search('-image-', os.path.basename(p)): + elif os.path.exists(p) and (not os.path.isdir(p)) and '-image-' in os.path.basename(p): self.rootfs = p dirpath = os.path.dirname(p) m = re.search('(.*)\.(.*)$', p)
@@ -371,7 +371,7 @@ class BaseConfig(object): self.kernel_cmdline_script += ' %s' % arg[len('bootparams='):] elif os.path.exists(arg) or (re.search(':', arg) and re.search('/', arg)): self.check_arg_path(os.path.abspath(arg)) - elif re.search('-image-', arg): + elif re.search(r'-image-|-image$', arg): # Lazy rootfs self.rootfs = arg else:
Signature · 1 line
2.1.4
PATCH v2 8/11 runqemu: fix undefined variable reference in check_arg_path()
In reply to Patrick Ohly'arg' isn't defined, the right name there is 'p'.
This fixes a rather obscure error message when that code path ends up being taken:
$ runqemu some/existing-file-name runqemu - ERROR - name 'arg' is not defined runqemu - ERROR - Try 'runqemu help' on how to use it
--- scripts/runqemu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/runqemu +1 -1
@@ -282,7 +282,7 @@ class BaseConfig(object): self.check_arg_fstype(fst) else: raise Exception("Can't find FSTYPE from: %s" % p) - elif os.path.isdir(p) or re.search(':', arg) and re.search('/', arg): + elif os.path.isdir(p) or re.search(':', p) and re.search('/', p): if self.is_deploy_dir_image(p): logger.info('DEPLOY_DIR_IMAGE: %s' % p) self.set("DEPLOY_DIR_IMAGE", p)
Signature · 1 line
2.1.4
PATCH v2 9/11 runqemu: support UEFI with OVMF firmware
In reply to Patrick OhlyIn the simplest case, "runqemu qemux86 <some-image> qcow2 ovmf" for an EFI-enabled image in the qcow2 format will locate the ovmf.qcow2 firmware file deployed by the ovmf recipe in the image deploy directory, override the graphics hardware with "-vga std" because that is all that OVMF supports, and boot with UEFI enabled.
ovmf is not built by default. Either do it explicitly ("bitbake ovmf") or make it a part of the normal build ("MACHINE_ESSENTIAL_EXTRA_RDEPENDS_append = ' ovmf'").
The firmware file is activated as a flash drive instead of using the qemu BIOS parameters, because that is the recommended method
(https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=764918#47) as it allows storing UEFI variables in the file.
Instead of just "ovmf", a full path to an existing file can also be used, just as with the rootfs. That may be useful when making a permanent copy of the virtual machine data files.
It is possible to specify "ovmf*" parameters more than once, then each parameter creates a separate flash drive. This way it is possible to use separate flash drives for firmware code and variables:
$ runqemu qemux86 <some-image> qcow2 ovmf.code ovmf.vars"
Note that rebuilding ovmf will overwrite the ovmf.vars.qcow2 file in the image deploy directory. So when the goal is to update the firmware while keeping variables, make a copy of the variable file and use that:
$ mkdir my-machine $ cp tmp/deploy/images/qemux86/ovmf.vars.qcow2 my-machine/ $ runqemu qemux86 <some-image> qcow2 ovmf.code my-machine/ovmf.vars.qcow2
When Secure Boot was enabled in ovmf, one can pick that instead of the non-Secure-Boot enabled ovmf.code:
$ runqemu qemux86 <some-image> qcow2 ovmf.secboot.code my-machine/ovmf.vars.qcow2
--- scripts/runqemu | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-)
scripts/runqemu +41 -1
@@ -74,6 +74,7 @@ of the following environment variables (in any order): kvm-vhost - enable KVM with vhost when running x86/x86_64 (VT-capable CPU required) publicvnc - enable a VNC server open to all hosts audio - enable audio + [*/]ovmf* - OVMF firmware file or base name for booting with UEFI tcpserial=<port> - specify tcp serial port number biosdir=<dir> - specify custom bios dir biosfilename=<filename> - specify bios filename
@@ -162,6 +163,13 @@ class BaseConfig(object): self.clean_nfs_dir = False self.nfs_server = '' self.rootfs = '' + # File name(s) of a OVMF firmware file or variable store, + # to be added with -drive if=pflash. + # Found in the same places as the rootfs, with or without one of + # these suffices: qcow2, bin. + # Setting one also adds "-vga std" because that is all that + # OVMF supports. + self.ovmf_bios = [] self.qemuboot = '' self.qbconfload = False self.kernel = ''
@@ -259,6 +267,7 @@ class BaseConfig(object): - Check whether is a kernel file - Check whether is a image file - Check whether it is a nfs dir + - Check whether it is a OVMF flash file """ if p.endswith('.qemuboot.conf'): self.qemuboot = p
@@ -289,6 +298,8 @@ class BaseConfig(object): else: logger.info("Assuming %s is an nfs rootfs" % p) self.check_arg_nfs(p) + elif os.path.basename(p).startswith('ovmf'): + self.ovmf_bios.append(p) else: raise Exception("Unknown path arg %s" % p)
@@ -374,6 +385,8 @@ class BaseConfig(object): elif re.search(r'-image-|-image$', arg): # Lazy rootfs self.rootfs = arg + elif arg.startswith('ovmf'): + self.ovmf_bios.append(arg) else: # At last, assume is it the MACHINE if (not unknown_arg) or unknown_arg == arg:
@@ -472,6 +485,20 @@ class BaseConfig(object): if not os.path.exists(self.rootfs): raise Exception("Can't find rootfs: %s" % self.rootfs) + def check_ovmf(self): + """Check and set full path for OVMF firmware and variable file(s).""" + + for index, ovmf in enumerate(self.ovmf_bios): + if os.path.exists(ovmf): + continue + for suffix in ('qcow2', 'bin'): + path = '%s/%s.%s' % (self.get('DEPLOY_DIR_IMAGE'), ovmf, suffix) + if os.path.exists(path): + self.ovmf_bios[index] = path + break + else: + raise Exception("Can't find OVMF firmware: %s" % ovmf) + def check_kernel(self): """Check and set kernel, dtb""" # The vm image doesn't need a kernel
@@ -562,6 +589,7 @@ class BaseConfig(object): self.check_kvm() self.check_fstype() self.check_rootfs() + self.check_ovmf() self.check_kernel() self.check_biosdir() self.check_mem()
@@ -670,6 +698,8 @@ class BaseConfig(object): print('NFS_DIR: [%s]' % self.nfs_dir) else: print('ROOTFS: [%s]' % self.rootfs) + if self.ovmf_bios: + print('OVMF: %s' % self.ovmf_bios) print('CONFFILE: [%s]' % self.qemuboot) print('')
@@ -926,7 +956,17 @@ class BaseConfig(object): check_libgl(qemu_bin) - self.qemu_opt = "%s %s %s %s %s" % (qemu_bin, self.get('NETWORK_CMD'), self.get('ROOTFS_OPTIONS'), self.get('QB_OPT_APPEND'), self.qemu_opt_script) + self.qemu_opt = "%s %s %s %s" % (qemu_bin, self.get('NETWORK_CMD'), self.get('ROOTFS_OPTIONS'), self.get('QB_OPT_APPEND')) + + for ovmf in self.ovmf_bios: + format = ovmf.rsplit('.', 1)[-1] + self.qemu_opt += ' -drive if=pflash,format=%s,file=%s' % (format, ovmf) + if self.ovmf_bios: + # OVMF only supports normal VGA, i.e. we need to override a -vga vmware + # that gets added for example for normal qemux86. + self.qemu_opt += ' -vga std' + + self.qemu_opt += ' ' + self.qemu_opt_script if self.snapshot: self.qemu_opt += " -snapshot"
Signature · 1 line
2.1.4
PATCH v2 10/11 ovmf: build image which enrolls standard keys
In reply to Patrick OhlyWhen booting a qemu virtual machine with ovmf.secboot, it comes up with no keys installed and thus Secure Boot disabled. To lock down the machine like a typical PC, one has to enroll the same keys that PC vendors normally install, i.e. the ones from Microsoft.
This can be done manually (see
https://wiki.ubuntu.com/SecurityTeam/SecureBoot and
https://github.com/tianocore-docs/Docs/raw/master/White_Papers/A_Tour_Beyond_BIOS_into_UEFI_Secure_Boot_White_Paper.pdf) or automatically with the EnrollDefaultKeys.efi helper from the Fedora ovmf rpm.
To use this with qemu:
$ bitbake ovmf-shell-image
...
$ runqemu serial nographic qemux86 ovmf-shell-image wic ovmf.secboot
...
UEFI Interactive Shell v2.1
EDK II
UEFI v2.60 (EDK II, 0x00010000)
Mapping table
FS0: Alias(s):HD2b:;BLK4:
PciRoot(0x0)/Pci(0x5,0x0)/HD(1,GPT,06AEF759-3982-4AF6-B517-70BA6304FC1C,0x800,0x566C)
BLK0: Alias(s):
PciRoot(0x0)/Pci(0x1,0x0)/Floppy(0x0)
BLK1: Alias(s):
PciRoot(0x0)/Pci(0x1,0x0)/Floppy(0x1)
BLK2: Alias(s):
PciRoot(0x0)/Pci(0x1,0x1)/Ata(0x0)
BLK3: Alias(s):
PciRoot(0x0)/Pci(0x5,0x0)Press ESC in 1 seconds to skip startup.nsh or any other key to continue. Shell> fs0:EnrollDefaultKeys.efi
info: SetupMode=1 SecureBoot=0 SecureBootEnable=0 CustomMode=0 VendorKeys=1
info: SetupMode=0 SecureBoot=1 SecureBootEnable=1 CustomMode=0 VendorKeys=0
info: success
Shell> reset
Remember that this will modify deploy/images/qemux86/ovmf.secboot.qcow2, so make a copy and use the full path of that copy instead of the "ovmf" argument if needed.
The ovmf-shell-image contains an EFI shell, which is what got started here directly. After enrolling the keys, Secure Boot is active and the same image cannot be booted anymore, so the BIOS goes through the normal boot targets (including network boot, which can take a while to time out), and ends up in the internal EFI shell. Trying to invoke bootia32.efi (the shell from the image) or EnrollDefaultKeys.efi then fails:
Shell> bootia32.efi
Command Error Status: Security Violation
The main purpose at the moment is to test that Secure Boot enforcement really works. If we had a way to sign generated images, that part could also be tested by booting in a locked down qemu instance.
0007-OvmfPkg-EnrollDefaultKeys-application-for-enrolling-.patch is from
https://src.fedoraproject.org/cgit/rpms/edk2.git/tree/0007-OvmfPkg-EnrollDefaultKeys-application-for-enrolling-.patch?id=b1781931894bf2057464e634beed68b1e3218c9e
with one line changed to fix
https://bugzilla.redhat.com/show_bug.cgi?id=132502:
"EFI_STATUS Status = EFI_SUCCESS;" in EnrollListOfX509Certs() lacked the initializer.
--- meta/recipes-core/ovmf/ovmf-shell-image.bb | 17 + ...ollDefaultKeys-application-for-enrolling-.patch | 1124 ++++++++++++++++++++ meta/recipes-core/ovmf/ovmf/ovmf-shell-image.wks | 4 + meta/recipes-core/ovmf/ovmf_git.bb | 22 + 4 files changed, 1167 insertions(+) create mode 100644 meta/recipes-core/ovmf/ovmf-shell-image.bb create mode 100644 meta/recipes-core/ovmf/ovmf/0007-OvmfPkg-EnrollDefaultKeys-application-for-enrolling-.patch create mode 100644 meta/recipes-core/ovmf/ovmf/ovmf-shell-image.wks
meta/recipes-core/ovmf/ovmf-shell-image.bb new file +17 -0
@@ -0,0 +1,17 @@ +DESCRIPTION = "boot image with UEFI shell and tools" + +# For this image recipe, only the wic format with a +# single vfat partition makes sense. +IMAGE_FSTYPES_forcevariable = 'wic' + +WKS_FILE = "ovmf/ovmf-shell-image.wks" +inherit image + +# We want a minimal image with just ovmf-shell-efi unpacked in it. We +# avoid installing unnecessary stuff as much as possible, but some +# things still get through and need to be removed. +PACKAGE_INSTALL = "ovmf-shell-efi" +LINGUAS_INSTALL = "" +do_image () { + rm -rf `ls -d ${IMAGE_ROOTFS}/* | grep -v efi` +}
meta/recipes-core/ovmf/ovmf/0007-OvmfPkg-EnrollDefaultKeys-application-for-enrolling-.patch new file +1124 -0
1,124 lines not on this page · raw message
meta/recipes-core/ovmf/ovmf/ovmf-shell-image.wks new file +4 -0
@@ -0,0 +1,4 @@ +# short-description: Create an EFI disk image with just the EFI system partition + +part / --source rootfs --ondisk sda --fstype=vfat --align 1024 +bootloader --ptable gpt --timeout=5
meta/recipes-core/ovmf/ovmf_git.bb +22 -0
@@ -19,6 +19,7 @@ SRC_URI = "git://github.com/tianocore/edk2.git;branch=master \ SRC_URI_append_class-target = " \ ${@bb.utils.contains('PACKAGECONFIG', 'secureboot', 'http://www.openssl.org/source/openssl-1.0.2j.tar.gz;name=openssl;subdir=${S}/CryptoPkg/Library/OpensslLib', '', d)} \ + file://0007-OvmfPkg-EnrollDefaultKeys-application-for-enrolling-.patch \ " SRCREV="4575a602ca6072ee9d04150b38bfb143cbff8588"
@@ -136,6 +137,7 @@ do_compile_class-target() { ln ${build_dir}/FV/OVMF.fd ${WORKDIR}/ovmf/ovmf.fd ln ${build_dir}/FV/OVMF_CODE.fd ${WORKDIR}/ovmf/ovmf.code.fd ln ${build_dir}/FV/OVMF_VARS.fd ${WORKDIR}/ovmf/ovmf.vars.fd + ln ${build_dir}/${OVMF_ARCH}/Shell.efi ${WORKDIR}/ovmf/ if ${@bb.utils.contains('PACKAGECONFIG', 'secureboot', 'true', 'false', d)}; then # See CryptoPkg/Library/OpensslLib/Patch-HOWTO.txt and
@@ -150,6 +152,7 @@ do_compile_class-target() { ${S}/OvmfPkg/build.sh $PARALLEL_JOBS -a $OVMF_ARCH -b RELEASE -t ${FIXED_GCCVER} ${OVMF_SECURE_BOOT_FLAGS} ln ${build_dir}/FV/OVMF.fd ${WORKDIR}/ovmf/ovmf.secboot.fd ln ${build_dir}/FV/OVMF_CODE.fd ${WORKDIR}/ovmf/ovmf.secboot.code.fd + ln ${build_dir}/${OVMF_ARCH}/EnrollDefaultKeys.efi ${WORKDIR}/ovmf/ fi }
@@ -159,8 +162,27 @@ do_install_class-native() { } do_install_class-target() { + # Content for UEFI shell iso. We install the EFI shell as + # bootx64/ia32.efi because then it can be started even when the + # firmware itself does not contain it. + install -d ${D}/efi/boot + install ${WORKDIR}/ovmf/Shell.efi ${D}/efi/boot/boot${@ "ia32" if "${TARGET_ARCH}" != "x86_64" else "x64"}.efi + if ${@bb.utils.contains('PACKAGECONFIG', 'secureboot', 'true', 'false', d)}; then + install ${WORKDIR}/ovmf/EnrollDefaultKeys.efi ${D} + fi } +# This always gets packaged because ovmf-shell-image depends on it. +# This allows testing that recipe in all configurations because it +# can always be part of a world build. +# +# However, EnrollDefaultKeys.efi is only included when Secure Boot is enabled. +PACKAGES =+ "ovmf-shell-efi" +FILES_ovmf-shell-efi = " \ + EnrollDefaultKeys.efi \ + efi/ \ +" + do_deploy() { } do_deploy[cleandirs] = "${DEPLOYDIR}"
Signature · 1 line
2.1.4
PATCH v2 11/11 ovmf: remove BGRT patch
In reply to Patrick OhlyThis patch was added to meta-luv for kernel testing purposes and probably is not relevant for OE-core.
--- .../ovmf/0001-OvmfPkg-Enable-BGRT-in-OVMF.patch | 110 --------------------- meta/recipes-core/ovmf/ovmf_git.bb | 1 - 2 files changed, 111 deletions(-) delete mode 100644 meta/recipes-core/ovmf/ovmf/0001-OvmfPkg-Enable-BGRT-in-OVMF.patch
meta/recipes-core/ovmf/ovmf/0001-OvmfPkg-Enable-BGRT-in-OVMF.patch deleted +0 -110
@@ -1,110 +0,0 @@ -From 66a4020c3c2163aeffc9757851f33c346ecfd870 Mon Sep 17 00:00:00 2001 -From: Sai Praneeth Prakhya <[email protected]> -Date: Mon, 4 Apr 2016 12:15:12 -0700 -Subject: [PATCH] OvmfPkg: Enable BGRT in OVMF - -By default, firmware (OVMF - Open source Virtual Machine Firmware) -never publishes BGRT (Boot Graphics Resource Table) and in the boot -process Linux kernel checks for this table and if it fails to find BGRT -table then corresponding code in Linux kernel is not executed. EDK II -(EFI Development Kit, thus OVMF) already has BGRT source code packaged -into it but it is excluded from the build process of OVMF. These changes -to build system of OVMF enables BGRT in 32-bit and 64-bit OVMF. - -There are only two files that need to be modified in order to do this. -The first one being OvmfPkg*.dsc (this file describes the platform) and -the second one being OvmfPkg*.fdf (this file describes firmware descriptor -volume). A *.inf file (here "BootGraphicsResourceTableDxe.inf") -describes a module (here BGRT). So, include -"BootGraphicsResourceTableDxe.inf" file in "OvmfPkg*.dsc" so that BGRT -source code will be compiled and "BootGraphicsResourceTableDxe.efi" file -is generated and we should also include -"BootGraphicsResourceTableDxe.inf" file in "OvmfPkg*.fdf" file so that -"BootGraphicsResourceTableDxe.efi" will be placed in a firmware volume -and thus gets published. - -Signed-off-by: Sai Praneeth Prakhya <[email protected]> ---- - OvmfPkg/OvmfPkgIa32.dsc | 1 + - OvmfPkg/OvmfPkgIa32.fdf | 1 + - OvmfPkg/OvmfPkgIa32X64.dsc | 1 + - OvmfPkg/OvmfPkgIa32X64.fdf | 1 + - OvmfPkg/OvmfPkgX64.dsc | 1 + - OvmfPkg/OvmfPkgX64.fdf | 1 + - 6 files changed, 6 insertions(+) - -diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc -index 9e5b477..0582219 100644 ---- a/OvmfPkg/OvmfPkgIa32.dsc -+++ b/OvmfPkg/OvmfPkgIa32.dsc -@@ -647,6 +647,7 @@ - OvmfPkg/AcpiS3SaveDxe/AcpiS3SaveDxe.inf - MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf - MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf -+ MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf - - # - # Network Support -diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf -index fc203f2..f968cb7 100644 ---- a/OvmfPkg/OvmfPkgIa32.fdf -+++ b/OvmfPkg/OvmfPkgIa32.fdf -@@ -274,6 +274,7 @@ INF RuleOverride=ACPITABLE OvmfPkg/AcpiTables/AcpiTables.inf - INF OvmfPkg/AcpiS3SaveDxe/AcpiS3SaveDxe.inf - INF MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf - INF MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf -+INF MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf - - INF RuleOverride = BINARY FatBinPkg/EnhancedFatDxe/Fat.inf - -diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc -index 6e4da4f..8289385 100644 ---- a/OvmfPkg/OvmfPkgIa32X64.dsc -+++ b/OvmfPkg/OvmfPkgIa32X64.dsc -@@ -656,6 +656,7 @@ - OvmfPkg/AcpiS3SaveDxe/AcpiS3SaveDxe.inf - MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf - MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf -+ MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf - - # - # Network Support -diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf -index d3f46f3..282d40b 100644 ---- a/OvmfPkg/OvmfPkgIa32X64.fdf -+++ b/OvmfPkg/OvmfPkgIa32X64.fdf -@@ -274,6 +274,7 @@ INF RuleOverride=ACPITABLE OvmfPkg/AcpiTables/AcpiTables.inf - INF OvmfPkg/AcpiS3SaveDxe/AcpiS3SaveDxe.inf - INF MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf - INF MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf -+INF MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf - - INF RuleOverride = BINARY USE = X64 FatBinPkg/EnhancedFatDxe/Fat.inf - -diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc -index 3d6d43e..0f956a7 100644 ---- a/OvmfPkg/OvmfPkgX64.dsc -+++ b/OvmfPkg/OvmfPkgX64.dsc -@@ -654,6 +654,7 @@ - OvmfPkg/AcpiS3SaveDxe/AcpiS3SaveDxe.inf - MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf - MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf -+ MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf - - # - # Network Support -diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf -index 15ef13a..9708fd5 100644 ---- a/OvmfPkg/OvmfPkgX64.fdf -+++ b/OvmfPkg/OvmfPkgX64.fdf -@@ -274,6 +274,7 @@ INF RuleOverride=ACPITABLE OvmfPkg/AcpiTables/AcpiTables.inf - INF OvmfPkg/AcpiS3SaveDxe/AcpiS3SaveDxe.inf - INF MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf - INF MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf -+INF MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf - - INF RuleOverride = BINARY FatBinPkg/EnhancedFatDxe/Fat.inf - --- -2.7.4 -
meta/recipes-core/ovmf/ovmf_git.bb +0 -1
@@ -12,7 +12,6 @@ PACKAGECONFIG[secureboot] = ",,," SRC_URI = "git://github.com/tianocore/edk2.git;branch=master \ file://0001-BaseTools-Force-tools-variables-to-host-toolchain.patch \ - file://0001-OvmfPkg-Enable-BGRT-in-OVMF.patch \ file://0002-ovmf-update-path-to-native-BaseTools.patch \ file://0003-BaseTools-makefile-adjust-to-build-in-under-bitbake.patch \ "
Signature · 1 line
2.1.4
Re: [PATCH v2 09/11] runqemu: support UEFI with OVMF firmware
In reply to Patrick OhlyQuoted 3 lines · Patrick Ohly
ovmf is not built by default. Either do it explicitly ("bitbake ovmf") or make it a part of the normal build ("
MACHINE_ESSENTIAL_EXTRA_RDEPENDS_append= ' ovmf'").
Wrong advice in the commit message: MACHINE_ESSENTIAL_EXTRA_RDEPENDS doesn't work (it tries to install a non-existent ovmf package into the rootfs and fails), use EXTRA_IMAGEDEPENDS instead (same mechanism that also triggers building qemu-native).
I'll fix this if a v3 of this series becomes necessary, but wouldn't do that just for this fix alone.
Signature · 6 lines
Best Regards, Patrick Ohly The content of this message is my personal opinion only and although I am an employee of Intel, the statements I make here in no way represent Intel's position on the issue, nor am I authorized to speak on behalf of Intel on this matter.