-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
armv8-m: making full SRAM run-time partitioning (MPU gap filling) optional #20152
armv8-m: making full SRAM run-time partitioning (MPU gap filling) optional #20152
Conversation
ca2702c
to
e945d37
Compare
e945d37
to
efcf04f
Compare
efcf04f
to
cf25a00
Compare
I think it should be off by default -- an extra feature that can be enabled if users want it. It's not required for user mode at any rate. As far as the naming of the Kconfig, MPU_FULL_BACKGROUND_SRAM_PARTITIONING is rather long winded, but sure, no complaints if you want to call it that. |
ad9a7a3
to
e903d14
Compare
All checks are passing now. Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages. |
e903d14
to
05671f0
Compare
05671f0
to
29b5260
Compare
I want to have this in for Zephyr v2.1 release; is it possible to have additional reviewing (besides @andrewboie ) on the introduced Kconfig option at least? |
Note that the direct ( The dependencies of
If A tip is to go into the menuconfig and jump to each of the definition locations of the symbol. That might help with figuring out how it works. Basically, the definition in |
Thanks so much @ulfalizer for this feedback.
Not exactly. I need |
arch/arm/core/cortex_m/mpu/Kconfig
Outdated
@@ -62,6 +62,31 @@ config MPU_ALLOW_FLASH_WRITE | |||
help | |||
Enable this to allow MPU RWX access to flash memory | |||
|
|||
config MPU_SRAM_GAP_FILLING |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ulfalizer can we put the definition into if USERSPACE
block, to make it defined only if USERSPACE is also defined? Then, what will happen with the dependency on MPU_REQUIRES_NON_OVERLAPPING_REGIONS
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Note that if FOO
is just a shorthand for adding depends on FOO
to the symbol(s) within it. if
and depends on
are exactly the same thing. I think this is something that confuses people re. Kconfig, where people assume if
does more than that. :)
If a symbol is defined in multiple locations and should depend on USERSPACE
, then all definition locations need to have depends on USERSPACE
(or be within an if USERSPACE
-- same thing), since the dependencies get ORed together.
Personally, I'd try to refactor it so that there's just a single definition in arch/Kconfig
, maybe along with some helper symbols.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I'd try to refactor it so that there's just a single definition in arch/Kconfig, maybe along with some helper symbols.
That's hard; I raised the definition up in arch/Kconfig, as it is essentially a cross-arch option, but I want to keep re-defining it in arch/arm/cortex-m/mpu/Kconfig , so I can have the additional help text that is ARMv8-M specific. But it is becoming clear from your comments that dependencies are always ORed so I cannot add additional dependencies here (so I need to move depends on USERSPACE up in the top-level definition, correct?)
So how can I do it in a way it satisfies you @ulfalizer ? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two are 100% identical:
if FOO
if BAR
config FOO
bool "foo"
depends on BAZ
endif
endif
config FOO
bool "foo"
depends on FOO && BAR && BAZ
if
does not "cancel" the definition, but only modified the dependencies, like depends on
does. When a symbol is defined more than once, the dependencies get ||
'd together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A tip is to play around with this in menuconfig
btw, because it'll make it clear how multiple definitions work:
config DEP1
bool "dep1"
config DEP2
bool "dep2"
config MULTIDEF
bool "first multidef prompt"
depends on DEP1
config MULTIDEF
bool "second multidef prompt"
depends on DEP2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point is that : only the ARCH-specific option will be used in the code. the top-arch option will only be used in Kconfig, to enable the ARM-specific option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was thinking from an interface design perspective. There'll be a button you toggle that says "MPU SRAM gap filling" or the like, but it won't do anything unless you also toggle "User mode threads".
Feels like it gets lost sometimes that Kconfig defines a configuration interface. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as that wouldn't be weird to users, it'll work at least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My preferred solution would be either
-
A single definition in
arch/Kconfig
, with some arch-specific notes in the help text, and maybe some helper symbols to adjust it for different arch capabilities -
Have multiple arch-specific definitions (wouldn't necessarily need to have the same name either), and skip the definition in
arch/Kconfig
I won't impose anything though. Just keep the multiple-definition dependency gotchas in mind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ulfalizer could you come back to this, briefy?
FYI, I integrated your suggestion of _not_duplicating the definition of the Kconfig option - it is really cleaner. So, I introduced an internal hidden ARM-only option that takes the configuration enforced by the user. The internal option is used in source code.
29b5260
to
40942a0
Compare
584e31c
to
99247b1
Compare
99247b1
to
31ecc5d
Compare
Personally, I think I'd either have a single shared symbol in The main motivation is to avoid complicated multiple definition stuff where not many people know how it works (and that's easy to get wrong re. dependencies). I won't block anything here though, so go with whatever you prefer. :) Please also check how things look in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ioannisg note that you still have in this branch the sanitycheck hotfix which is already in master (I do not understand why github is not complaining about the conflict and let's one press the button..) Please disregard this review on your own when you fix it (no need to ping me back)
The commit is present because I did not rebase. |
31ecc5d
to
4c70ad7
Compare
a81becb
to
833dfeb
Compare
@ulfalizer I finally went along with your preference here, i.e. removed the internal option, and added the ARMv8-M specific explanatory text in the |
We introduce MPU_GAP_FILLING Kconfig option that instructs the MPU driver to enforce a full SRAM partitioning, when it programs the dynamic MPU regions (user thread stack, PRIV stack guard and application memory domains) at context-switch. We allow this to be configurable, in order to increase the number of MPU regions available for application memory domain programming. This option is introduced in arch/Kconfig, as it is expected to serve as a cross-ARCH symbol. The option can be set by the user during build configuration. By not enforcing full partition, we may leave part of kernel SRAM area covered only by the default ARM memory map. This is fine for User Mode, since the background ARM map does not allow nPRIV access at all. The difference is that kernel code will be able to attempt fetching instructions from kernel SRAM area without this leading directly to a MemManage exception. Since this does not compromize User Mode, we make the skipping of full partitioning the default behavior for the ARMv8-M MPU driver. The application developer may be able to overwrite this. In the wake of this change we update the macro definitions in arm_core_mpu_dev.h that derive the maximum number of MPU regions for application memory domains. Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit moves the function mpu_configure_regions(.) from arm_mpu_v7_internal.h to arm_mpu.c. The function is to be used by the both ARMv7-M MPU driver, as well as the ARMv8-M MPU driver (when it behaves like the ARMv7-M driver). Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
We allow the run-time, full paritioning of the SRAM space by the ARMv8-M MPU driver to be an optional feature. Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
We add a new test-case for the mem_protect and userspace tests, to test the ARMv8-M MPU driver without the skipping of full SRAM partitioning (i.e. gap filling). Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
833dfeb
to
17e251f
Compare
Addresses #19067 for ARM.
It should be working atm.
I would like a review on the Kconfig symbol name I've used, and the default behavior.
I am also going to add a test of the feature,