qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] target/riscv: enable floating point unit
@ 2024-09-16 18:16 Heinrich Schuchardt
  2024-09-17 12:13 ` Andrew Jones
  2024-09-18 14:38 ` Richard Henderson
  0 siblings, 2 replies; 16+ messages in thread
From: Heinrich Schuchardt @ 2024-09-16 18:16 UTC (permalink / raw)
  To: Palmer Dabbelt, Alistair Francis, Bin Meng
  Cc: Weiwei Li, Daniel Henrique Barboza, Liu Zhiwei, qemu-riscv,
	qemu-devel, Heinrich Schuchardt

OpenSBI enables the floating point in mstatus. For consistency QEMU/KVM
should do the same.

Without this patch EDK II with TLS enabled crashes when hitting the first
floating point instruction while running QEMU with --accel kvm and runs
fine with --accel tcg.

Additionally to this patch EDK II should be changed to make no assumptions
about the state of the floating point unit.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
 target/riscv/cpu.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index 4bda754b01..c32e2721d4 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -923,6 +923,13 @@ static void riscv_cpu_reset_hold(Object *obj, ResetType type)
     if (mcc->parent_phases.hold) {
         mcc->parent_phases.hold(obj, type);
     }
+    if (riscv_has_ext(env, RVF) || riscv_has_ext(env, RVD)) {
+        env->mstatus = set_field(env->mstatus, MSTATUS_FS, env->misa_mxl);
+        for (int regnr = 0; regnr < 32; ++regnr) {
+            env->fpr[regnr] = 0;
+        }
+        riscv_csrrw(env, CSR_FCSR, NULL, 0, -1);
+    }
 #ifndef CONFIG_USER_ONLY
     env->misa_mxl = mcc->misa_mxl_max;
     env->priv = PRV_M;
-- 
2.45.2



^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2024-10-08  0:47 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-16 18:16 [PATCH 1/1] target/riscv: enable floating point unit Heinrich Schuchardt
2024-09-17 12:13 ` Andrew Jones
2024-09-17 13:28   ` Heinrich Schuchardt
2024-09-17 14:49     ` Andrew Jones
2024-09-17 16:45       ` Heinrich Schuchardt
2024-09-18  6:05         ` Andrew Jones
2024-09-18 11:10           ` Peter Maydell
2024-09-18 13:06             ` Heinrich Schuchardt
2024-09-18 13:12               ` Peter Maydell
2024-09-18 13:49                 ` Heinrich Schuchardt
2024-09-18 13:56                   ` Andrew Jones
2024-09-18 15:49                     ` Heinrich Schuchardt
2024-09-18 15:32                   ` Peter Maydell
2024-09-18 16:27                     ` Heinrich Schuchardt
2024-10-08  0:45                     ` Alistair Francis
2024-09-18 14:38 ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).