Attention is currently required from: Maximilian Brune, Philipp Hug, ron minnich.
Carlos López has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/85677?usp=email )
Change subject: mb/qemu-riscv: enable vboot ......................................................................
mb/qemu-riscv: enable vboot
Add the option to enable vboot for the qemu-riscv board. In order to do this, enable the qemu boot device driver, so that vboot is able to store and modify data in flash, as well as the fw_cfg driver.
Additionally, add FMD files to describe the two different vboot FMAP configurations (A or A + B), and update the memory layout in the linker script to acommodate for the VBOOT2_WORK buffer.
TEST=boot verified with qemu-system-riscv64 + OpenSBI Change-Id: I5a6dfa10b66c20851c5012679a9bc0168d1cf17c Signed-off-by: Carlos López carlos.lopez@openchip.com --- M src/mainboard/emulation/qemu-riscv/Kconfig M src/mainboard/emulation/qemu-riscv/Makefile.mk M src/mainboard/emulation/qemu-riscv/memlayout.ld M src/mainboard/emulation/qemu-riscv/rom_media.c A src/mainboard/emulation/qemu-riscv/vboot-rwa.fmd A src/mainboard/emulation/qemu-riscv/vboot-rwab.fmd 6 files changed, 68 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/77/85677/1
diff --git a/src/mainboard/emulation/qemu-riscv/Kconfig b/src/mainboard/emulation/qemu-riscv/Kconfig index 2361e25..ac9bde6 100644 --- a/src/mainboard/emulation/qemu-riscv/Kconfig +++ b/src/mainboard/emulation/qemu-riscv/Kconfig @@ -35,6 +35,17 @@ select ARCH_ROMSTAGE_RISCV select ARCH_RAMSTAGE_RISCV select RISCV_USE_ARCH_TIMER + select BOOT_DEVICE_MEMORY_MAPPED + select DRIVERS_EMULATION_QEMU_FW_CFG + select DRIVERS_EMULATION_QEMU_BOOT_DEVICE + +config VBOOT + select VBOOT_STARTS_IN_BOOTBLOCK + select VBOOT_VBNV_FLASH + +config FMDFILE + default "src/mainboard/emulation/qemu-riscv/vboot-rwa.fmd" if VBOOT_SLOTS_RW_A && !VBOOT_SLOTS_RW_AB + default "src/mainboard/emulation/qemu-riscv/vboot-rwab.fmd" if VBOOT_SLOTS_RW_AB
config MEMLAYOUT_LD_FILE string diff --git a/src/mainboard/emulation/qemu-riscv/Makefile.mk b/src/mainboard/emulation/qemu-riscv/Makefile.mk index bed0f80..55e6e79 100644 --- a/src/mainboard/emulation/qemu-riscv/Makefile.mk +++ b/src/mainboard/emulation/qemu-riscv/Makefile.mk @@ -18,4 +18,6 @@ ramstage-y += cbmem.c ramstage-y += chip.c
+all-y += ../qemu-i440fx/bootmode.c + CPPFLAGS_common += -I$(src)/mainboard/$(MAINBOARDDIR)/include diff --git a/src/mainboard/emulation/qemu-riscv/memlayout.ld b/src/mainboard/emulation/qemu-riscv/memlayout.ld index 9c16496..e02c335 100644 --- a/src/mainboard/emulation/qemu-riscv/memlayout.ld +++ b/src/mainboard/emulation/qemu-riscv/memlayout.ld @@ -16,5 +16,8 @@ PRERAM_CBMEM_CONSOLE(QEMU_VIRT_DRAM + 128K + 256K + 256K + 2M, 8K) FMAP_CACHE(QEMU_VIRT_DRAM + 128K + 256K + 256K + 2M + 8K, 2K) CBFS_MCACHE(QEMU_VIRT_DRAM + 128K + 256K + 256K + 2M + 8K + 2K, 10K) - STACK(QEMU_VIRT_DRAM + 128K + 256K + 256K + 2M + 8K + 2K + 10K, 4M) +#if CONFIG(VBOOT_STARTS_IN_BOOTBLOCK) + VBOOT2_WORK(QEMU_VIRT_DRAM + 128K + 256K + 256K + 2M + 8K + 2K + 10K, VB2_FIRMWARE_WORKBUF_RECOMMENDED_SIZE) +#endif + STACK(QEMU_VIRT_DRAM + 4M, 4M) } diff --git a/src/mainboard/emulation/qemu-riscv/rom_media.c b/src/mainboard/emulation/qemu-riscv/rom_media.c index 3c636ce..531bca8 100644 --- a/src/mainboard/emulation/qemu-riscv/rom_media.c +++ b/src/mainboard/emulation/qemu-riscv/rom_media.c @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ #include <boot_device.h> +#include <device/qemu_boot_device.h> #include <symbols.h> #include <mainboard/addressmap.h>
@@ -10,3 +11,8 @@ { return &boot_dev.rdev; } + +void *qemu_boot_device_addr(void) +{ + return (void *)QEMU_VIRT_FLASH; +} diff --git a/src/mainboard/emulation/qemu-riscv/vboot-rwa.fmd b/src/mainboard/emulation/qemu-riscv/vboot-rwa.fmd new file mode 100644 index 0000000..741d4ba --- /dev/null +++ b/src/mainboard/emulation/qemu-riscv/vboot-rwa.fmd @@ -0,0 +1,20 @@ +FLASH@0 0x02000000 { + BIOS@0 0x02000000 { + WP_RO { + BOOTBLOCK 128K + FMAP 0x800 + RO_FRID 0x40 + RO_PADDING 0x7c0 + GBB 0x1e000 + COREBOOT(CBFS) + } + RW_SECTION_A 0x1c0000 { + VBLOCK_A@0x0 0x10000 + FW_MAIN_A(CBFS) + RW_FWID_A 0x40 + } + + RW_VPD(PRESERVE) 0x1000 + RW_NVRAM(PRESERVE) 0x6000 + } +} diff --git a/src/mainboard/emulation/qemu-riscv/vboot-rwab.fmd b/src/mainboard/emulation/qemu-riscv/vboot-rwab.fmd new file mode 100644 index 0000000..af4c8ea --- /dev/null +++ b/src/mainboard/emulation/qemu-riscv/vboot-rwab.fmd @@ -0,0 +1,25 @@ +FLASH@0 0x02000000 { + BIOS@0 0x02000000 { + WP_RO { + BOOTBLOCK 128K + FMAP 0x800 + RO_FRID 0x40 + RO_PADDING 0x7c0 + GBB 0x1e000 + COREBOOT(CBFS) + } + RW_SECTION_A 0x1c0000 { + VBLOCK_A@0x0 0x10000 + FW_MAIN_A(CBFS) + RW_FWID_A 0x40 + } + RW_SECTION_B 0x1c0000 { + VBLOCK_B@0x0 0x10000 + FW_MAIN_B(CBFS) + RW_FWID_B 0x40 + } + + RW_VPD(PRESERVE) 0x1000 + RW_NVRAM(PRESERVE) 0x6000 + } +}