summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNico Huber <nico.h@gmx.de>2020-07-18 16:15:42 +0200
committerPatrick Georgi <pgeorgi@google.com>2020-08-24 09:13:30 +0000
commitbea01e32b277682d273fa4a054f34cf725cb15b7 (patch)
tree3c94473ea766b8440fca31d9af932198ad0232ed
parent12faea3095cbdb4f134442db1451487355368cf8 (diff)
downloadcoreboot-bea01e32b277682d273fa4a054f34cf725cb15b7.tar.xz
libpayload: Cache physical location of CBMEM entries
In the presence of self-relocating payloads, it's safer to keep physical addresses in `libsysinfo`. This updates all the references to CBMEM entries that are not consumed inside libpayload code. Change-Id: I3be64c8be8b46d00b457eafd7f80a8ed8e604030 Signed-off-by: Nico Huber <nico.h@gmx.de> Reviewed-on: https://review.coreboot.org/c/coreboot/+/43580 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
-rw-r--r--payloads/coreinfo/timestamps_module.c2
-rw-r--r--payloads/libpayload/arch/x86/coreboot.c2
-rw-r--r--payloads/libpayload/include/coreboot_tables.h1
-rw-r--r--payloads/libpayload/include/sysinfo.h16
-rw-r--r--payloads/libpayload/libc/coreboot.c18
5 files changed, 16 insertions, 23 deletions
diff --git a/payloads/coreinfo/timestamps_module.c b/payloads/coreinfo/timestamps_module.c
index 32f1866693..c8b8df2d85 100644
--- a/payloads/coreinfo/timestamps_module.c
+++ b/payloads/coreinfo/timestamps_module.c
@@ -147,7 +147,7 @@ static int timestamps_module_init(void)
if (ret)
return -1;
- struct timestamp_table *timestamps = lib_sysinfo.tstamp_table;
+ struct timestamp_table *timestamps = phys_to_virt(lib_sysinfo.tstamp_table);
if (timestamps == NULL)
return -1;
diff --git a/payloads/libpayload/arch/x86/coreboot.c b/payloads/libpayload/arch/x86/coreboot.c
index bf16b71f97..38ede875c7 100644
--- a/payloads/libpayload/arch/x86/coreboot.c
+++ b/payloads/libpayload/arch/x86/coreboot.c
@@ -49,7 +49,7 @@ static void cb_parse_x86_rom_var_mtrr(void *ptr, struct sysinfo_t *info)
static void cb_parse_mrc_cache(void *ptr, struct sysinfo_t *info)
{
- info->mrc_cache = get_cbmem_ptr(ptr);
+ info->mrc_cache = get_cbmem_addr(ptr);
}
int cb_parse_arch_specific(struct cb_record *rec, struct sysinfo_t *info)
diff --git a/payloads/libpayload/include/coreboot_tables.h b/payloads/libpayload/include/coreboot_tables.h
index c281417f10..bf8c0d9303 100644
--- a/payloads/libpayload/include/coreboot_tables.h
+++ b/payloads/libpayload/include/coreboot_tables.h
@@ -396,6 +396,5 @@ static inline const char *cb_mb_part_string(const struct cb_mainboard *cbm)
+ (sizeof((_rec)->map[0]) * (_idx)))
/* Helper functions */
-void *get_cbmem_ptr(unsigned char *ptr);
uintptr_t get_cbmem_addr(const void *cbmem_tab_entry);
#endif
diff --git a/payloads/libpayload/include/sysinfo.h b/payloads/libpayload/include/sysinfo.h
index 33610c3c79..a1b0545074 100644
--- a/payloads/libpayload/include/sysinfo.h
+++ b/payloads/libpayload/include/sysinfo.h
@@ -94,23 +94,23 @@ struct sysinfo_t {
uintptr_t cb_header;
uintptr_t cb_mainboard;
- void *vboot_workbuf;
+ uintptr_t vboot_workbuf;
#if CONFIG(LP_ARCH_X86)
int x86_rom_var_mtrr_index;
#endif
- void *tstamp_table;
+ uintptr_t tstamp_table;
uintptr_t cbmem_cons;
- void *mrc_cache;
- void *acpi_gnvs;
+ uintptr_t mrc_cache;
+ uintptr_t acpi_gnvs;
#define UNDEFINED_STRAPPING_ID (~0)
u32 board_id;
u32 ram_code;
u32 sku_id;
- void *wifi_calibration;
+ uintptr_t wifi_calibration;
uint64_t ramoops_buffer;
uint32_t ramoops_buffer_size;
struct {
@@ -124,11 +124,11 @@ struct sysinfo_t {
uint64_t boot_media_size;
uint64_t mtc_start;
uint32_t mtc_size;
- void *chromeos_vpd;
- int mmc_early_wake_status;
+ uintptr_t chromeos_vpd;
+ int mmc_early_wake_status;
/* Pointer to FMAP cache in CBMEM */
- void *fmap_cache;
+ uintptr_t fmap_cache;
};
extern struct sysinfo_t lib_sysinfo;
diff --git a/payloads/libpayload/libc/coreboot.c b/payloads/libpayload/libc/coreboot.c
index be2eebb56d..b34f2c582f 100644
--- a/payloads/libpayload/libc/coreboot.c
+++ b/payloads/libpayload/libc/coreboot.c
@@ -41,12 +41,6 @@
/* === Parsing code === */
/* This is the generic parsing code. */
-void *get_cbmem_ptr(unsigned char *ptr)
-{
- struct cb_cbmem_tab *const cbmem = (struct cb_cbmem_tab *)ptr;
- return phys_to_virt(cbmem->cbmem_tab);
-}
-
uintptr_t get_cbmem_addr(const void *const cbmem_tab_entry)
{
const struct cb_cbmem_tab *const cbmem = cbmem_tab_entry;
@@ -91,7 +85,7 @@ static void cb_parse_serial(void *ptr, struct sysinfo_t *info)
static void cb_parse_vboot_workbuf(unsigned char *ptr, struct sysinfo_t *info)
{
- info->vboot_workbuf = get_cbmem_ptr(ptr);
+ info->vboot_workbuf = get_cbmem_addr(ptr);
}
static void cb_parse_vbnv(unsigned char *ptr, struct sysinfo_t *info)
@@ -136,7 +130,7 @@ static void cb_parse_mac_addresses(unsigned char *ptr,
static void cb_parse_tstamp(unsigned char *ptr, struct sysinfo_t *info)
{
- info->tstamp_table = get_cbmem_ptr(ptr);
+ info->tstamp_table = get_cbmem_addr(ptr);
}
static void cb_parse_cbmem_cons(unsigned char *ptr, struct sysinfo_t *info)
@@ -146,7 +140,7 @@ static void cb_parse_cbmem_cons(unsigned char *ptr, struct sysinfo_t *info)
static void cb_parse_acpi_gnvs(unsigned char *ptr, struct sysinfo_t *info)
{
- info->acpi_gnvs = get_cbmem_ptr(ptr);
+ info->acpi_gnvs = get_cbmem_addr(ptr);
}
static void cb_parse_board_id(unsigned char *ptr, struct sysinfo_t *info)
@@ -197,7 +191,7 @@ static void cb_parse_string(unsigned char *ptr, char **info)
static void cb_parse_wifi_calibration(void *ptr, struct sysinfo_t *info)
{
- info->wifi_calibration = get_cbmem_ptr(ptr);
+ info->wifi_calibration = get_cbmem_addr(ptr);
}
static void cb_parse_ramoops(void *ptr, struct sysinfo_t *info)
@@ -238,12 +232,12 @@ static void cb_parse_boot_media_params(unsigned char *ptr,
static void cb_parse_vpd(void *ptr, struct sysinfo_t *info)
{
- info->chromeos_vpd = get_cbmem_ptr(ptr);
+ info->chromeos_vpd = get_cbmem_addr(ptr);
}
static void cb_parse_fmap_cache(void *ptr, struct sysinfo_t *info)
{
- info->fmap_cache = get_cbmem_ptr(ptr);
+ info->fmap_cache = get_cbmem_addr(ptr);
}
#if CONFIG(LP_TIMER_RDTSC)