-
Notifications
You must be signed in to change notification settings - Fork 291
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
shim: Flush the memory region from i-cache before execution #504
Conversation
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.
Thanks for the patch. I've a comment inline... since I'm asking for changes already, please also fixup the line lengths in your commit messages (I know we're not always great about this, but it's nicer to have 72 in body and not much over 50 in subject).
| @@ -1196,6 +1197,9 @@ handle_image (void *data, unsigned int datasize, | |||
|
|
|||
| CopyMem(buffer, data, context.SizeOfHeaders); | |||
|
|
|||
| /* Flush the instruction cache for the region holding the image */ | |||
| cache_invalidate(buffer, buffer + context.ImageSize); | |||
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 line and the line above suggest to me that the invalidation always occurs, while that's not what the function does.
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.
Thanks for the review @frozencemetery. Along with correcting the comment, what do you think about renaming the function maybe_cache_invalidate() or perhaps arch_cache_invalidate()?
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.
I've pushed a version w/ the arch_cache_invalidate() name, but open to other suggestions.
66c96ae
to
04aa103
Compare
Also done, thanks for the feedback! |
We've seen crashes in early GRUB code on an ARM Cortex-A72-based platform that point at seemingly harmless instructions. Flushing the i-cache of those instructions prior to executing has been shown to avoid the problem, which has parallels with this story: https://www.mail-archive.com/osv-dev@googlegroups.com/msg06203.html Add a cache flushing utility function and provide an implementation using a GCC intrinsic. This will need to be extended to support other compilers. Note that this intrinsic is a no-op for x86 platforms. This fixes issue rhboot#498. Signed-off-by: dann frazier <dann.frazier@canonical.com>
04aa103
to
812ad99
Compare
|
I've pushed a new version due to feedback at rhboot/grub2#107 (comment)
fyi, I tested with clang as well, and found that it does define |
|
I've pushed this as 5c537b3, which is just organized a bit differently. |
…ing it
We've seen crashes in early GRUB code on an ARM Cortex-A72-based platform
that point at seemingly harmless instructions. Flushing the i-cache of
those instructions prior to executing seems to work fine, which seems to
have parallels with this story:
https://www.mail-archive.com/osv-dev@googlegroups.com/msg06203.html
Add a cache flushing utility function that is a no-op for !arm64, and
and provide an implementation using a GCC intrinsic.
This fixes issue #498.
Signed-off-by: dann frazier dann.frazier@canonical.com