[coreboot-gerrit] New patch to review for coreboot: 164bbe1 qemu-armv7: fix cbfs media implementation

Aaron Durbin (adurbin@chromium.org) gerrit at coreboot.org
Tue Apr 21 22:25:06 CEST 2015


Aaron Durbin (adurbin at chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/9935

-gerrit

commit 164bbe141dd3dbb1926eb78eee809913ce1be03c
Author: Aaron Durbin <adurbin at chromium.org>
Date:   Tue Apr 21 15:20:46 2015 -0500

    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 at chromium.org>
---
 src/mainboard/emulation/qemu-armv7/media.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/mainboard/emulation/qemu-armv7/media.c b/src/mainboard/emulation/qemu-armv7/media.c
index c3760ab..8c71263 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;



More information about the coreboot-gerrit mailing list