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

merge gen_kobject_list.py and gen_priv_stacks.py #19588

Conversation

keylime-unicorn
Copy link

Fixes #15304

@zephyrbot
Copy link
Collaborator

zephyrbot commented Oct 3, 2019

Some checks failed. Please fix and resubmit.

Gitlint issues

Commit d60c4ea63d:
1: UC2 Body does not contain a 'Signed-off-by:' line
1: UC3 Title does not follow [subsystem]: [subject] (and should not start with literal subsys:): "merge gen_kobject_list.py and gen_priv_stacks.py"
1: UC6 Body has no content, should at least have 1 line.
3: B6 Body message is missing

Commit ee56a94f79:
1: UC2 Body does not contain a 'Signed-off-by:' line
1: UC6 Body has no content, should at least have 1 line.
3: B6 Body message is missing

Commit 8ebf651f48:
1: UC2 Body does not contain a 'Signed-off-by:' line
1: UC3 Title does not follow [subsystem]: [subject] (and should not start with literal subsys:): "merge gen_kobject_list.py and gen_priv_stacks.py"
1: UC6 Body has no content, should at least have 1 line.
3: B6 Body message is missing

checkpatch issues

-:302: ERROR:TRAILING_WHITESPACE: trailing whitespace
#302: FILE: scripts/elf_helper.py:65:
+    $

-:426: ERROR:TRAILING_WHITESPACE: trailing whitespace
#426: FILE: scripts/gen_kobject_list.py:214:
+    $

-:508: ERROR:TRAILING_WHITESPACE: trailing whitespace
#508: FILE: scripts/gen_kobject_list.py:350:
+        fp.write('case %s: ret = sizeof(struct %s); break;\n' % $

-:549: ERROR:TRAILING_WHITESPACE: trailing whitespace
#549: FILE: scripts/gen_kobject_list.py:391:
+    $

-:559: ERROR:TRAILING_WHITESPACE: trailing whitespace
#559: FILE: scripts/gen_kobject_list.py:400:
+    $

-:565: ERROR:TRAILING_WHITESPACE: trailing whitespace
#565: FILE: scripts/gen_kobject_list.py:406:
+    $

- total: 6 errors, 0 warnings, 537 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

NOTE: Whitespace errors detected.
      You may wish to use scripts/cleanpatch or scripts/cleanfile

Your patch has style problems, please review.

NOTE: Ignored message types: AVOID_EXTERNS BRACES CONFIG_EXPERIMENTAL CONST_STRUCT DATE_TIME FILE_PATH_CHANGES MINMAX NETWORKING_BLOCK_COMMENT_STYLE PRINTK_WITHOUT_KERN_LEVEL SPLIT_STRING VOLATILE

NOTE: If any of the errors are false positives, please report
      them to the maintainers.

pylint issues

************* Module gen_kobject_list
scripts/gen_kobject_list.py:214:0: C0303: Trailing whitespace (trailing-whitespace)
scripts/gen_kobject_list.py:350:63: C0303: Trailing whitespace (trailing-whitespace)
scripts/gen_kobject_list.py:391:0: C0303: Trailing whitespace (trailing-whitespace)
scripts/gen_kobject_list.py:400:0: C0303: Trailing whitespace (trailing-whitespace)
scripts/gen_kobject_list.py:406:0: C0303: Trailing whitespace (trailing-whitespace)
************* Module elf_helper
scripts/elf_helper.py:65:0: C0303: Trailing whitespace (trailing-whitespace)

Identity/Emails issues

d60c4ea63dee5d5a34d3ec42a0c929a86668ef98: author email (camicarballo camigcarballo@gmail.com) needs to match one of the signed-off-by entries.
d60c4ea63dee5d5a34d3ec42a0c929a86668ef98: author email (camicarballo camigcarballo@gmail.com) does not follow the syntax: First Last .

ee56a94f799362ce5f6ccdd10c9a1c3d01ba4029: author email (camicarballo camigcarballo@gmail.com) needs to match one of the signed-off-by entries.
ee56a94f799362ce5f6ccdd10c9a1c3d01ba4029: author email (camicarballo camigcarballo@gmail.com) does not follow the syntax: First Last .

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.

priv_stacks_output_obj_renamed_lib
priv_stacks_output_obj_renamed
)
## Warning most of this gperf code is duplicated below for
Copy link
Contributor

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":
Copy link
Contributor

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,
Copy link
Contributor

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)
Copy link
Contributor

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.

@nashif
Copy link
Member

nashif commented Mar 12, 2020

fixed in #23429

@nashif nashif closed this Mar 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

merge gen_kobject_list.py and gen_priv_stacks.py
4 participants