aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Holland <samuel.holland@sifive.com>2024-07-01 07:54:58 -0700
committerAnup Patel <anup@brainfault.org>2024-07-04 10:42:16 +0530
commitd8608e615fae150ddb54e9b54d0e1fb5f16a9d9c (patch)
tree13b0bdda4a94363ad56c448f02dc8193c896b216
parentc531adbf08cf9cd4cad0bc0c1fbf6e8333955e44 (diff)
downloadopensbi-d8608e615fae150ddb54e9b54d0e1fb5f16a9d9c.zip
opensbi-d8608e615fae150ddb54e9b54d0e1fb5f16a9d9c.tar.gz
opensbi-d8608e615fae150ddb54e9b54d0e1fb5f16a9d9c.tar.bz2
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 <samuel.holland@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
-rw-r--r--lib/sbi/sbi_emulate_csr.c9
1 files changed, 0 insertions, 9 deletions
diff --git a/lib/sbi/sbi_emulate_csr.c b/lib/sbi/sbi_emulate_csr.c
index 5f3b111..869c81f 100644
--- a/lib/sbi/sbi_emulate_csr.c
+++ b/lib/sbi/sbi_emulate_csr.c
@@ -10,7 +10,6 @@
#include <sbi/riscv_asm.h>
#include <sbi/riscv_encoding.h>
#include <sbi/sbi_bitops.h>
-#include <sbi/sbi_console.h>
#include <sbi/sbi_emulate_csr.h>
#include <sbi/sbi_error.h>
#include <sbi/sbi_hart.h>
@@ -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;
}