Subject: [PATCH 0/1] Add grub-coreboot
From: Denis 'GNUtoo' Carikli <[email-masked]>
To: [email-masked]
Cc: Denis 'GNUtoo' Carikli <[email-masked]>
Date: Sun, 16 Jul 2023 18:49:32 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,

In the following mail there will be a patch that adds grub-coreboot.

The './pre-inst-env guix lint grub-coreboot' command shows some warnings:
    [...]/bootloaders.scm:301:2: [email-masked]:
    label 'qemu' does not match package name 'qemu-minimal'
    [...]/bootloaders.scm:301:2: [email-masked]:
    label 'gettext' does not match package name 'gettext-minimal'
    [...]/bootloaders.scm:301:2: [email-masked]:
    file names of patches should start with the package name
    [...]/bootloaders.scm:301:2: [email-masked]:
    probably vulnerable to CVE-2022-2601, CVE-2022-3775, CVE-2021-3981
    [...]/bootloaders.scm:301:2: [email-masked]:
    updater 'gnu' failed to find upstream releases
but since this package is based on grub-coreboot, I guess that things should
be fixed there instead.

A standalone image was built with the following commands:

    modules="ahci at_keyboard cbfs ehci ext2 fat ohci part_gpt part_msdos \
             pata uhci usb_keyboard usbms usbserial_usbdebug"

    install_modules="acpi ahci all_video archelp at_keyboard ata blocklist \
    boot btrfs cat cbfs cbls cbls cbmemc cbmemc cbtime cbtime chain chain \
    cmosdump cmostest cmp configfile configfile cpio cpuid crc64 crypto \
    cryptodisk cs5536 date datehook datetime disk diskfilter div dm_nv echo \
    echo ehci elf eval exfat ext2 extcmd fat file fshelp gcry_crc gcry_rfc2268 \
    gcry_rijndael gcry_rsa gcry_seed gcry_serpent gcry_sha1 gcry_sha256 \
    gcry_sha512 gcry_twofish gettext gfxmenu gfxterm_background gfxterm_menu \
    gptsync gzio gzio halt halt hashsum hdparm help help hexdump hexdump iorw \
    iorw iso9660 jpeg keylayouts keystatus ldm linux linux linux16 linux16 \
    loadenv loopback ls ls lsacpi lsacpi lsmmap lsmmap lspci lspci luks lvm \
    lzopio mda_text memdisk memrw memrw minicmd minicmd mmap morse mpi \
    msdospart multiboot multiboot multiboot2 nativedisk newc nilfs2 normal \
    normal odc offsetio ohci part_gpt part_msdos parttool password \
    password_pbkdf2 password_pbkdf2 pata pbkdf2 pci pcidump pcidump pgp play \
    priority_queue probe procfs progress random read reboot reboot regexp \
    regexp relocator romfs scsi search search search_fs_file search_fs_uuid \
    search_label serial serial setjmp setpci setpci sfs sleep spkmodem squash4 \
    syslinuxcfg syslinuxcfg tar terminal terminfo test test testload testspeed \
    time tr trig true udf uhci usb usb_keyboard usbms usbserial_common \
    usbserial_ftdi usbserial_pl2303 usbserial_usbdebug video_colors videoinfo \
    xnu xzio"

    "/gnu/store/[...]/bin/grub-mkstandalone" \
	-O i386-coreboot \
	-o grub_payload.elf \
	--fonts= \
	--themes= \
	--locales= \
	--modules="${modules}" \
	--install-modules="${install_modules}" \
	/boot/grub/grub.cfg=coreboot.cfg

The coreboot.cfg file was taken from grub source code (GPLv3+) and consist of
the following:
    
    if test -f (cbfsdisk)/etc/grub.cfg; then
       source (cbfsdisk)/etc/grub.cfg
    fi

The resulting image was tested on a Thinkpad X200 running a custom 100% free
software version of Coreboot with as a GRUB payload) with the following
commands:
  
    chainloader /path/to/grub_payload.elf
    boot

It then booted fine. As for the partitions I used, I have LUKS encrypted hard
drive with LVM2 and a mix of BTRFS and ext4 partitions.

Denis 'GNUtoo' Carikli (1):
  gnu: Add grub-coreboot

 gnu/packages/bootloaders.scm | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

base-commit: 796c823a0d1d0aec9f4af908eca462e58e5675b5
-- 
2.41.0