-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
merge gen_kobject_list.py and gen_priv_stacks.py #19588
merge gen_kobject_list.py and gen_priv_stacks.py #19588
Conversation
Some checks failed. Please fix and resubmit. Gitlint issuesCommit d60c4ea63d: Commit ee56a94f79: Commit 8ebf651f48: checkpatch issues
pylint issues
Identity/Emails issuesd60c4ea63dee5d5a34d3ec42a0c929a86668ef98: author email (camicarballo camigcarballo@gmail.com) needs to match one of the signed-off-by entries. ee56a94f799362ce5f6ccdd10c9a1c3d01ba4029: author email (camicarballo camigcarballo@gmail.com) needs to match one of the signed-off-by entries. 8ebf651f48c9805fbdc2c7b424e34d64e0fe022b: author email (Cami Carballo cami.carballo@intel.com) needs to match one of the signed-off-by entries. Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages. |
6148f12
to
77e68db
Compare
77e68db
to
4cd29ff
Compare
priv_stacks_output_obj_renamed_lib | ||
priv_stacks_output_obj_renamed | ||
) | ||
## Warning most of this gperf code is duplicated below for |
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.
don't comment out -- just delete it
@@ -76,6 +78,9 @@ def __init__(self, type_obj, addr): | |||
elif self.type_obj.name == "k_futex": | |||
self.data = "(u32_t)(&futex_data[%d])" % futex_counter | |||
futex_counter += 1 | |||
elif self.type_obj.name == "_k_thread_stack_element": |
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.
this looks right
parser.add_argument( | ||
"-g", "--gperf-output", required=False, |
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.
why was this changed?
#create privilege stack for each K_OBJ__THREAD_STACK_ELEMENT | ||
if is_stack and priv_stacks: | ||
if stack != 0: | ||
priv_stacks += ", K_THREAD_STACK_DEFINE(stack_data[%d], %d)" % (stack, ko.data) |
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.
You've already declared the privilege elevation stack buffer at line 169, this isn't what you need to do here.
Let's say there is a stack object at address 0x2001000 of size 8192 inside the kernel. Below is an example on how this could be wired up. Your code doesn't have to be exactly like this, but this should be the gist of it:
First, you need to generate the privilege stack:
static u8_t __used __aligned(Z_PRIVILEGE_STACK_ALIGN) priv_stack_20010000[CONFIG_PRIVILEGED_STACK_SIZE];
You need to generate a metadata struct:
/* Put this struct definition in kernel.h next to _k_object definition */
struct z_stack_metadata {
u8_t *privilege_stack;
size_t stack_size;
}
static z_stack_metadata stack_metadata_20010000 = {
.privilege_stack = &priv_stack_20010000,
.size = 8192
};
And then in the gperf table, an entry:
{(char *)0x20010000, {}, K_OBJ__THREAD_STACK_ELEMENT, 0, (u32_t)&stack_metadata_20010000},
Then, provide a replacement for z_priv_stack_find() which just looks up the kobject and fetches the priv stack pointer from its linked metadata struct.
You'll also have to find all the places which are currently looking at the data value for the stack size, since the data value is now a pointer to the metadata and not the stack size itself, I think it's just thread.c:583, possibly some tests.
Finally, generation of privilege stacks needs to be optional, controlled by a flag. Currently X86 and ARC do not generate separate privilege stacks, they just roll it into the main stack object. We want to change this, but doesn't need to be in this PR. If privilege stack generation isn't enabled, continue to generate the metadata struct, but leave the .privilege_stack member NULL.
fixed in #23429 |
Fixes #15304