diff options
author | Nico Huber <nico.h@gmx.de> | 2022-02-22 02:06:51 +0100 |
---|---|---|
committer | Nico Huber <nico.h@gmx.de> | 2022-02-23 22:47:09 +0000 |
commit | 4fa9f2ae8bfe9260afa5f8e1880f430e551ff7c0 (patch) | |
tree | f4340a3de871ca5b601da20117eafbb4bd8dacc6 | |
parent | 22372f4ac90780407533ebefc25d1740fc72ce7c (diff) |
libpayload/x86: Fix boot_device_read() and hook it up
Casts from integer to pointer are usually a case for phys_to_virt().
Change-Id: I861d435ff2361cdc26a2abd46d43b9346fa67ccc
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/62246
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
-rw-r--r-- | payloads/libpayload/arch/x86/Makefile.inc | 1 | ||||
-rw-r--r-- | payloads/libpayload/arch/x86/boot_media.c | 3 |
2 files changed, 3 insertions, 1 deletions
diff --git a/payloads/libpayload/arch/x86/Makefile.inc b/payloads/libpayload/arch/x86/Makefile.inc index 41228f2e12..e010329eba 100644 --- a/payloads/libpayload/arch/x86/Makefile.inc +++ b/payloads/libpayload/arch/x86/Makefile.inc @@ -42,6 +42,7 @@ libc-$(CONFIG_LP_GPL) += string.c libgdb-y += gdb.c libcbfs-$(CONFIG_LP_CBFS) += rom_media.c +libcbfs-$(CONFIG_LP_CBFS) += boot_media.c # Multiboot support is configurable libc-$(CONFIG_LP_MULTIBOOT) += multiboot.c diff --git a/payloads/libpayload/arch/x86/boot_media.c b/payloads/libpayload/arch/x86/boot_media.c index ce0283273d..99fb4e3c2a 100644 --- a/payloads/libpayload/arch/x86/boot_media.c +++ b/payloads/libpayload/arch/x86/boot_media.c @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: BSD-3-Clause */ +#include <arch/virtual.h> #include <boot_device.h> #include <commonlib/bsd/cb_err.h> #include <stddef.h> @@ -11,7 +12,7 @@ __attribute__((weak)) ssize_t boot_device_read(void *buf, size_t offset, size_t /* Memory-mapping usually only works for the top 16MB. */ if (!lib_sysinfo.boot_media_size || lib_sysinfo.boot_media_size - offset > 16 * MiB) return CB_ERR_ARG; - void *ptr = (void *)(uintptr_t)(0 - lib_sysinfo.boot_media_size + offset); + const void *const ptr = phys_to_virt(0 - lib_sysinfo.boot_media_size + offset); memcpy(buf, ptr, size); return size; } |