Skip to contentSkip to conversation

lib: sbi: Don't check SBI error range for legacy console getchar

PATCH New Anup Patel 2 participants 2 messages Apr 17, 2023 – Apr 20, 2023

lore
Share & tools
lore

Anup Patel

author
#0 lore raw

PATCH 1/1 lib: sbi: Don't check SBI error range for legacy console getchar

The legacy console getchar SBI call returns character value in the sbiret.error field so the "SBI_SUCCESS < ret" check in sbi_ecall_handler() results in unwanted error prints for the legacy console getchar SBI call. Let's suppress these unwanted error prints.

Fixes 67b2a408924b ("lib: sbi: sbi_ecall: Check the range of

SBI error")

---
 lib/sbi/sbi_ecall.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/sbi/sbi_ecall.c +3 -1
index d0f0166..76a1ae9 100644
@@ -120,7 +120,9 @@ int sbi_ecall_handler(struct sbi_trap_regs *regs)
 		trap.epc = regs->mepc;
 		sbi_trap_redirect(regs, &trap);
 	} else {
-		if (ret < SBI_LAST_ERR || SBI_SUCCESS < ret) {
+		if (ret < SBI_LAST_ERR ||
+		    (extension_id != SBI_EXT_0_1_CONSOLE_GETCHAR &&
+		     SBI_SUCCESS < ret)) {
 			sbi_printf("%s: Invalid error %d for ext=0x%lx "
 				   "func=0x%lx\n", __func__, ret,
 				   extension_id, func_id);
Signature · 1 line
2.34.1
Applied
#1 lore raw

PATCH 1/1 lib: sbi: Don't check SBI error range for legacy console getchar

Quoted 10 lines · On Mon, Apr 17, 2023 at 11:27?AM Anup Patel <[email protected]> wrote:

The legacy console getchar SBI call returns character value in the sbiret.error field so the "SBI_SUCCESS < ret" check in sbi_ecall_handler() results in unwanted error prints for the legacy console getchar SBI call. Let's suppress these unwanted error prints.

Fixes 67b2a408924b ("lib: sbi: sbi_ecall: Check the range of

SBI error")

Applied this patch to the riscv/opensbi repo.

Regards,
Anup

Quoted 22 lines
---
 lib/sbi/sbi_ecall.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/sbi/sbi_ecall.c +3 -2
index d0f0166..76a1ae9 100644
@@ -120,7 +120,9 @@ int sbi_ecall_handler(struct sbi_trap_regs *regs)
                trap.epc = regs->mepc;
                sbi_trap_redirect(regs, &trap);
        } else {
-               if (ret < SBI_LAST_ERR || SBI_SUCCESS < ret) {
+               if (ret < SBI_LAST_ERR ||
+                   (extension_id != SBI_EXT_0_1_CONSOLE_GETCHAR &&
+                    SBI_SUCCESS < ret)) {
                        sbi_printf("%s: Invalid error %d for ext=0x%lx "
                                   "func=0x%lx\n", __func__, ret,
                                   extension_id, func_id);
--

2.34.1