From 934a8b734c89102ad02c39811aad55d22c66cc9e Mon Sep 17 00:00:00 2001 From: Kit Rhett Aultman Date: Mon, 2 Sep 2024 13:44:02 -0400 Subject: [PATCH] main.rs: enable floating point The trap frame already handles the floating point registers, but floating point support was not enabled via the mstatus register. This didn't cause an issue on the Ubuntu 22.04 standard version of qemu, but one built from nightly source will issue an illegal instruction exception if floating point registers are accessed without the support being enabled. This commit fixes the issue by enabling floating point support from early initialization. --- src/main.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main.rs b/src/main.rs index d25754e..76f3110 100644 --- a/src/main.rs +++ b/src/main.rs @@ -104,6 +104,9 @@ extern "C" fn entry() -> ! { // we can't use keywords other than const and sym unsafe { asm!( + // Turn on floating point support + "li t0, 1 << 13", + "csrw mstatus, t0", // Establish the stack frame reference in mscratch "csrw mscratch, {trap_frame}", "lla t2, m_trap_vector", -- 2.34.1