Skip to content

Fixup ARM MPU to use opaque types / Rebase of #500 #987

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

Merged
merged 5 commits into from
Aug 9, 2017

Conversation

agross-oss
Copy link
Collaborator

This set of patches takes jamike's #500 and rebases them on top of master. Additionally, this fixes up the code to use the new opaque kernel types and fixes the outstanding review comments from #500.

Copy link
Contributor

@andrewboie andrewboie left a comment

Choose a reason for hiding this comment

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

Have some questions about the test case, with at least one bug


while (1) {
k_sleep(SLEEPTIME);
}
}

k_sleep(SCHEDTIME);
Copy link
Contributor

Choose a reason for hiding this comment

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

any particular reason why we need a delay here? if the messages from different threads are clobbering each other in the console output you could consider locking the scheduler around the printk()

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have no idea why that was added. I'll check it out and see if that is the reason. If so, I'll change to be as you suggested.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

After looking at this more, it doesn't make any difference having it or not. So I am going to remove it.

/* stack_guard_thread is a dynamic thread */
void stack_guard_thread(void *dummy1, void *dummy2, void *dummy3)
{
ARG_UNUSED(dummy1);
ARG_UNUSED(dummy2);
ARG_UNUSED(dummy3);
while (1)
recursive_loop(0, (int)dummy1, dummy2);
Copy link
Contributor

Choose a reason for hiding this comment

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

Also you have ARG_UNUSED(dummy1) and ARG_UNUSED(dummy2), but then they now get used. This definitely needs to be changed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good catch

@@ -35,33 +35,40 @@ To build the test with the MPU enabled and the stack guard feature present:
Sample Output
=============

With the MPU disabled:
With the MPU enabled but the stack guard feature disabled:
Copy link
Contributor

Choose a reason for hiding this comment

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

since you used the phrase"stack guard feature disabled" here, should line 62 below say "stack guard feature enabled" to be consistent?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, ill make that change.

* @param nmemb Number of stacks to declare
* @param size Size of the stack memory region
*/

Copy link
Contributor

Choose a reason for hiding this comment

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

tradition has it this blank line shouldn't be here

Copy link
Contributor

@dbkinder dbkinder left a comment

Choose a reason for hiding this comment

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

couple of suggestions

@andrewboie
Copy link
Contributor

As an aside, the test code is just a sample, and doesn't programmatically determine whether stack overflow protection is working correctly. We really need to convert this into a proper test case, my suggestion would be to merge this code with tests/kernel/fatal which also does some stack overflow scenarios and verifies that the expected exception type was triggered.

Also despite its name, the test code isn't MPU specific; with PR #982 applied, it works great on qemu_x86.

These changes to the test can happen another in another patch, but I thought I'd mention them.

@galak galak self-assigned this Aug 3, 2017
Copy link
Collaborator Author

@agross-oss agross-oss left a comment

Choose a reason for hiding this comment

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

will fix issues and resubmit


while (1) {
k_sleep(SLEEPTIME);
}
}

k_sleep(SCHEDTIME);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have no idea why that was added. I'll check it out and see if that is the reason. If so, I'll change to be as you suggested.

/* stack_guard_thread is a dynamic thread */
void stack_guard_thread(void *dummy1, void *dummy2, void *dummy3)
{
ARG_UNUSED(dummy1);
ARG_UNUSED(dummy2);
ARG_UNUSED(dummy3);
while (1)
recursive_loop(0, (int)dummy1, dummy2);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good catch


while (1) {
k_sleep(SLEEPTIME);
}
}

k_sleep(SCHEDTIME);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

After looking at this more, it doesn't make any difference having it or not. So I am going to remove it.

jamike and others added 5 commits August 3, 2017 14:27
The mimimum mpu size is 32 bytes, but requires mpu base address to be
aligned on 32 bytes to work. Define architecture thread macro when
MPU_STACK_GUARD config to allocate stack with 32 more bytes.

Signed-off-by: Michel Jaouen <[email protected]>
This test launches several threads. Only last thread will overflow the
stack and an mpu exception will occur. The other threads are regulary
suspended, this triggers access to kthread structure. This tests is
failed on st and nxp platform, if 32 bytes alignement is not set.

Signed-off-by: Michel Jaouen <[email protected]>
Following test changes, log info have changes and previous log info
with stack guard present shows an mpu error not caused by a stack
overflow caught by mpu stack guard feature.

Signed-off-by: Michel Jaouen <[email protected]>
This patch always defines the ARCH_THREAD_STACK_XXX macros/functions
regardless of the MPU_STACK_GUARD usage.  Only use MPU_STACK_GUARD when
determining the minimum stack alignment.

Signed-off-by: Andy Gross <[email protected]>
This patch adjusts the ARM MPU implementation to be compliant to the
recent changes that introduced the opaque kernel data types.

Signed-off-by: Andy Gross <[email protected]>
@galak galak dismissed stale reviews from andrewboie and dbkinder August 9, 2017 18:34

Changes made

@galak galak merged commit 5930e9d into zephyrproject-rtos:master Aug 9, 2017
nagineni pushed a commit to nagineni/zephyr that referenced this pull request Nov 20, 2017
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