[coreboot-gerrit] Patch set updated for coreboot: 6c28803 libpayload: allow for pointers in cbfs ram media

Stefan Reinauer (stefan.reinauer@coreboot.org) gerrit at coreboot.org
Wed Nov 20 01:10:57 CET 2013

Stefan Reinauer (stefan.reinauer at coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/4193


commit 6c2880359509f9fe3110cea0fab3e48862b0f1ba
Author: Aaron Durbin <adurbin at chromium.org>
Date:   Fri May 24 13:34:38 2013 -0500

    libpayload: allow for pointers in cbfs ram media
    The ram_map() handled offsets from 0->size as well as
    negative offsets from the top of the region. However,
    the cbfs core tries to map a offset that is actually a
    pointer within the region itself. Allow for such instances.
    This fixes an issue when using ram_media with tthe ebmedded
    SeaBIOS cbfs.
    Change-Id: I15b0b3b643390d3784ae5887c0f17d420d59c5b6
    Signed-off-by: Aaron Durbin <adurbin at chromium.org>
    Reviewed-on: https://gerrit.chromium.org/gerrit/56641
    Reviewed-by: Duncan Laurie <dlaurie at chromium.org>
    Reviewed-by: Stefan Reinauer <reinauer at google.com>
 payloads/libpayload/libcbfs/ram_media.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/payloads/libpayload/libcbfs/ram_media.c b/payloads/libpayload/libcbfs/ram_media.c
index 859555c..9f11a31 100644
--- a/payloads/libpayload/libcbfs/ram_media.c
+++ b/payloads/libpayload/libcbfs/ram_media.c
@@ -43,6 +43,12 @@ static int ram_open(struct cbfs_media *media) {
 static void *ram_map(struct cbfs_media *media, size_t offset, size_t count) {
 	struct ram_media *m = (struct ram_media*)media->context;
+	/* Special case an absolute pointer within the region. */
+	if (offset >= (uintptr_t)m->start &&
+	    offset < ((uintptr_t)m->start + m->size))
+		return (void *)offset;
 	/* assume addressing from top of image in this case */
 	if (offset > 0xf0000000) {
 		offset = m->size + offset;

More information about the coreboot-gerrit mailing list