Fix A32-on-A64 for Apple Silicon

Unpatch is called from InvalidateBasicBlocks, which has temporarily
enabled writing, and thus disabled execution. However, the fast dispatch
lookup code is dynamically generated just like the rest of the JITed
output and so also is currently not executable. Thus we must temporarily
disable writing, and thus re-enable execution, whilst we run the lookup
function, otherwise we will fault on jumping to it.
This commit is contained in:
Jessica Clarke 2021-05-13 02:33:10 +01:00
parent 707ae88153
commit bef990b74e

View File

@ -1584,6 +1584,9 @@ void A32EmitA64::EmitPatchMovX0(CodePtr target_code_ptr) {
void A32EmitA64::Unpatch(const IR::LocationDescriptor& location) {
EmitA64::Unpatch(location);
if (config.enable_fast_dispatch) {
code.DisableWriting();
SCOPE_EXIT { code.EnableWriting(); };
(*fast_dispatch_table_lookup)(location.Value()) = {};
}
}