Skip to contentSkip to conversation

riscv: qemu_chr_fe_write_all() in CONSOLE_WRITE_BYTE

PATCH Applied Daniel Henrique Barboza 2 participants 3 messages Jun 5, 2025 – Jun 9, 2025 RISC-V

lore
Share & tools
lore
#0 lore raw

v2 cover riscv: qemu_chr_fe_write_all() in CONSOLE_WRITE_BYTE

Hi,

In this version I removed the reference of SBI_EXT_DBCN_CONSOLE_WRITE in the commit message. That API is *non-blocking*, and citing it to justify a change in a blocking API sounds weird. It's also uneeded since we have a good case without it regardless.

No other changes made.

Changes from v1:
- removed the "SBI_EXT_DBCN_CONSOLE_WRITE" bit from the commit msg
- v1 link: https://lore.kernel.org/qemu-riscv/[email protected]/

Daniel Henrique Barboza (1):
target/riscv: use qemu_chr_fe_write_all() in DBCN_CONSOLE_WRITE_BYTE

 target/riscv/kvm/kvm-cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 1 line
2.49.0
#1 lore raw

PATCH v2 1/1 target/riscv: use qemu_chr_fe_write_all() in DBCN_CONSOLE_WRITE_BYTE

The SBI spec states, for console write byte:

"This is a blocking SBI call and it will only return after writing the specified byte to the debug console. It will also return, with SBI_ERR_FAILED, if there are I/O errors."

Being a blocker call will either succeed writing the byte or error out, it's feasible to use the blocking qemu_chr_fe_write_all() instead of qemu_chr_fe_write().

Last but not the least, we will duck possible changes in qemu_chr_fe_write() where ret = 0 will have a 'zero byte written' semantic [1] - something that we're not ready to deal in this current state.

[1] https://lore.kernel.org/qemu-devel/CAFEAcA_kEndvNtw4EHySXWwQPoGs029yAzZGGBcV=zGHaj7KUQ@mail.gmail.com/

---
 target/riscv/kvm/kvm-cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/riscv/kvm/kvm-cpu.c +1 -1
index e1a04be20f..86724e5c44 100644
@@ -1605,7 +1605,7 @@ static void kvm_riscv_handle_sbi_dbcn(CPUState *cs, struct kvm_run *run)
         break;
     case SBI_EXT_DBCN_CONSOLE_WRITE_BYTE:
         ch = run->riscv_sbi.args[0];
-        ret = qemu_chr_fe_write(serial_hd(0)->be, &ch, sizeof(ch));
+        ret = qemu_chr_fe_write_all(serial_hd(0)->be, &ch, sizeof(ch));
 
         if (ret < 0) {
             error_report("SBI_EXT_DBCN_CONSOLE_WRITE_BYTE: error when "
Signature · 1 line
2.49.0
#2 lore raw
In reply to Daniel Henrique Barboza
Quoted 8 lines · Daniel Henrique Barboza

Hi,

In this version I removed the reference of SBI_EXT_DBCN_CONSOLE_WRITE in the commit message. That API is *non-blocking*, and citing it to justify a change in a blocking API sounds weird. It's also uneeded since we have a good case without it regardless.

Quoted 8 lines

No other changes made.

Changes from v1:
- removed the "SBI_EXT_DBCN_CONSOLE_WRITE" bit from the commit msg
- v1 link: https://lore.kernel.org/qemu-riscv/[email protected]/

Daniel Henrique Barboza (1):
target/riscv: use qemu_chr_fe_write_all() in DBCN_CONSOLE_WRITE_BYTE

Thanks!

Applied to riscv-to-apply.next

Alistair

Quoted 8 lines
 target/riscv/kvm/kvm-cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--
2.49.0