-
Notifications
You must be signed in to change notification settings - Fork 8.2k
arch: arc: fixes the case triggering a cpu exception in user mode #18079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
arch: arc: fixes the case triggering a cpu exception in user mode #18079
Conversation
|
Not sure if it's relevant or not, but this seems to change the behavior for the kernel non-isr case: it doesn't trigger an exception anymore. Alternative would be to first test for user mode, and then test for interrupt context (I assume that is to avoid fatal double exception?) |
z_except_reason/Z_ARCH_EXCEPT is actively called by kernel like k_panic, k_oops, it's a kind of SW exception, different with HW exception. So if the processor in kernel mode, it has enough privilege to do things like an exception fix. Although it's also ok to raise a hardware exception by TRAP, it's not efficient because of exception prologue handling. any thought on this? Does z_except_reason need to raise a real exception? @andrewboie |
|
I did a further look of Z_ARCH_EXCEPT. It seems to it's required to raise an cpu exception. So i made some updates that remove the check of user_context/isr. For the case that called in exception handler, it will raise double exception. But this case is unreasonable. |
Yes, this should trigger an exception. |
|
Why is this check even needed? |
|
Now, raise exception unconditionally |
ioannisg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's now completely unconditional, right?
Looks ok to me, @ruuddw pls, take a look
|
@abrodkin could you also review? |
|
This indeed fixes #17899. Not sure though if the ISR check isn't required to handle the case that Z_ARCH_EXCEPT is called from interrupt context. Sanity check looks clean, is there a test that calls Z_ARCH_EXCEPT from isr context? Would that be expected to work? Also, I see a related 'FIXME' in userspace tests. ARC is excluded in test_oops ("FIXME #17590"). Can #17590 be closed now as well? |
abrodkin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me to.
use "trap_s 3" to simulate SW exception raised by kernel Signed-off-by: Wayne Ren <[email protected]>
|
@ruuddw @andrewboie , I found why there is a condition to raise exception, i.e., whether in isr, I add another commit to fix this in this PR. Pls review, and do not merge before the sanitycheck test is clean. |
exception, different with irq offload, may be raised interrupt handling, e.g. * z_check_stack_sentinel * wrong code we need to add specific handling of this case in exception handling Signed-off-by: Wayne Ren <[email protected]>
@ruuddw I'm not sure I understand. If you trigger this while servicing an interrupt, doesn't this just induce an exception? That's what we would want. The behavior should be:
I don't know if there's a test for this scenario, it should be reasonable to implement using irq_offload(). |
ruuddw
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
according to high-level design,in user mode software-triggered system fatal exceptions only allow oops and stack check failure Signed-off-by: Wayne Ren <[email protected]>
the tested feature is supported now, remove the exception Signed-off-by: Wayne Ren <[email protected]>
|
@ruuddw @vonhust @andrewboie @nashif can we backport this PR to v1.14 branch? |
|
@wentongwu agree this looks like it should be backported. I would recommend look at all other arch/arc patches I am not sure if all ARC userspace patches have been backported since 1.14. there were a lot of things fixed after 1.14 |
|
@andrewboie yes, checked the commit history, lots of enhancement/fix for user space added, I don't think user space on arc will work well without them. It would be better if these patches can be backported to v1.14 branch. @ruuddw is it possible to do that backport for arc? |
|
We've done few backports, but there have been many enhancements (to support SMP) as well that we didn't backport. |
Fixes #17899 #17590