forked from FreeRTOS/FreeRTOS-Kernel
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Privileged Task Call Stack Idea #5
Open
Skptak
wants to merge
9
commits into
ARM_CRx_MPU
Choose a base branch
from
PrivilegedTaskStackIdea
base: ARM_CRx_MPU
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Apply git review patch created by @aggargr * Add necessary changes to the CMakeLists.txt file to build the port
Update the comment for configKERNEL_INTERRUPT_PRIORITY in the template FreeRTOSConfig.h. It was reported here - https://forums.freertos.org/t/migration-from-v10-5-1-to-v11-0-1-fails-with-new-freertosconfig-h-file/19276/ Signed-off-by: Gaurav Aggarwal <[email protected]>
* pxIndex should only be used when selecting next task. Altering pxIndex of a ready list will cause the scheduler to be unable to select the right task to run. Using a for loop if traversing the list for trace utility is required. * Not defining listGET_OWNER_OF_NEXT_ENTRY when using SMP scheduler --------- Co-authored-by: Gaurav-Aggarwal-AWS <[email protected]>
Skptak
force-pushed
the
PrivilegedTaskStackIdea
branch
from
March 6, 2024 18:46
384621b
to
d95451d
Compare
Idea is to statically declare stacks that can then be turned into MPU regions. In order to prevent accidental overflows/underflows an MPU region is set around the stack that does not allow privileged writes. I then use MPU sub-regions to disable writing to the top and bottom 8th of the stack. This way if an accidental overflow/underflow occurs it will hit the section that doesn't allow writes, causing a data abort. However, in order to do this the task stack region has to be a higher priority region than portPRIVILEGED_RAM_REGION. This is because if portPRIVILEGED_RAM_REGION is a higher numeric region, it would over-write the MPU region on the call stack that doesn't allow writes. This commit has the code that performs this change wrapped in an if 0 block while I tested just changing portSTACK_REGION to be a higher priority region than portPRIVILEGED_RAM_REGION. This commit also has a bit of a proof of concept for trying to do this with only two registers. Idea is to use the LDREX and STREX instructions, which according to ARM replace the deprecated SWP instruction. But going to leave that alone for now and work on just getting this to actually work before looking into that.
Save MPU Settings for the Call Stack as part of the struct. Use subregions to not allow writes to the end and start of it. Use scratch registers to load/save the MPU settings. Could look into getting it to work without needing scratch registers, but think that leads to a much longer entrance/exit. Add an additional check for the xPortIsAuthorizedToAccessBuffer() to look at the MPU settings saved in xSYSTEM_CALL_STACK_BUFFER if pulTaskStackPointer != NULL.
… it can build without a change to the demos FreeRTOSConfig files.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Very lazy idea for how to move the privileged call stacks out of the TCBs
Test Steps
Checklist:
Related Issue
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.