You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/03/23 12:05:35 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 edited a comment on pull request #5782: RISC-V: Implement option to run NuttX in supervisor mode (S-mode)

xiaoxiang781216 edited a comment on pull request #5782:
URL: https://github.com/apache/incubator-nuttx/pull/5782#issuecomment-1076299011


   > > 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.
   
   Ok, I get the key point. So is syscall from S-mode to S-mode only used for kernel thread context switch?
   
   > Also, we want to use ecall in S-mode to raise privileges to M-mode, to access some machine mode services (mhartid,
   
   Yes, but it's still the same ecall instruction. Here is my understanding:
   
   1. Any syscall(include context switch) issued by U-mode could be implemented by ECALL and raise to S-mode
   2. Kernel thread context switch could be implemented by ECALL too, but it will be handled in M-mode instead S-mode
   3. Some special function(e.g. mhartid) which need the highest privilege has to issue ECALL from S-mode to M-mode
   
   So, I think we can still use the same sys_call0-syscall6 as before, and:
   
   1. Handle U-mode syscall in S-mode as before
   2. Handle S-mode context switch in M-mode( the code should be same as S-mode)
   3. Extend the reserved syscall id to cover the special need(e.g. mhardid)
   
   > mtimer to name a few, see riscv_mcall.c).
   
   Why we can't use S-mode timer instead?
   


-- 
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-unsubscribe@nuttx.apache.org

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