Skip to content

freertos: riscv: fix t0 restore in ecall_yield - #228

Merged
tdrozdovsky merged 1 commit into
Samsung:masterfrom
Saiiijchan:fix_mistake_t0_restore
Dec 30, 2025
Merged

tdrozdovsky merged 1 commit into
Samsung:masterfrom
Saiiijchan:fix_mistake_t0_restore

Conversation

@Saiiijchan

@Saiiijchan Saiiijchan commented Dec 30, 2025

Copy link
Copy Markdown

In trap entry, t0 is saved to mscratch.

Description

In trap entry, t0 is saved to mscratch (csrw mscratch, t0). In ecall_yield, the code attempted to restore t0 from mstatus. This would corrupt t0 with mstatus value instead of original t0

Retore t0, from mscratch instead of mstatus
Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • [x ] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code cleanup/refactoring
  • CI system update
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A
  • Test B

Test Configuration:

  • Firmware version:
  • Hardware:
  • Toolchain:
  • SDK:

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

In trap entry, t0 is saved to mscratch.

Signed-off-by: wangfei_chen <wangfei_chen@realsil.com.cn>
@tdrozdovsky
tdrozdovsky merged commit 5e3bfc2 into Samsung:master Dec 30, 2025
6 of 7 checks passed
@Saiiijchan
Saiiijchan deleted the fix_mistake_t0_restore branch December 31, 2025 05:39
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.

2 participants