From: Thomas Huth Date: Mon, 4 Nov 2024 16:35:04 +0000 (+0100) Subject: hw/char/sifive_uart: Fix broken UART on big endian hosts X-Git-Tag: v9.2.0-rc0~8^2~11 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b069018e2fe1fc613f5eeecc810050210e845528;p=thirdparty%2Fqemu.git hw/char/sifive_uart: Fix broken UART on big endian hosts Casting a "uint32_t *" to a "uint8_t *" to get to the lowest 8-bit part of the value does not work on big endian hosts. We've got to take the proper detour through an 8-bit variable. Fixes: 53c1557b23 ("hw/char: sifive_uart: Print uart characters async") Signed-off-by: Thomas Huth Reviewed-by: Alistair Francis Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20241104163504.305955-1-thuth@redhat.com> Signed-off-by: Alistair Francis --- diff --git a/hw/char/sifive_uart.c b/hw/char/sifive_uart.c index aeb45d36018..5ae2a29ed68 100644 --- a/hw/char/sifive_uart.c +++ b/hw/char/sifive_uart.c @@ -174,10 +174,11 @@ sifive_uart_write(void *opaque, hwaddr addr, { SiFiveUARTState *s = opaque; uint32_t value = val64; + uint8_t ch = value; switch (addr) { case SIFIVE_UART_TXFIFO: - sifive_uart_write_tx_fifo(s, (uint8_t *) &value, 1); + sifive_uart_write_tx_fifo(s, &ch, 1); return; case SIFIVE_UART_IE: s->ie = val64;