You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "sdc-g (via GitHub)" <gi...@apache.org> on 2025/03/13 08:04:27 UTC

[PR] xtensa: set PS.EXCM initial value to 1 while new thread created [nuttx]

sdc-g opened a new pull request, #15985:
URL: https://github.com/apache/nuttx/pull/15985

   ## Summary
   
   To avoid level-1 interrupt break retrieve PC/A0/SP/A2 register, PS.EXCM set to 1 by CPU HW while handling exception/interrupt.
   
   But if context switching happens and new thread created, the thread initial value of PS.EXCM is used.
   
   Same behevior as ESP-IDF code:
   https://github.com/espressif/esp-idf/blob/master/
   components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c#L366
   
   ## Impact
   
   PS.EXCM initial value while new thread created.
   
   ## Testing
   
   tested by internal test case as below code
   
   ```
   static void *BusyThread(void *arg) {
     (void)arg;  // Avoid compiler warning
     while (1) {
     }
     return NULL;
   }
   
   //-----------------------------------------------------------------------------
   static void *DebugTestThread(void *arg) {
     printf("Test Thread\n");
     return NULL;
   }
   
   //-----------------------------------------------------------------------------
   static void *TimeSliceThread(void *arg) {
     printf("Start TimeSliceThread\n");
     while (1) {
       usleep(500 * 1000);
     }
     return NULL;
   }
   
   //-----------------------------------------------------------------------------
   int main(int argc, char *argv[]) {
   
     // Start priority=120 thread to induce Time Slice
     pthread_t thread;
     pthread_attr_t attr;
     struct sched_param param;
   
     pthread_attr_init(&attr);
     pthread_attr_getschedparam(&attr, &param);
     param.sched_priority = 120;
     pthread_attr_setschedparam(&attr, &param);
     pthread_create(&thread, &attr, TimeSliceThread, NULL);
   
     printf("\n\n******** Test Start ********\n");
   
     pthread_t busy_thread;
     pthread_create(&busy_thread, NULL, BusyThread, NULL);
   
     pthread_t test_thread;
     while(1) {
       pthread_create(&test_thread, NULL, DebugTestThread, NULL);
       pthread_join(test_thread, NULL);
     }
   }
   ```
   
   


-- 
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


Re: [PR] arch/xtensa: set PS.EXCM initial value to 1 while new thread created [nuttx]

Posted by "chirping78 (via GitHub)" <gi...@apache.org>.
chirping78 commented on PR #15985:
URL: https://github.com/apache/nuttx/pull/15985#issuecomment-2728509964

   @sdc-g I have some concerns about your this PR.
   
   Without your PR, in new task‘s  register save area, REG_PS's `EXCM` bit is clear.
   
   Before the new task is resumed , `exception_exit` will copy REG_PS from register save area to PS (for level1) or EPS[N] (for level2 and above).
   
   - if new task be resumed by level1: `rfe` sets PS.EXCM back to 0, and then jumps to the address in EPC[1].
   To prevent the resuming action be interrupted, REG_PS.EXCM is set to 1 [here](https://github.com/apache/nuttx/blob/master/arch/xtensa/src/common/xtensa_user_handler.S#L317) and [here](https://github.com/apache/nuttx/blob/master/arch/xtensa/src/common/xtensa_int_handlers.S#L224)
   
   - if new task be resumed by level2 and above: `rfi` will restores the PS from EPS[N] and jump to the address in EPC[N].
   
   ----------------------
   
   
   Now with your PR, in new task‘s  register save area, REG_PS's `EXCM` bit is set.
   
   - If new task be resumed by level1: `rfe` sets PS.EXCM back to 0, and then jumps to the address in EPC[1]. No problem here, it works as before.
   
   - If new task be resumed by level2 and above: `rfi` will restores the PS from EPS[N] and jump to the address in EPC[N]. ***Problem will be here***, after the new task be resumed, ***the PS.EXCM bit is still set***. If window rotation related instruction is executed, error will arise.


-- 
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


Re: [PR] arch/xtensa: set PS.EXCM initial value to 1 while new thread created [nuttx]

Posted by "sdc-g (via GitHub)" <gi...@apache.org>.
sdc-g commented on PR #15985:
URL: https://github.com/apache/nuttx/pull/15985#issuecomment-2732368852

   Hi @tmedicci 
   
   please wait a moment...


-- 
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


Re: [PR] arch/xtensa: set PS.EXCM initial value to 1 while new thread created [nuttx]

Posted by "chirping78 (via GitHub)" <gi...@apache.org>.
chirping78 commented on PR #15985:
URL: https://github.com/apache/nuttx/pull/15985#issuecomment-2735567042

   > Hi @chirping78
   > 
   > Sorry, one more discussion: while level-2 and above interrupt, PS.EXCM also set to 1.
   > 
   > So if context switching happens, there is also double exception if window ratation instruction is executed. The sequence like: threadA PS.EXCM is 0 -> PS.EXCM set to 1 while level-2 interrupt -> context switching to threadB -> level-2 interrupt and resume threadA with PS.EXCM=1, then double exception
   > 
   > 
   > Is it possible and correct understanding?
   
   the sequence is not clear. 
   Let's use this convention: `PS` means ***the CPU hardware***, while `REG_PS` is PS saved in ***the register saving area***.
   please rewrite the sequence using the convention (maybe when you rewrite, you'll make it out yourself)
   


-- 
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


Re: [PR] arch/xtensa: set PS.EXCM initial value to 1 while new thread created [nuttx]

Posted by "sdc-g (via GitHub)" <gi...@apache.org>.
sdc-g commented on PR #15985:
URL: https://github.com/apache/nuttx/pull/15985#issuecomment-2720311503

   @zhuyanlin111 
   Could you please also review the change since previous PR: https://github.com/apache/nuttx/commit/fbc1da98b7b500580a183771c938cce121056c65#diff-6ea32ef16de4dfd7e2971ae010a3c4c82b09751ab8acd8bf0e055baba1b93961


-- 
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


Re: [PR] arch/xtensa: set PS.EXCM initial value to 1 while new thread created [nuttx]

Posted by "anchao (via GitHub)" <gi...@apache.org>.
anchao merged PR #15985:
URL: https://github.com/apache/nuttx/pull/15985


-- 
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


Re: [PR] arch/xtensa: set PS.EXCM initial value to 1 while new thread created [nuttx]

Posted by "chirping78 (via GitHub)" <gi...@apache.org>.
chirping78 commented on PR #15985:
URL: https://github.com/apache/nuttx/pull/15985#issuecomment-2731529034

   @sdc-g , to be more elaborate,
   Take into consideration the task being interrupted and resumed, there are four combination scenarios:
   two symmetric scenarios:
   1. task being interrupted by level1 int, and resumed by level1 int;
   2. task being interrupted by level2+ int, and resumed by level2+ int;
   
   and two asymmetric  scenarios:
   
   3. task being interrupted by level1 int, and resumed by level2+ int;
   4. task being interrupted by level2+ int, and resumed by level1 int;
   
   For new task creation, since we are pretended the task is being interrupted, and resume it later, it's just a special one of above scenarios.
   
   Before the current PR change, in new task‘s register save area, REG_PS's `EXCM` bit is clear. 
   This means it looks like scenario 2 or 4.  My changes in PR [14672](https://github.com/apache/nuttx/pull/14672) have done special handling to achieve the balence: level 1 enter, clear REG_PS's `EXCM` bit; level 1 leave, set REG_PS's `EXCM` bit before `rfe`.
   
   With  the current PR change, in new task‘s register save area, REG_PS's `EXCM` bit is set. 
   This means it looks like scenario 1 or 3. But the new task missed what have been done for hardware interrupt, clear REG_PS's `EXCM` bit. This means it breaks the balence, this is why I said error will arise in scenario 3.


-- 
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


Re: [PR] arch/xtensa: set PS.EXCM initial value to 1 while new thread created [nuttx]

Posted by "sdc-g (via GitHub)" <gi...@apache.org>.
sdc-g commented on PR #15985:
URL: https://github.com/apache/nuttx/pull/15985#issuecomment-2720321515

   > please update the commit title to
   > 
   > arch/xtensa: set PS.EXCM initial value to 1 while new thread created
   
   Done, thanks for your comment. @jerpelea 


-- 
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


Re: [PR] arch/xtensa: set PS.EXCM initial value to 1 while new thread created [nuttx]

Posted by "sdc-g (via GitHub)" <gi...@apache.org>.
sdc-g commented on PR #15985:
URL: https://github.com/apache/nuttx/pull/15985#issuecomment-2728858391

   Hi @chirping78 
   
   thanks so much for your comment.
   
   > To prevent the resuming action be interrupted, REG_PS.EXCM is set to 1 [here](https://github.com/apache/nuttx/blob/master/arch/xtensa/src/common/xtensa_user_handler.S#L317) and [here](https://github.com/apache/nuttx/blob/master/arch/xtensa/src/common/xtensa_int_handlers.S#L224)
   
   I'm so sorry, I do NOT enough check the latest Nuttx code. I am working at branched version around 12.5.
   Actually, I also provide one similar assembly code change internally. So I think, by using your changes, the issue also can fixed. But let me try to reproduce and double confirm.
   
   > If new task be resumed by level2 and above: rfi will restores the PS from EPS[N] and jump to the address in EPC[N]. Problem will be here, after the new task be resumed, the PS.EXCM bit is still set. If window rotation related instruction is executed, error will arise.
   
   This PR changes the initial value of PS.EXCM. While high level interrupt, e.g., swint as level 3 to switch to the new thread, what is the value of its EPS_3? PS.EXCM is cleared [here](https://github.com/apache/nuttx/blob/master/arch/xtensa/src/common/xtensa_swint.c#L387):


-- 
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


Re: [PR] arch/xtensa: set PS.EXCM initial value to 1 while new thread created [nuttx]

Posted by "sdc-g (via GitHub)" <gi...@apache.org>.
sdc-g commented on PR #15985:
URL: https://github.com/apache/nuttx/pull/15985#issuecomment-2731615130

   Hi @chirping78 
   
   Thank you so much. It's so happy to discuss with you~
   
   > please check the latest master code: xtensa_swint is now triggered by syscall, not by wsr intset.
   > syscall is a level1 interrupt. 
   
   I'm also noticed that change. So current system only level-1 interrupt and syscall, both can re-set PS.EXCM to 0 by rfe, right?
   
   > If new task be resumed by level2 and above: rfi will restores the PS from EPS[N] and jump to the address in EPC[N]. Problem will be here, after the new task be resumed, the PS.EXCM bit is still set. If window rotation related instruction is executed, error will arise.
   
   I'm still wonder what happens while high level interrupt handling then switch to new thread context.
   Does it really happens? what is the value of EPS[N] then?
   
   Here is my consideration, from Level-1 interrupt and syscall view, it is a little bit strange to overwrite PS.EXCM to 0 and then set it to 1.
   I can understand that we are fixing same issue since I prepare one similar commit internally before (without overwrite, but set PS.EXCM to 1 in level-1 case), and also let Espressif guy reviewed.
   But this PR align with ESP-IDF, so probably, another choose is use it as formal one but remove _xtensa_syscall_handler/_xtensa_level1_handler overwrite/set PS.EXCM code.
   
   So I suppose the key point here is what is the impact for level-2 and above?


-- 
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


Re: [PR] arch/xtensa: set PS.EXCM initial value to 1 while new thread created [nuttx]

Posted by "sdc-g (via GitHub)" <gi...@apache.org>.
sdc-g commented on PR #15985:
URL: https://github.com/apache/nuttx/pull/15985#issuecomment-2732366846

   Hi @chirping78 
   
   I am trying...


-- 
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


Re: [PR] arch/xtensa: set PS.EXCM initial value to 1 while new thread created [nuttx]

Posted by "chirping78 (via GitHub)" <gi...@apache.org>.
chirping78 commented on PR #15985:
URL: https://github.com/apache/nuttx/pull/15985#issuecomment-2735659086

   
   
   > Could you please share this doc, I can not find it in [official website](https://www.cadence.com/en_US/home.html). Thanks in advance~
   
   This doc is bundled with cadence CPU design tools Xplorer, which is provided to company who buys the IP, so I can't share outside. 
   It's just a simplified version of "Instruction Set Architecture (ISA) Reference Manual", so don't expect too much.
   


-- 
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


Re: [PR] arch/xtensa: set PS.EXCM initial value to 1 while new thread created [nuttx]

Posted by "tmedicci (via GitHub)" <gi...@apache.org>.
tmedicci commented on PR #15985:
URL: https://github.com/apache/nuttx/pull/15985#issuecomment-2720986262

   Marked as draft to avoid being merged before extensive testing. I will trigger our internal CI and test run the runtime testing.


-- 
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


Re: [PR] arch/xtensa: set PS.EXCM initial value to 1 while new thread created [nuttx]

Posted by "sdc-g (via GitHub)" <gi...@apache.org>.
sdc-g commented on PR #15985:
URL: https://github.com/apache/nuttx/pull/15985#issuecomment-2723113854

   > Hi @sdc-g , did you find any bug related to this PR?
   > 
   > Before applying its patch, what was the behavior of the testing application? Can you please update the PR's descriptions with this information if applicable?
   
   Hi @tmedicci 
   Yes, actually the test code is extract from application.
   
   Without this patch, the system will hang since the registers especially SP (retrieve after PS register) are corrupted. 
   Let me update the log into PR's description.


-- 
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


Re: [PR] arch/xtensa: set PS.EXCM initial value to 1 while new thread created [nuttx]

Posted by "tmedicci (via GitHub)" <gi...@apache.org>.
tmedicci commented on PR #15985:
URL: https://github.com/apache/nuttx/pull/15985#issuecomment-2724509023

   > Marked as draft to avoid being merged before extensive testing. I will trigger our internal CI and run the runtime testing.
   
   Everything seems to be fine with it. Tested with all xtensa devices and run the runtime testing (`ostest` included). Thanks!


-- 
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


Re: [PR] arch/xtensa: set PS.EXCM initial value to 1 while new thread created [nuttx]

Posted by "sdc-g (via GitHub)" <gi...@apache.org>.
sdc-g commented on PR #15985:
URL: https://github.com/apache/nuttx/pull/15985#issuecomment-2735462706

   Hi @chirping78 
   
   Sorry, one more discussion: while level-2 and above interrupt, PS.EXCM also set to 1.
   
   So if context switching happens, there is also double exception if window ratation instruction is executed.
   The sequence like: threadA PS.EXCM is 0 -> PS.EXCM set to 1 while level-2 interrupt -> context switching to threadB -> level-2 interrupt and resume threadA with PS.EXCM=1, then double exception
   
   Please refer to "xtensa Instruction Set Architecture (ISA) Reference Manual"
   ```
   The taking of an exception under the Exception Option has the following semantics:
   procedure Exception(cause)
   if (PS.EXCM & NDEPC=1) then
   DEPC ← PC
   nextPC ← DoubleExceptionVector
   elseif PS.EXCM then
   EPC[1] ← PC
   nextPC ← DoubleExceptionVector
   elseif PS.UM then
   EPC[1] ← PC
   nextPC ← UserExceptionVector
   else
   EPC[1] ← PC
   nextPC ← KernelExceptionVector
   endif
   EXCCAUSE ← cause
   PS.EXCM ← 1
   endprocedure Exception
   ```
   
   Is it possible and correct understanding?


-- 
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


Re: [PR] arch/xtensa: set PS.EXCM initial value to 1 while new thread created [nuttx]

Posted by "chirping78 (via GitHub)" <gi...@apache.org>.
chirping78 commented on PR #15985:
URL: https://github.com/apache/nuttx/pull/15985#issuecomment-2735606918

   
   > Even REG_PS is saved with PS.EXCM=1, PS retrieve by EPS[N]
   
   Nonono, for level2+ interrupt ***pre-interrupt*** PS is saved into EPS[N], this means `REG_PS.EXCM=0`


-- 
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


Re: [PR] arch/xtensa: set PS.EXCM initial value to 1 while new thread created [nuttx]

Posted by "sdc-g (via GitHub)" <gi...@apache.org>.
sdc-g commented on PR #15985:
URL: https://github.com/apache/nuttx/pull/15985#issuecomment-2732442828

   Hi @chirping78 
   
   > If window rotation related instruction is executed, error will arise.
   > The PS here 00050030, note the bit 0x10, it's PS.EXCM.
   
   sorry, what is the relationship between window rotation and PS.EXCM=1?


-- 
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


Re: [PR] arch/xtensa: set PS.EXCM initial value to 1 while new thread created [nuttx]

Posted by "sdc-g (via GitHub)" <gi...@apache.org>.
sdc-g commented on PR #15985:
URL: https://github.com/apache/nuttx/pull/15985#issuecomment-2735671080

   OK, got it. Thank you again! @chirping78 


-- 
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


Re: [PR] arch/xtensa: set PS.EXCM initial value to 1 while new thread created [nuttx]

Posted by "sdc-g (via GitHub)" <gi...@apache.org>.
sdc-g commented on PR #15985:
URL: https://github.com/apache/nuttx/pull/15985#issuecomment-2735635483

   Hi @chirping78 
   
   Yes, I can understand it now. Thanks so much!
   
   > Copied from <<Xtensa Microprocessor Programmer’s Guide>>
   
   Could you please share this doc, I can not find it in [official website](https://www.cadence.com/en_US/home.html).
   Thanks in advance~


-- 
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


Re: [PR] arch/xtensa: set PS.EXCM initial value to 1 while new thread created [nuttx]

Posted by "chirping78 (via GitHub)" <gi...@apache.org>.
chirping78 commented on PR #15985:
URL: https://github.com/apache/nuttx/pull/15985#issuecomment-2732248819

   @sdc-g I have found a way to reproduce. Here it is:
   1. With latest master code, change `apps/examples/hello/hello_main.c`, replace it with the progrom in your PR summary
   2. change `esp32s3-devkit:tickless` config, enable `CONFIG_EXAMPLES_HELLO`
   3. change `arch/xtensa/src/esp32s3/esp32s3_tickless.c` to make `esp32s3_setup_irq` request level2 interrupt. There is a patch [here](https://github.com/apache/nuttx/pull/14672#issuecomment-2558786070) 
   4. change `arch/xtensa/src/common/xtensa_vectors.S`, comment out the `break   1, 4` in `_double_exception_vector`
   
   That's all. With these changes, the system will have a level2 interrupt, and new thread is created frequently.
   
   
   Now build `esp32s3-devkit:tickless` config and flash the board.
   Run hello will trigger this error:
   ````
   ******** Test Start ********
   xtensa_panic: Unhandled Exception 2 task: hello
   dump_assert_info: Current Version: NuttX  12.8.0 b1bab5c7837-dirty Mar 18 2025 17:01:37 xtensa
   dump_assert_info: Assertion failed panic: at file: :0 task: hello process: hello 0x42022d5c
   up_dump_register:    PC: 4202b27c    PS: 00050030
   ````
   The PC here is `pthread_start`, this is what I said ***If window rotation related instruction is executed, error will arise***
   
   Revert your this PR, then everything is OK.
   ````
   nsh> hello
   Start TimeSliceThread
   
   
   ******** Test Start ********
   Test Thread
   Test Thread
   Test Thread
   Test Thread
   Test Thread
   ````
   You can revert and apply your this PR back and forth to see the effect, until you are convinced your this PR is harmful.


-- 
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


Re: [PR] arch/xtensa: set PS.EXCM initial value to 1 while new thread created [nuttx]

Posted by "tmedicci (via GitHub)" <gi...@apache.org>.
tmedicci commented on PR #15985:
URL: https://github.com/apache/nuttx/pull/15985#issuecomment-2732366586

   Thanks for the ongoing conversation @chirping78 and @sdc-g !
   
   Should we revert it then?


-- 
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


Re: [PR] arch/xtensa: set PS.EXCM initial value to 1 while new thread created [nuttx]

Posted by "chirping78 (via GitHub)" <gi...@apache.org>.
chirping78 commented on PR #15985:
URL: https://github.com/apache/nuttx/pull/15985#issuecomment-2733017038

   > Hi @chirping78
   > 
   > Thanks so much always. I can understand instruction undefined behavior while PS.EXCM=1. Let me revert this commit.
   
   Since you already understood, so I just write down here for future reference:
   
   Copied from <<Xtensa Microprocessor Programmer’s Guide>>
   " On Xtensa IV (T1040) processors or later, executing a windowed-register instruction (for example, callN, callxN, entry, or retw) when PS.EXCM==1 or PS.WOE==0 will result in an Illegal Instruction exception."


-- 
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


Re: [PR] arch/xtensa: set PS.EXCM initial value to 1 while new thread created [nuttx]

Posted by "sdc-g (via GitHub)" <gi...@apache.org>.
sdc-g commented on PR #15985:
URL: https://github.com/apache/nuttx/pull/15985#issuecomment-2735591257

   Hi @chirping78 
   
   Not sure below one is correct answer, but PS is saved into EPS[N] before PS.EXCM set to 1
   
   ```
   function takeinterrupt(level)
   EPC[level] ← PC
   EPS[level] ← PS
   PC ← InterruptVector[level]
   PS.INTLEVEL ← level
   PS.EXCM ← 1
   endfunction takeinterrupt
   ```


-- 
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


Re: [PR] arch/xtensa: set PS.EXCM initial value to 1 while new thread created [nuttx]

Posted by "sdc-g (via GitHub)" <gi...@apache.org>.
sdc-g commented on PR #15985:
URL: https://github.com/apache/nuttx/pull/15985#issuecomment-2732667748

   Hi @chirping78 
   
   Thanks so much always.
   I can understand instruction undefined behavior while PS.EXCM=1.
   Let me revert this commit.


-- 
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


Re: [PR] arch/xtensa: set PS.EXCM initial value to 1 while new thread created [nuttx]

Posted by "chirping78 (via GitHub)" <gi...@apache.org>.
chirping78 commented on PR #15985:
URL: https://github.com/apache/nuttx/pull/15985#issuecomment-2732052485

   > So current system only level-1 interrupt and syscall, both can re-set PS.EXCM to 0 by rfe, right?
   
   yes
   
   > 
   > I'm still wonder what happens while high level interrupt handling then switch to new thread context. Does it really happens? what is the value of EPS[N] then?
   > 
   > 
   > So I suppose the key point here is what is the impact for level-2 and above?
   
   Does it really happens? In theory, it exists.  
   But this scenario is rarely seen, it needs intentionally creating the conditions to reproduce. I will try to find.
   


-- 
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


Re: [PR] arch/xtensa: set PS.EXCM initial value to 1 while new thread created [nuttx]

Posted by "sdc-g (via GitHub)" <gi...@apache.org>.
sdc-g commented on PR #15985:
URL: https://github.com/apache/nuttx/pull/15985#issuecomment-2732740063

   Hi @chirping78 @tmedicci 
   
   Please review: https://github.com/apache/nuttx/pull/16013


-- 
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


Re: [PR] arch/xtensa: set PS.EXCM initial value to 1 while new thread created [nuttx]

Posted by "chirping78 (via GitHub)" <gi...@apache.org>.
chirping78 commented on PR #15985:
URL: https://github.com/apache/nuttx/pull/15985#issuecomment-2731421548

   
   
   > 
   > This PR changes the initial value of PS.EXCM. While high level interrupt, e.g., swint as level 3 to switch to the new thread, what is the value of its EPS_3? PS.EXCM is cleared [here](https://github.com/apache/nuttx/blob/master/arch/xtensa/src/common/xtensa_swint.c#L387):
   
   
   @sdc-g please check the latest master code: `xtensa_swint` is now triggered by `syscall`, not by `wsr intset`. `syscall ` is a level1 interrupt.
   
   


-- 
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


Re: [PR] arch/xtensa: set PS.EXCM initial value to 1 while new thread created [nuttx]

Posted by "chirping78 (via GitHub)" <gi...@apache.org>.
chirping78 commented on PR #15985:
URL: https://github.com/apache/nuttx/pull/15985#issuecomment-2735595428

   yes, for level2+ interrupt, pre-interrupt PS is saved into EPS[N], then into `REG_PS`.
   For level1 interrupt, it's another story..


-- 
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


Re: [PR] arch/xtensa: set PS.EXCM initial value to 1 while new thread created [nuttx]

Posted by "tmedicci (via GitHub)" <gi...@apache.org>.
tmedicci commented on PR #15985:
URL: https://github.com/apache/nuttx/pull/15985#issuecomment-2721392583

   Hi @sdc-g , did you find any bug related to this PR?
   
   Before applying its patch, what was the behavior of the testing application? Can you please update the PR's descriptions with this information if applicable? 


-- 
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