diff options
author | Aaron Durbin <adurbin@chromium.org> | 2015-04-21 15:20:46 -0500 |
---|---|---|
committer | Aaron Durbin <adurbin@chromium.org> | 2015-04-22 15:48:11 +0200 |
commit | 696689bfb11933565db8fac6921dcb082abcb2ec (patch) | |
tree | 00a59ba418863fe0319af8c8996b3226dd2f866a /src/mainboard | |
parent | 69cb2c2b5e4c4e4db005dc57249c0d15cadea5ee (diff) |
qemu-armv7: fix cbfs media implementation
When using qemu-armv7 to load coreboot.rom with the -kernel
flag the rom is offset by 0x10000. Therefore only allow
mappings within 0x10000 and 0x10000 + CONFIG_ROM_SIZE.
TEST= QEMU_AUDIO_DRV=none qemu-system-arm -M vexpress-a9 \
-m 1024M -nographic \
-kernel coreboot-builds/emulation_qemu-armv7/coreboot.rom
Change-Id: Ifec5761a7d54685f664c54efaa31949b8cc94bad
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: http://review.coreboot.org/9935
Tested-by: build bot (Jenkins)
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Diffstat (limited to 'src/mainboard')
-rw-r--r-- | src/mainboard/emulation/qemu-armv7/media.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/mainboard/emulation/qemu-armv7/media.c b/src/mainboard/emulation/qemu-armv7/media.c index c3760ab033..8c71263e67 100644 --- a/src/mainboard/emulation/qemu-armv7/media.c +++ b/src/mainboard/emulation/qemu-armv7/media.c @@ -26,7 +26,9 @@ static int emu_rom_open(struct cbfs_media *media) static void *emu_rom_map(struct cbfs_media *media, size_t offset, size_t count) { - return (void*)offset; + if (offset + count > CONFIG_ROM_SIZE) + return (void *)-1; + return (void*)(offset + 0x10000); } static void *emu_rom_unmap(struct cbfs_media *media, const void *address) @@ -38,6 +40,10 @@ static size_t emu_rom_read(struct cbfs_media *media, void *dest, size_t offset, size_t count) { void *ptr = emu_rom_map(media, offset, count); + + if (ptr == (void *)-1) + return 0; + memcpy(dest, ptr, count); emu_rom_unmap(media, ptr); return count; |