pussuw commented on code in PR #9103:
URL: https://github.com/apache/nuttx/pull/9103#discussion_r1215247730


##########
arch/risc-v/src/common/riscv_macros.S:
##########
@@ -227,8 +222,15 @@
   REGLOAD      t0, REG_INT_CTX(\out)
   li           t1, MSTATUS_FS
   and          t2, t0, t1
-  li           t1, MSTATUS_FS_INIT
-  ble          t2, t1, 1f
+  li           t1, MSTATUS_FS_DIRTY
+  bne          t2, t1, 1f
+
+  /* Reset FS bit to MSTATUS_FS_CLEAN */
+  li           t1, MSTATUS_FS_CLEAN

Review Comment:
   Yes, I will provide patches for that.
   
   Lazy FPU save/restore works in flat and protected mode but in kernel mode 
there is a problem. The user context is saved in user stack but there are 
corner cases where a different address environment is in use which cause a 
crash. binfmt_execmodule() is a good example, during that if a context switch 
occurs de-referencing tcb->xcp.regs will result in a crash due to reading from 
the wrong address environment. This will be fixed by moving the context save 
into the process's own kernel stack, I am working on this right now.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to