-
Notifications
You must be signed in to change notification settings - Fork 20
Extables #220
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
Extables #220
Conversation
| { | ||
| __start_extables = .; | ||
| *(.extables) | ||
| __stop_extables = .; |
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.
Very nice catch. Thanks!
| #include <mm/regions.h> | ||
|
|
||
| void init_extables(void) { | ||
| for (extable_entry_t *cur = __start_extables; cur < __stop_extables; ++cur) { |
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.
Good idea to have them sanity checked. Thanks!
Next step could be to sort them and use bsearch to speed up lookup.
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.
Right now we've only like 8 entries, so a linear search should still be fast enough. ;) But yeah, when we get more users and especially ones in hot code, speeding up the search might make sense.
| use_extables(regs); | ||
| if (extables_fixup(regs)) | ||
| return; |
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.
Ugh... Thanks!
Change the type of the __{start,end}_* markers to unsigned char so
pointer diff does "The Right Thing"™, i.e. give the byte difference,
not the object count difference.
Signed-off-by: Mathias Krause <[email protected]>
The extables handling is broken as in not being able to handle exceptions gracefully. They'll all end up in a panic, which is probably not intended. Make use_extables() return a boolean that tells if the exception was handled or not. If it was, we can simply return from the exception handler and continue execution. Also don't support doing both, a fixup IP and a callback. Only do one and prefer the fixup IP which is currently the only use case. Last, but not least, use the oppurtunity to rename the function to extables_fixup(), as that's what it does: fixing up the exception. Signed-off-by: Mathias Krause <[email protected]>
We round up the extables array to a multiple of 4kB. However, this leads to empty extable entries, i.e. entries for NULL ptr faults without a fixup IP nor a callback. To avoid bogus handling of these, introduce a new symbol __stop_extables[] that points to the end of legitimate extable entries. Leave __end_extables[] as is to lower the amount of code churn. However, change its type to unsigned char to avoid and flag accidental misuse. Signed-off-by: Mathias Krause <[email protected]>
Some headers lack explicit includes for #defines / types they use. Add these to avoid these implicit include dependencies. Signed-off-by: Mathias Krause <[email protected]>
Ensure all entries have a fixup IP or a callback. Panic if an entry lacks both. Signed-off-by: Mathias Krause <[email protected]>
Head branch was pushed to by a user without write access
This PR fixes the extable handling as in not triggering a panic or handling NULL pointer dereferences in an endless loop. E.g. when booting on a VM with too little memory we'll now fail gracefully instead of looping in exception handling:
Boilerplate disclamer follows:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.