Skip to content

Invalidate CPU I-cache on Apple Silicon#259

Merged
SChernykh merged 1 commit into
tevador:masterfrom
SChernykh:fix_invalidate_order
Dec 17, 2022
Merged

Invalidate CPU I-cache on Apple Silicon#259
SChernykh merged 1 commit into
tevador:masterfrom
SChernykh:fix_invalidate_order

Conversation

@SChernykh

Copy link
Copy Markdown
Collaborator

Call sys_icache_invalidate() after pthread_jit_write_protect_np() according to https://developer.apple.com/documentation/apple-silicon/porting-just-in-time-compilers-to-apple-silicon

@hyc

hyc commented Nov 30, 2022

Copy link
Copy Markdown
Collaborator

This issue keeps coming up a lot. Just a reminder (for future reference): we're already using the gcc/clang __builtin___clear_cache() and on MacOS that is simply a call to sys_icache_invalidate(). So the real question to answer is, do we have enough of those __builtin___clear_cache() invocations, in the right places?

Example clang implementation: https://codebrowser.dev/llvm/compiler-rt/lib/builtins/clear_cache.c.html

Comment thread src/virtual_memory.c Outdated
@SChernykh SChernykh force-pushed the fix_invalidate_order branch from 9ab7d58 to 7245f13 Compare November 30, 2022 12:26

@hyc hyc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving, even though it seems this isn't fixing any crashes. It is at least following the letter of the Apple docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants