arm: cortex_r: config_userspace: nested interrupt level is not decremented following syscall


Phil Erwin Jr
 

In v2.3 when building with CONFIG_USERSPACE enabled, I see that we do not do a context switch a short time after POR.  I've chased this back and found the the cpus[0].nested has incremented to 6, so the code in z_arm_int_exit() thinks we are in a nested interrupt, and does not switch to another task.

The flaw is because of our syscall path.  On each syscall, we increment the nested count upon entry to the SVC (z_arm_svc in swap_helper.S), but then we go through z_arm_do_syscall (userspace.S) and return from the syscall without ever decrementing nested. 

The Cortex M code appears to work the same way to me.

It seems to me that the system call should exit by means of branching to z_arm_exc_exit, as is done elsewhere.

Comments?

Phil


Boie, Andrew P
 

  • In v2.3 when building with CONFIG_USERSPACE enabled, I see that we do not do a context switch a short time after POR.  I've chased this back and found the the cpus[0].nested has incremented to 6, so the code in z_arm_int_exit() thinks we are in a nested interrupt, and does not switch to another task.

 

Hi Phil, can you open a GH issue on this? Stephanos or maybe Ioannis may want to take a look at it.

 

Also, what platform do you use to test user mode on cortex-R? qemu_cortex_r5 doesn't work with it (gaps in emulation support for the MPU perhaps?)

 

Andrew


Phil Erwin Jr
 

Hi Andrew,

I opened GH issue #26912, and Stephanos is assigned to it.

My platform is an internal chip, that has an R5 core.  I'm fairly certain that one of our team members uses QEMU, though, so I'll check with him to see if we need to up-stream anything to get that working.  It sure would be nice to close this testing hole with each upgrade.

Phil


From: Boie, Andrew P <andrew.p.boie@...>
Sent: 17 July 2020 7:08 PM
To: Phil Erwin Jr <phil.erwin@...>; devel@... <devel@...>
Subject: RE: [Zephyr-devel] arm: cortex_r: config_userspace: nested interrupt level is not decremented following syscall
 
  • In v2.3 when building with CONFIG_USERSPACE enabled, I see that we do not do a context switch a short time after POR.  I've chased this back and found the the cpus[0].nested has incremented to 6, so the code in z_arm_int_exit() thinks we are in a nested interrupt, and does not switch to another task.

 

Hi Phil, can you open a GH issue on this? Stephanos or maybe Ioannis may want to take a look at it.

 

Also, what platform do you use to test user mode on cortex-R? qemu_cortex_r5 doesn't work with it (gaps in emulation support for the MPU perhaps?)

 

Andrew