-
Notifications
You must be signed in to change notification settings - Fork 23
Clear ARM64 instruction cache on mprotect exec #344
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4540,6 +4540,11 @@ int64_t sys_mprotect(guest_t *g, uint64_t addr, uint64_t length, int prot) | |
| return -LINUX_ENOMEM; | ||
| } | ||
| guest_region_set_prot(g, addr, mprot_end, prot); | ||
| if (prot & LINUX_PROT_EXEC) { | ||
| char *host_start = (char *) g->host_base + addr; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: In the high-VA branch the range passed to Prompt for AI agents |
||
| char *host_end = (char *) g->host_base + mprot_end; | ||
| __builtin___clear_cache(host_start, host_end); | ||
| } | ||
| return 0; | ||
| } | ||
| uint64_t mprot_off = addr - g->ipa_base; | ||
|
|
||
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.
P1: The icache flush is added only in the high-VA branch (
addr >= g->guest_size), but ordinary guest memory (text/heap/mmap belowguest_size, which is the 64 GiB to 1 TiB primary window where ART JIT buffers live) is handled by the secondmprot_offbranch below, which never calls__builtin___clear_cache. For any mprotect(PROT_EXEC) at a normal guest VA,sys_mprotectreturns without invalidating the instruction cache, so the stale-instruction bug the PR targets remains unfixed in the common case.Prompt for AI agents