Skip to content

Conversation

@zephyrbot
Copy link

@zephyrbot zephyrbot commented Jul 27, 2024

Backport 7db18ab from #75564.

Fixes #76398

According to the riscv's `arch.h`:

 +------------+ <- thread.arch.priv_stack_start
 | Guard      | } Z_RISCV_STACK_GUARD_SIZE
 +------------+
 | Priv Stack | } CONFIG_PRIVILEGED_STACK_SIZE
 +------------+ <- thread.arch.priv_stack_start +
                   CONFIG_PRIVILEGED_STACK_SIZE +
                   Z_RISCV_STACK_GUARD_SIZE

The start of the privilege stack should be:

  `thread.arch.priv_stack_start + Z_RISCV_STACK_GUARD_SIZE`

Instead of

  `thread.arch.priv_stack_start - CONFIG_PRIVILEGED_STACK_SIZE`

For the `end`, use the same equation of `top_of_priv_stack` in
the `arch_user_mode_enter()`

Signed-off-by: Yong Cong Sin <[email protected]>
(cherry picked from commit 7db18ab)
@zephyrbot zephyrbot added Backport Backport PR and backport failure issues area: RISCV RISCV Architecture (32-bit & 64-bit) labels Jul 27, 2024
@henrikbrixandersen henrikbrixandersen added this to the v3.7.1 milestone Jul 27, 2024
@henrikbrixandersen
Copy link
Member

This needs a bug report in order to get backported.

@ycsin
Copy link
Member

ycsin commented Jul 29, 2024

This needs a bug report in order to get backported.

Added bug report

@ycsin ycsin linked an issue Aug 1, 2024 that may be closed by this pull request
@dleach02 dleach02 merged commit 57c1f22 into v3.7-branch Aug 3, 2024
@dleach02 dleach02 deleted the backport-75564-to-v3.7-branch branch August 3, 2024 03:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: RISCV RISCV Architecture (32-bit & 64-bit) Backport Backport PR and backport failure issues

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

arch: riscv: stacktrace: user thread stack bound check is wrong

9 participants