target/riscv/kvm: use qemu_chr_fe_write_all() in SBI_EXT_DBCN_CONSOLE_WRITE_BYTE
PATCH 1/1 target/riscv/kvm: use qemu_chr_fe_write_all() in SBI_EXT_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(). This is also how SBI_EXT_DBCN_CONSOLE_WRITE is implemented, so we're also being more consistent.
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
@@ -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
Quoted 16 lines · Daniel Henrique Barboza
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 ofqemu_chr_fe_write(). This is also howSBI_EXT_DBCN_CONSOLE_WRITEis implemented, so we're also being more consistent.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.
Quoted 6 lines
[1] https://lore.kernel.org/qemu-devel/ CAFEAcA_kEndvNtw4EHySXWwQPoGs029yAzZGGBcV=zGHaj7KUQ@mail.gmail.com/
Signed-off-by Daniel Henrique Barboza <[email protected]>--- target/riscv/kvm/kvm-cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Thank you very much Daniel!
Quoted 17 lines · Philippe Mathieu-Daudé
Quoted 16 lines · Daniel Henrique Barboza
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 ofqemu_chr_fe_write(). This is also howSBI_EXT_DBCN_CONSOLE_WRITEis implemented, so we're also being more consistent.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.
Quoted 8 lines
Quoted 6 lines
[1] https://lore.kernel.org/qemu-devel/ CAFEAcA_kEndvNtw4EHySXWwQPoGs029yAzZGGBcV=zGHaj7KUQ@mail.gmail.com/
Signed-off-by Daniel Henrique Barboza <[email protected]>---
target/riscv/kvm/kvm-cpu.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)Thank you very much Daniel!
No problem :)
FYI I just sent a v2 with a small change in the commit msg. Your ack was kept. Thanks,
Daniel
Quoted 3 lines
Reviewed-by Philippe Mathieu-Daudé <[email protected]>