From 4a7325228f7afbb47a35300a76bde5e5da0a833a Mon Sep 17 00:00:00 2001 From: Nico Huber Date: Sat, 18 Jul 2020 16:29:18 +0200 Subject: libpayload: Cache physical location of strings In the presence of self-relocating payloads, it's safer to keep physical addresses in `libsysinfo`. This updates the remaining pointers that are not consumed by libpayload code, all of them strings. Also update the comment that `libsysinfo` only containts physical addresses. Change-Id: I9d095c826b00d621201c34b329fb9b5beb1ec794 Signed-off-by: Nico Huber Reviewed-on: https://review.coreboot.org/c/coreboot/+/43581 Tested-by: build bot (Jenkins) Reviewed-by: Angel Pons Reviewed-by: Julius Werner --- payloads/libpayload/libc/coreboot.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'payloads/libpayload/libc') diff --git a/payloads/libpayload/libc/coreboot.c b/payloads/libpayload/libc/coreboot.c index b34f2c582f..c48b6cffd8 100644 --- a/payloads/libpayload/libc/coreboot.c +++ b/payloads/libpayload/libc/coreboot.c @@ -184,9 +184,12 @@ static void cb_parse_framebuffer(void *ptr, struct sysinfo_t *info) } #endif -static void cb_parse_string(unsigned char *ptr, char **info) +static void cb_parse_string(const void *const ptr, uintptr_t *const info) { - *info = (char *)((struct cb_string *)ptr)->string; + /* ptr is already virtual (str->string just an offset to that), + but we want to keep physical addresses */ + const struct cb_string *const str = ptr; + *info = virt_to_phys(str->string); } static void cb_parse_wifi_calibration(void *ptr, struct sysinfo_t *info) -- cgit v1.2.3