Skip to content
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

Secure stack check #9024

Conversation

vonhust
Copy link
Collaborator

@vonhust vonhust commented Jul 19, 2018

this PR is used to enable the stack check when arc is in secure mode.

If arc is in secure mode, SSC bit of sec_stat, not SC bit of status32, is used to enable/disable stack check.

Fixes #8313

@vonhust vonhust requested a review from ruuddw as a code owner July 19, 2018 09:07
@carlescufi carlescufi requested a review from ioannisg July 19, 2018 09:20
@codecov-io
Copy link

codecov-io commented Jul 19, 2018

Codecov Report

Merging #9024 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #9024   +/-   ##
=======================================
  Coverage   52.15%   52.15%           
=======================================
  Files         212      212           
  Lines       25916    25916           
  Branches     5582     5582           
=======================================
  Hits        13517    13517           
  Misses      10149    10149           
  Partials     2250     2250

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 84c352d...201b260. Read the comment docs.

@ruuddw
Copy link
Member

ruuddw commented Aug 2, 2018

Looks ok, few discussion topics:

  • I don't see corresponding stack check enables in most cases where checking is disabled (exceptions, interrupts), assume that is handled implicitly by restore of the original STAT/SEC_STAT on interrupt return?
  • is it necessary to always disable stack checking for interrupt processing? Would it be possible to keep stack checking enabled and only disable on reprogramming the stack boundary registers on a context switch?

@vonhust
Copy link
Collaborator Author

vonhust commented Aug 3, 2018 via email

Wayne Ren added 4 commits August 22, 2018 16:59
stack check bit of status32/sec_stat will be cleared
automically in exception entry.

so remove the redundent codes

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
when arc is in secure mode, SSC bit of sec_stat,
not SC bit of status32,is used to enable stack check.

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
The fake exception return is used to jump to user mode.
So the init status of user thread is in exception mode.

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
re-orginize the code in _new_thread to make it
easier to understand and maintain

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
Copy link
Member

@ruuddw ruuddw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok, and sanitycheck is (almost) clean now for nsim_em and nsim_sem. Few remaining failures, but these are understood and expected.
@nashif I believe this PR is ready for merging now.

Wayne Ren added 2 commits August 22, 2018 17:17
as the thread is created in privileged mode, the init
context should also be in privileged stack.

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
to avoid _get_num_regions to access the aux
reg each time in the for loop

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
@nashif nashif merged commit 506f21b into zephyrproject-rtos:master Aug 22, 2018
@vonhust vonhust deleted the secure_stack_check branch December 13, 2018 03:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants