[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-7.2.6 54/63] hw/char/riscv_htif: Fix printing of console charact
From: |
Michael Tokarev |
Subject: |
[Stable-7.2.6 54/63] hw/char/riscv_htif: Fix printing of console characters on big endian hosts |
Date: |
Wed, 20 Sep 2023 15:15: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>
(Mjt: edit to compensate for v7.2.0-805-g753ae97abc and v7.2.0-808-gdadee9e3ce)
diff --git a/hw/char/riscv_htif.c b/hw/char/riscv_htif.c
index 6577f0e640..c76d333cfc 100644
--- a/hw/char/riscv_htif.c
+++ b/hw/char/riscv_htif.c
@@ -146,7 +146,8 @@ static void htif_handle_tohost_write(HTIFState *htifstate,
uint64_t val_written)
htifstate->env->mtohost = 0; /* clear to indicate we read */
return;
} else if (cmd == 0x1) {
- qemu_chr_fe_write(&htifstate->chr, (uint8_t *)&payload, 1);
+ uint8_t ch = (uint8_t)payload;
+ qemu_chr_fe_write(&htifstate->chr, &ch, 1);
resp = 0x100 | (uint8_t)payload;
} else {
qemu_log("HTIF device %d: unknown command\n", device);
--
2.39.2
- [Stable-7.2.6 00/63] v3 Patch Round-up for stable 7.2.6, freeze on 2023-09-19, Michael Tokarev, 2023/09/20
- [Stable-7.2.6 52/63] virtio: Drop out of coroutine context in virtio_load(), Michael Tokarev, 2023/09/20
- [Stable-7.2.6 54/63] hw/char/riscv_htif: Fix printing of console characters on big endian hosts,
Michael Tokarev <=
- [Stable-7.2.6 53/63] arm64: Restore trapless ptimer access, Michael Tokarev, 2023/09/20
- [Stable-7.2.6 55/63] hw/intc: Fix upper/lower mtime write calculation, Michael Tokarev, 2023/09/20
- [Stable-7.2.6 56/63] hw/intc: Make rtc variable names consistent, Michael Tokarev, 2023/09/20
- [Stable-7.2.6 57/63] linux-user/riscv: Use abi type for target_ucontext, Michael Tokarev, 2023/09/20
- [Stable-7.2.6 60/63] hw/tpm: TIS on sysbus: Remove unsupport ppi command line option, Michael Tokarev, 2023/09/20
- [Stable-7.2.6 58/63] hw/riscv: virt: Fix riscv,pmu DT node path, Michael Tokarev, 2023/09/20
- [Stable-7.2.6 59/63] target/riscv/pmp.c: respect mseccfg.RLB for pmpaddrX changes, Michael Tokarev, 2023/09/20
- [Stable-7.2.6 62/63] s390x/ap: fix missing subsystem reset registration, Michael Tokarev, 2023/09/20
- [Stable-7.2.6 61/63] ui: fix crash when there are no active_console, Michael Tokarev, 2023/09/20
- [Stable-7.2.6 63/63] tpm: fix crash when FD >= 1024 and unnecessary errors due to EINTR, Michael Tokarev, 2023/09/20