From d8608e615fae150ddb54e9b54d0e1fb5f16a9d9c Mon Sep 17 00:00:00 2001 From: Samuel Holland Date: Mon, 1 Jul 2024 07:54:58 -0700 Subject: [PATCH] lib: sbi_emulate_csr: Do not log illegal CSR accesses Illegal CSR accesses from lower privilege modes are delegated to S-mode and do not necessarily indicate a bug. Supervisor software may want to emulate some CSRs, or may intentionally disable access to certain existing CSRs, and thus will expect traps when those CSRs are accessed. For example, Linux disables sstatus.VS by default in order to detect when userspace first accesses vector register state; this includes the CSRs defined by the V extesion. As a result, if the first vector instruction in a process is a CSR access, OpenSBI will log the illegal instruction exception, even though there is no unexpected or erroneous behavior occurring. Since the illegal instruction exception is delegated to S-mode, S-mode software should be responsible for reporting the exception, not OpenSBI. Signed-off-by: Samuel Holland Reviewed-by: Anup Patel --- lib/sbi/sbi_emulate_csr.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/lib/sbi/sbi_emulate_csr.c b/lib/sbi/sbi_emulate_csr.c index 5f3b111d..869c81f4 100644 --- a/lib/sbi/sbi_emulate_csr.c +++ b/lib/sbi/sbi_emulate_csr.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -151,10 +150,6 @@ int sbi_emulate_csr_read(int csr_num, struct sbi_trap_regs *regs, break; } - if (ret) - sbi_dprintf("%s: hartid%d: invalid csr_num=0x%x\n", - __func__, current_hartid(), csr_num); - return ret; } @@ -189,9 +184,5 @@ int sbi_emulate_csr_write(int csr_num, struct sbi_trap_regs *regs, break; } - if (ret) - sbi_dprintf("%s: hartid%d: invalid csr_num=0x%x\n", - __func__, current_hartid(), csr_num); - return ret; }