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

Fix portSWITCH_TO_USER_MODE() on Armv7-M MPU ports #803

Merged
merged 10 commits into from
Sep 26, 2023

Conversation

Skptak
Copy link
Member

@Skptak Skptak commented Sep 21, 2023

Description

A task's privilege level is stored in ulTaskFlag member in the TCB. Current implementation of portSWITCH_TO_USER_MODE() does not update this flag but just lowers the processor's privilege level. This results in many APIs incorrectly determining task's privilege level and access permissions -

  • xPortIsAuthorizedToAccessBuffer
  • xPortIsTaskPrivileged
  • xPortIsAuthorizedToAccessKernelObject

This PR fixes the portSWITCH_TO_USER_MODE() implementation to correctly update the ulTaskFlag member in the TCB before lowering the processor's privilege level.

Test Steps

Tested on Cortex-M7.

Checklist:

  • I have tested my changes. No regression in existing tests.
  • I have modified and/or added unit-tests to cover the code changes in this Pull Request.

Related Issue

NA.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@Skptak Skptak requested a review from a team as a code owner September 21, 2023 19:23
portable/GCC/ARM_CM3_MPU/port.c Outdated Show resolved Hide resolved
portable/GCC/ARM_CM4_MPU/port.c Outdated Show resolved Hide resolved
portable/IAR/ARM_CM4F_MPU/port.c Outdated Show resolved Hide resolved
portable/RVDS/ARM_CM4_MPU/port.c Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Sep 21, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (ac5deb1) 93.62% compared to head (7721ab0) 93.62%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #803   +/-   ##
=======================================
  Coverage   93.62%   93.62%           
=======================================
  Files           6        6           
  Lines        2508     2508           
  Branches      598      598           
=======================================
  Hits         2348     2348           
  Misses        107      107           
  Partials       53       53           
Flag Coverage Δ
unittests 93.62% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

…ded macros, remove the incorrect attribute comments
@Skptak
Copy link
Member Author

Skptak commented Sep 21, 2023

/bot run formatting

@Skptak Skptak force-pushed the portSwitchToUserModeFix branch from c6d3547 to 398e82b Compare September 21, 2023 20:55
jasonpcarroll
jasonpcarroll previously approved these changes Sep 21, 2023
@aggarg aggarg changed the title MPU enabled ArmV7-M portSWITCH_TO_USER_MODE() Fix Fix portSWITCH_TO_USER_MODE() on Armv7-M MPU ports Sep 25, 2023
Signed-off-by: Gaurav Aggarwal <[email protected]>
Signed-off-by: Gaurav Aggarwal <[email protected]>
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@aggarg aggarg merged commit 84bdb05 into FreeRTOS:main Sep 26, 2023
@Skptak Skptak deleted the portSwitchToUserModeFix branch December 19, 2023 13:07
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.

5 participants