summaryrefslogtreecommitdiff
path: root/payloads
diff options
context:
space:
mode:
authorNico Huber <nico.h@gmx.de>2020-07-18 16:29:18 +0200
committerPatrick Georgi <pgeorgi@google.com>2020-08-24 09:13:35 +0000
commit4a7325228f7afbb47a35300a76bde5e5da0a833a (patch)
treed0632e7598f5f85c822c42439c1c64a9f35c6197 /payloads
parentbea01e32b277682d273fa4a054f34cf725cb15b7 (diff)
downloadcoreboot-4a7325228f7afbb47a35300a76bde5e5da0a833a.tar.xz
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 <nico.h@gmx.de> Reviewed-on: https://review.coreboot.org/c/coreboot/+/43581 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'payloads')
-rw-r--r--payloads/libpayload/include/sysinfo.h31
-rw-r--r--payloads/libpayload/libc/coreboot.c7
2 files changed, 21 insertions, 17 deletions
diff --git a/payloads/libpayload/include/sysinfo.h b/payloads/libpayload/include/sysinfo.h
index a1b0545074..fe3d3304c4 100644
--- a/payloads/libpayload/include/sysinfo.h
+++ b/payloads/libpayload/include/sysinfo.h
@@ -42,10 +42,11 @@
#include <coreboot_tables.h>
/*
- * All pointers in here shall be virtual.
+ * This is a collection of information and pointers gathered
+ * mostly from the coreboot table.
*
- * If a relocation happens after the last call to lib_get_sysinfo(),
- * it is up to the user to call lib_get_sysinfo() again.
+ * We do not store virtual pointers in here to avoid problems
+ * with self-relocating payloads.
*/
struct sysinfo_t {
unsigned int cpu_khz;
@@ -68,18 +69,18 @@ struct sysinfo_t {
u32 vbnv_start;
u32 vbnv_size;
- char *version;
- char *extra_version;
- char *build;
- char *compile_time;
- char *compile_by;
- char *compile_host;
- char *compile_domain;
- char *compiler;
- char *linker;
- char *assembler;
+ uintptr_t version;
+ uintptr_t extra_version;
+ uintptr_t build;
+ uintptr_t compile_time;
+ uintptr_t compile_by;
+ uintptr_t compile_host;
+ uintptr_t compile_domain;
+ uintptr_t compiler;
+ uintptr_t linker;
+ uintptr_t assembler;
- char *cb_version;
+ uintptr_t cb_version;
struct cb_framebuffer framebuffer;
@@ -87,7 +88,7 @@ struct sysinfo_t {
struct cb_gpio gpios[SYSINFO_MAX_GPIOS];
int num_macs;
struct mac_address macs[SYSINFO_MAX_MACS];
- char *serialno;
+ uintptr_t serialno;
unsigned long *mbtable; /** Pointer to the multiboot table */
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)