diff options
author | Patrick Rudolph <patrick.rudolph@9elements.com> | 2019-06-12 16:22:11 +0200 |
---|---|---|
committer | Patrick Rudolph <siro@das-labor.org> | 2019-07-30 08:59:48 +0000 |
commit | 8a48c923385ac86fe80ada3fa6555985494fd107 (patch) | |
tree | fb27e11a5be6f8549ebb363487cfb7722464d156 /src/mainboard/emulation | |
parent | c19161538cfdec472c9883c41649c8159e4dfeb1 (diff) |
mb/emulation/qemu-riscv: Protect CBFS from payload loader
The virt machine is special as it doesn't emulate flash and it puts
the coreboot.rom at start of DRAM. The payload loader doesn't know
about CBFS in DRAM and overwrites the CBFS while decompressing
payloads, resulting in undefined behaviour.
Mark the region as SRAM to make sure the payload won't
overwrite the CBFS while decompressing.
As payload is always decompressed to DRAM, it wouldn't touch
SRAM memory regions.
Change-Id: I36a18cb727f660ac9e77df413026627ea160c1e1
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/33426
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Philipp Deppenwiese <zaolin.daisuki@gmail.com>
Diffstat (limited to 'src/mainboard/emulation')
-rw-r--r-- | src/mainboard/emulation/qemu-riscv/memlayout.ld | 17 | ||||
-rw-r--r-- | src/mainboard/emulation/qemu-riscv/rom_media.c | 2 |
2 files changed, 13 insertions, 6 deletions
diff --git a/src/mainboard/emulation/qemu-riscv/memlayout.ld b/src/mainboard/emulation/qemu-riscv/memlayout.ld index 7f8ec3dd6a..2166d23f31 100644 --- a/src/mainboard/emulation/qemu-riscv/memlayout.ld +++ b/src/mainboard/emulation/qemu-riscv/memlayout.ld @@ -17,16 +17,23 @@ #include <arch/header.ld> #include <mainboard/addressmap.h> -//Stages start after CBFS in DRAM +// Stages start after CBFS in DRAM #define STAGES_START (QEMU_VIRT_DRAM + CONFIG_ROM_SIZE) SECTIONS { - DRAM_START(QEMU_VIRT_DRAM) + // the virt target doesn't emulate flash and just puts the CBFS into DRAM. + // fake SRAM where CBFS resides. It's only done for better integration. + SRAM_START(QEMU_VIRT_DRAM) BOOTBLOCK(QEMU_VIRT_DRAM, 64K) // CBFS goes here - STACK(STAGES_START, 4K) - ROMSTAGE(STAGES_START + 64K, 128K) - PRERAM_CBMEM_CONSOLE(STAGES_START + 192K, 8K) + SRAM_END(STAGES_START) + DRAM_START(STAGES_START) + +#if ENV_ROMSTAGE + ROMSTAGE(STAGES_START, 128K) +#endif + PRERAM_CBMEM_CONSOLE(STAGES_START + 128K, 8K) RAMSTAGE(STAGES_START + 200K, 16M) + STACK(STAGES_START + 200K + 16M, 4K) } diff --git a/src/mainboard/emulation/qemu-riscv/rom_media.c b/src/mainboard/emulation/qemu-riscv/rom_media.c index bac19846c5..79e5ca8f54 100644 --- a/src/mainboard/emulation/qemu-riscv/rom_media.c +++ b/src/mainboard/emulation/qemu-riscv/rom_media.c @@ -19,7 +19,7 @@ /* This assumes that the CBFS resides at start of dram, which is true for the * default configuration. */ static const struct mem_region_device boot_dev = - MEM_REGION_DEV_RO_INIT(_dram, CONFIG_ROM_SIZE); + MEM_REGION_DEV_RO_INIT(_sram, CONFIG_ROM_SIZE); const struct region_device *boot_device_ro(void) { |