[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-8.0.5 58/66] hw/char/riscv_htif: Fix printing of console charact
From: |
Michael Tokarev |
Subject: |
[Stable-8.0.5 58/66] hw/char/riscv_htif: Fix printing of console characters on big endian hosts |
Date: |
Wed, 13 Sep 2023 16:17:39 +0300 |
From: Thomas Huth <thuth@redhat.com>
The character that should be printed is stored in the 64 bit "payload"
variable. The code currently tries to print it by taking the address
of the variable and passing this pointer to qemu_chr_fe_write(). However,
this only works on little endian hosts where the least significant bits
are stored on the lowest address. To do this in a portable way, we have
to store the value in an uint8_t variable instead.
Fixes: 5033606780 ("RISC-V HTIF Console")
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Bin Meng <bmeng@tinylab.org>
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20230721094720.902454-2-thuth@redhat.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
(cherry picked from commit c255946e3df4d9660e4f468a456633c24393d468)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/char/riscv_htif.c b/hw/char/riscv_htif.c
index 098de50e35..e6e0fa3015 100644
--- a/hw/char/riscv_htif.c
+++ b/hw/char/riscv_htif.c
@@ -190,7 +190,8 @@ static void htif_handle_tohost_write(HTIFState *s, uint64_t
val_written)
s->tohost = 0; /* clear to indicate we read */
return;
} else if (cmd == HTIF_CONSOLE_CMD_PUTC) {
- qemu_chr_fe_write(&s->chr, (uint8_t *)&payload, 1);
+ uint8_t ch = (uint8_t)payload;
+ qemu_chr_fe_write(&s->chr, &ch, 1);
resp = 0x100 | (uint8_t)payload;
} else {
qemu_log("HTIF device %d: unknown command\n", device);
--
2.39.2
- [Stable-8.0.5 05/66] hw: replace most qemu_bh_new calls with qemu_bh_new_guarded, (continued)
- [Stable-8.0.5 05/66] hw: replace most qemu_bh_new calls with qemu_bh_new_guarded, Michael Tokarev, 2023/09/13
- [Stable-8.0.5 06/66] lsi53c895a: disable reentrancy detection for script RAM, Michael Tokarev, 2023/09/13
- [Stable-8.0.5 07/66] lsi53c895a: disable reentrancy detection for MMIO region, too, Michael Tokarev, 2023/09/13
- [Stable-8.0.5 08/66] bcm2835_property: disable reentrancy detection for iomem, Michael Tokarev, 2023/09/13
- [Stable-8.0.5 10/66] apic: disable reentrancy detection for apic-msi, Michael Tokarev, 2023/09/13
- [Stable-8.0.5 09/66] raven: disable reentrancy detection for iomem, Michael Tokarev, 2023/09/13
- [Stable-8.0.5 11/66] loongarch: mark loongarch_ipi_iocsr re-entrnacy safe, Michael Tokarev, 2023/09/13
- [Stable-8.0.5 12/66] pnv_lpc: disable reentrancy detection for lpc-hc, Michael Tokarev, 2023/09/13
- [Stable-8.0.5 57/66] arm64: Restore trapless ptimer access, Michael Tokarev, 2023/09/13
- [Stable-8.0.5 56/66] virtio: Drop out of coroutine context in virtio_load(), Michael Tokarev, 2023/09/13
- [Stable-8.0.5 58/66] hw/char/riscv_htif: Fix printing of console characters on big endian hosts,
Michael Tokarev <=
- [Stable-8.0.5 59/66] hw/char/riscv_htif: Fix the console syscall on big endian hosts, Michael Tokarev, 2023/09/13
- [Stable-8.0.5 60/66] hw/intc: Fix upper/lower mtime write calculation, Michael Tokarev, 2023/09/13
- [Stable-8.0.5 61/66] hw/intc: Make rtc variable names consistent, Michael Tokarev, 2023/09/13
- [Stable-8.0.5 63/66] hw/riscv: virt: Fix riscv,pmu DT node path, Michael Tokarev, 2023/09/13
- [Stable-8.0.5 62/66] linux-user/riscv: Use abi type for target_ucontext, Michael Tokarev, 2023/09/13
- [Stable-8.0.5 64/66] target/riscv: fix satp_mode_finalize() when satp_mode.supported = 0, Michael Tokarev, 2023/09/13
- [Stable-8.0.5 65/66] target/riscv/pmp.c: respect mseccfg.RLB for pmpaddrX changes, Michael Tokarev, 2023/09/13
- [Stable-8.0.5 66/66] hw/tpm: TIS on sysbus: Remove unsupport ppi command line option, Michael Tokarev, 2023/09/13
- Re: [Stable-8.0.5 00/66] v2 Patch Round-up for stable 8.0.5, freeze on 2023-09-19, Kevin Wolf, 2023/09/13