diff options
author | Nico Huber <nico.h@gmx.de> | 2020-07-18 14:54:47 +0200 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2020-08-24 09:13:09 +0000 |
commit | be842cb72d83b347bbc1c3308909f4eac286b47a (patch) | |
tree | e682a6fad4ad45d5764815b2f4754513be0c2c0d /payloads/libpayload | |
parent | b2eafa666cb7f5318daa61962bae62859f4e4e88 (diff) | |
download | coreboot-be842cb72d83b347bbc1c3308909f4eac286b47a.tar.xz |
libpayload: Cache physical location of serial-console struct
In the presence of self-relocating payloads, it's safer to keep
physical addresses in `libsysinfo`.
Change-Id: Icd30e95c6b8115d16dd793914fb01a1a9da1854f
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/43577
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/libpayload')
-rw-r--r-- | payloads/libpayload/drivers/serial/8250.c | 4 | ||||
-rw-r--r-- | payloads/libpayload/drivers/serial/ipq40xx.c | 4 | ||||
-rw-r--r-- | payloads/libpayload/drivers/serial/ipq806x.c | 4 | ||||
-rw-r--r-- | payloads/libpayload/drivers/serial/qcom_qupv3_serial.c | 5 | ||||
-rw-r--r-- | payloads/libpayload/drivers/serial/qcs405.c | 4 | ||||
-rw-r--r-- | payloads/libpayload/drivers/serial/s5p.c | 6 | ||||
-rw-r--r-- | payloads/libpayload/include/sysinfo.h | 4 | ||||
-rw-r--r-- | payloads/libpayload/libc/coreboot.c | 2 |
8 files changed, 16 insertions, 17 deletions
diff --git a/payloads/libpayload/drivers/serial/8250.c b/payloads/libpayload/drivers/serial/8250.c index b0e9d03c20..1df34c41ea 100644 --- a/payloads/libpayload/drivers/serial/8250.c +++ b/payloads/libpayload/drivers/serial/8250.c @@ -132,9 +132,9 @@ void serial_init(void) void serial_console_init(void) { - if (!lib_sysinfo.serial) + if (!lib_sysinfo.cb_serial) return; - cb_serial = *lib_sysinfo.serial; + cb_serial = *(struct cb_serial *)phys_to_virt(lib_sysinfo.cb_serial); serial_init(); diff --git a/payloads/libpayload/drivers/serial/ipq40xx.c b/payloads/libpayload/drivers/serial/ipq40xx.c index 5a9079b46b..bc5ebbbc1b 100644 --- a/payloads/libpayload/drivers/serial/ipq40xx.c +++ b/payloads/libpayload/drivers/serial/ipq40xx.c @@ -553,9 +553,7 @@ static struct console_output_driver consout = {}; /* For simplicity's sake, let's rely on coreboot initializing the UART. */ void serial_console_init(void) { - struct cb_serial *sc_ptr = lib_sysinfo.serial; - - if (!sc_ptr) + if (!lib_sysinfo.cb_serial) return; consin.havekey = serial_havechar; diff --git a/payloads/libpayload/drivers/serial/ipq806x.c b/payloads/libpayload/drivers/serial/ipq806x.c index ef4ce80849..93e2129185 100644 --- a/payloads/libpayload/drivers/serial/ipq806x.c +++ b/payloads/libpayload/drivers/serial/ipq806x.c @@ -343,9 +343,9 @@ int serial_getchar(void) /* For simplicity's sake, let's rely on coreboot initializing the UART. */ void serial_console_init(void) { - struct cb_serial *sc_ptr = lib_sysinfo.serial; + struct cb_serial *sc_ptr = phys_to_virt(lib_sysinfo.cb_serial); - if (!sc_ptr) + if (!lib_sysinfo.cb_serial) return; base_uart_addr = (void *) sc_ptr->baseaddr; diff --git a/payloads/libpayload/drivers/serial/qcom_qupv3_serial.c b/payloads/libpayload/drivers/serial/qcom_qupv3_serial.c index 3d0e6de335..321ff46b42 100644 --- a/payloads/libpayload/drivers/serial/qcom_qupv3_serial.c +++ b/payloads/libpayload/drivers/serial/qcom_qupv3_serial.c @@ -275,7 +275,8 @@ static struct console_output_driver consout = { static struct qup_regs *uart_base_address(void) { - return (void *)(uintptr_t)lib_sysinfo.serial->baseaddr; + const struct cb_serial *const serial = phys_to_virt(lib_sysinfo.cb_serial); + return phys_to_virt(serial->baseaddr); } static void uart_qupv3_tx_flush(void) @@ -332,7 +333,7 @@ int serial_getchar(void) void serial_console_init(void) { - if (!lib_sysinfo.serial) + if (!lib_sysinfo.cb_serial) return; console_add_output_driver(&consout); diff --git a/payloads/libpayload/drivers/serial/qcs405.c b/payloads/libpayload/drivers/serial/qcs405.c index 1a7b9e901b..2ed6af1749 100644 --- a/payloads/libpayload/drivers/serial/qcs405.c +++ b/payloads/libpayload/drivers/serial/qcs405.c @@ -541,9 +541,9 @@ int serial_getchar(void) /* For simplicity's sake, let's rely on coreboot initializing the UART. */ void serial_console_init(void) { - struct cb_serial *sc_ptr = lib_sysinfo.serial; + struct cb_serial *sc_ptr = phys_to_virt(lib_sysinfo.cb_serial); - if (!sc_ptr) + if (!lib_sysinfo.cb_serial) return; uart_board_param.uart_dm_base = (void *)(uintptr_t)sc_ptr->baseaddr; diff --git a/payloads/libpayload/drivers/serial/s5p.c b/payloads/libpayload/drivers/serial/s5p.c index 6ca5dc4717..7a6f0e1c39 100644 --- a/payloads/libpayload/drivers/serial/s5p.c +++ b/payloads/libpayload/drivers/serial/s5p.c @@ -90,10 +90,12 @@ static struct console_input_driver s5p_serial_input = void serial_init(void) { - if (!lib_sysinfo.serial || !lib_sysinfo.serial->baseaddr) + const struct cb_serial *const serial = phys_to_virt(lib_sysinfo.cb_serial); + + if (!lib_sysinfo.cb_serial || !serial->baseaddr) return; - uart_regs = (struct s5p_uart *)lib_sysinfo.serial->baseaddr; + uart_regs = (struct s5p_uart *)serial->baseaddr; } void serial_console_init(void) diff --git a/payloads/libpayload/include/sysinfo.h b/payloads/libpayload/include/sysinfo.h index c3d8c7fd53..188b2c3ecf 100644 --- a/payloads/libpayload/include/sysinfo.h +++ b/payloads/libpayload/include/sysinfo.h @@ -41,8 +41,6 @@ #include <coreboot_tables.h> -struct cb_serial; - /* * All pointers in here shall be virtual. * @@ -51,7 +49,7 @@ struct cb_serial; */ struct sysinfo_t { unsigned int cpu_khz; - struct cb_serial *serial; + uintptr_t cb_serial; unsigned short ser_ioport; unsigned long ser_base; // for mmapped serial diff --git a/payloads/libpayload/libc/coreboot.c b/payloads/libpayload/libc/coreboot.c index cb47a8317b..5ecdd51fab 100644 --- a/payloads/libpayload/libc/coreboot.c +++ b/payloads/libpayload/libc/coreboot.c @@ -86,7 +86,7 @@ static void cb_parse_memory(void *ptr, struct sysinfo_t *info) static void cb_parse_serial(void *ptr, struct sysinfo_t *info) { - info->serial = ((struct cb_serial *)ptr); + info->cb_serial = virt_to_phys(ptr); } static void cb_parse_vboot_workbuf(unsigned char *ptr, struct sysinfo_t *info) |