Fixing stale code tlb after fetch-prot hook - #2365
Open
bwhitn wants to merge 1 commit into
Open
Conversation
Contributor
|
nice catch. I haven't run the test yet, but in general it looks good. Can you change the target branche to dev? |
Author
|
Done |
Contributor
|
Can you also rebase your branch to dev and remove the 3 unrelated commits? If you have problems you can also just create a new PR and cherry-pick your commit. |
bwhitn
force-pushed
the
fix-fetch-prot-tlb-refill
branch
from
July 15, 2026 07:05
eb8f246 to
4c1f7b9
Compare
Author
|
Sorry about that, I think it is good now. |
Contributor
|
LGTM |
Member
|
Looks good. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes a stale code TLB path after a handled
UC_HOOK_MEM_FETCH_PROTcallback.When a fetch-protection callback returns
true, Unicorn treats the access as handled and continues translation. The read/write protected paths already reload TLB state after a handled callback, but the fetch-protection path did not. If the callback changes permissions, for example:the translator can continue using stale fetch TLB state.
This patch re-checks that the page is still mapped and now executable after a handled fetch-protection callback, then refills the code TLB entry before instruction bytes are read.
I believe this fixes #1780 and is related to #1393.
Added regression test.