pussuw commented on pull request #5782:
URL: https://github.com/apache/incubator-nuttx/pull/5782#issuecomment-1076206289


   > > I think @pussuw has addressed all the comments so far. This looks good 
to me, can you @xiaoxiang781216 re-check?
   > 
   > Yes, I will take a look again. But since the change is huge, I need find 
the enough free time to finish the review. So, I expect the review will finish 
in the end of week.
   > 
   
   Yes, apologies for the size of the patch, I perfectly understand that 
reviewing large patches is not preferred (I prefer smaller patches also). In 
this case I could not figure out a good way to split it into smaller 
components, the changes are pretty strongly dependent on each other.
   
   > The major concern is how to implement the syscall. From "3.3.1 Environment 
Call and Breakpoint“ at 
https://github.com/riscv/riscv-isa-manual/releases/tag/draft-20220318-c9a172f:
   > 
   > ```
   > The ECALL instruction is used to make a request to the supporting 
execution environment.
   > When executed in U-mode, S-mode, or M-mode, it generates an 
environment-call-from-U-mode
   > exception, environment-call-from-S-mode exception, or 
environment-call-from-M-mode exception,
   > respectively, and performs no other operation.
   > ECALL generates a different exception for each originating privilege mode 
so that environment
   > call exceptions can be selectively delegated. A typical use case for 
Unix-like operating systems is
   > to delegate to S-mode the environment-call-from-U-mode exception but not 
the others.
   > ```
   > 
   > S-mode can hook ECALL to self, @pussuw could you explain more why we need 
handle differently in S-mode and M-mode?
   
   S-mode can trap ecall from user mode (U-mode) but not from S-mode. So ecall 
from S-mode to S-mode is not possible. Also, we want to use ecall in S-mode to 
raise privileges to M-mode, to access some machine mode services (mhartid, 
mtimer to name a few, see riscv_mcall.c).
   
   The reason the current syscall implementation works with M-mode, is that 
M-mode is the highest privilege level, so ecall from M-mode will enter M-mode 
again. This mechanism unfortunately cannot be used when the kernel is in S-mode 
-> we need what is implemented in this patch.


-- 
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: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to