Skip to content
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

[WIP] EVE Custom EFI App to change UEFI setings #4318

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 21 additions & 1 deletion pkg/dom0-ztools/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# syntax=docker/dockerfile-upstream:1.5.0-rc2-labs
FROM lfedge/eve-alpine:82df60e43ab9f8c935584b8c7b4d0a4b0271d608 as zfs
ENV BUILD_PKGS git patch ca-certificates util-linux build-base gettext-dev libtirpc-dev automake autoconf \
libtool linux-headers attr-dev e2fsprogs-dev glib-dev openssl-dev util-linux-dev coreutils
libtool linux-headers attr-dev e2fsprogs-dev glib-dev openssl-dev util-linux-dev coreutils gnu-efi gnu-efi-dev mtools
ENV PKGS ca-certificates util-linux libintl libuuid libtirpc libblkid libcrypto1.1 zlib
RUN eve-alpine-deploy.sh

Expand Down Expand Up @@ -42,6 +42,26 @@
# Add directory for CDI files
RUN mkdir -p /out/etc/cdi

# build dosfstools, the one that is in alpine (busybox) is too old
# and doesn't support creating small FAT filesystems.
WORKDIR /mkfs
ADD https://github.com/dosfstools/dosfstools.git#v4.2 dosfstools
RUN cd dosfstools && \

Check failure on line 49 in pkg/dom0-ztools/Dockerfile

View workflow job for this annotation

GitHub Actions / yetus

hadolint: DL3003 warning: Use WORKDIR to switch to a directory
./autogen.sh && \
./configure --prefix=/mkfs/dosfstools/bin && \
make && \
make install
WORKDIR /efi
COPY efi/ .
RUN make all && \
mkdir -p /out/etc/ovmf && \
cp efi_run.sh /out/etc/ovmf/ && \
chmod +x /out/etc/ovmf/efi_run.sh && \
dd if=/dev/zero of=/out/etc/ovmf/eve_efi.img bs=1M count=1 && \
/mkfs/dosfstools/bin/sbin/mkfs.fat /out/etc/ovmf/eve_efi.img && \
mcopy -i /out/etc/ovmf/eve_efi.img startup.nsh :: && \
mcopy -i /out/etc/ovmf/eve_efi.img efi_eveutil.efi ::

FROM scratch
COPY --from=zfs /out/ /
# hadolint ignore=DL3020
Expand Down
32 changes: 32 additions & 0 deletions pkg/dom0-ztools/efi/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
ARCH = $(shell uname -m | sed s,i[3456789]86,ia32,)
OBJS = main.o
TARGE_SO = efi_eveutil.so
TARGET_EFI = efi_eveutil.efi
EFIINC = /usr/include/efi
EFIINCS = -I$(EFIINC) -I$(EFIINC)/$(ARCH) -I$(EFIINC)/protocol
LIB = /usr/lib
EFILIB = /usr/lib
EFI_CRT_OBJS = $(EFILIB)/crt0-efi-$(ARCH).o
EFI_LDS = $(EFILIB)/elf_$(ARCH)_efi.lds

CFLAGS = $(EFIINCS) -fno-stack-protector -fpic \
-fshort-wchar -mno-red-zone -Wall -Werror
ifeq ($(ARCH),x86_64)
CFLAGS += -DEFI_FUNCTION_WRAPPER
endif

LDFLAGS = -nostdlib -znocombreloc -T $(EFI_LDS) -shared \
-Bsymbolic -L $(EFILIB) -L $(LIB) $(EFI_CRT_OBJS)

Check failure on line 19 in pkg/dom0-ztools/efi/Makefile

View workflow job for this annotation

GitHub Actions / yetus

blanks:end of line

all: $(TARGET_EFI)

$(TARGE_SO): $(OBJS)
ld $(LDFLAGS) $(OBJS) -o $@ -lefi -lgnuefi

Check failure on line 25 in pkg/dom0-ztools/efi/Makefile

View workflow job for this annotation

GitHub Actions / yetus

blanks:end of line
clean:
rm -f $(OBJS) $(TARGE_EFI) $(TARGE_SO)

%.efi: %.so
objcopy -j .text -j .sdata -j .data -j .dynamic \
-j .dynsym -j .rel -j .rela -j .reloc \
--target=efi-app-$(ARCH) $^ $@
11 changes: 11 additions & 0 deletions pkg/dom0-ztools/efi/efi_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
mkdir -p /run/kvm
cp /hostfs/etc/ovmf/eve_efi.img /run/kvm/eve_efi.img
/usr/lib/xen/bin/qemu-system-x86_64 \
-machine "type=pc-q35-3.1" \
-drive "if=pflash,unit=0,format=raw,readonly=on,file=/usr/lib/xen/boot/OVMF_CODE.fd" \
-drive "if=pflash,unit=1,format=raw,readonly=off,file=${1}" \
-drive "file=/run/kvm/eve_efi.img,format=raw" \
-smbios "type=11,value=${2}" \
-net none \
-nographic
Loading
Loading