{a32,a64}_emit_x64: Fix fast_dispatch_table_lookup call in Unpatch on W^X systems
fast_dispatch_table_lookup is in JITted code, and thus execution must be enabled before it can be called.
This commit is contained in:
parent
0a98e5d3d7
commit
8235de9829
2 changed files with 9 additions and 9 deletions
|
@ -1680,7 +1680,9 @@ void A32EmitX64::EmitPatchMovRcx(CodePtr target_code_ptr) {
|
||||||
void A32EmitX64::Unpatch(const IR::LocationDescriptor& location) {
|
void A32EmitX64::Unpatch(const IR::LocationDescriptor& location) {
|
||||||
EmitX64::Unpatch(location);
|
EmitX64::Unpatch(location);
|
||||||
if (conf.HasOptimization(OptimizationFlag::FastDispatch)) {
|
if (conf.HasOptimization(OptimizationFlag::FastDispatch)) {
|
||||||
|
code.DisableWriting();
|
||||||
(*fast_dispatch_table_lookup)(location.Value()) = {};
|
(*fast_dispatch_table_lookup)(location.Value()) = {};
|
||||||
|
code.EnableWriting();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ A64EmitX64::A64EmitX64(BlockOfCode& code, A64::UserConfig conf, A64::Jit* jit_in
|
||||||
code.PreludeComplete();
|
code.PreludeComplete();
|
||||||
ClearFastDispatchTable();
|
ClearFastDispatchTable();
|
||||||
|
|
||||||
exception_handler.SetFastmemCallback([this](u64 rip_){
|
exception_handler.SetFastmemCallback([this](u64 rip_) {
|
||||||
return FastmemCallback(rip_);
|
return FastmemCallback(rip_);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -990,8 +990,7 @@ void A64EmitX64::EmitMemoryRead(A64EmitContext& ctx, IR::Inst* inst) {
|
||||||
Common::BitCast<u64>(code.getCurr()),
|
Common::BitCast<u64>(code.getCurr()),
|
||||||
Common::BitCast<u64>(wrapped_fn),
|
Common::BitCast<u64>(wrapped_fn),
|
||||||
*fastmem_marker,
|
*fastmem_marker,
|
||||||
}
|
});
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
// Use page table
|
// Use page table
|
||||||
ASSERT(conf.page_table);
|
ASSERT(conf.page_table);
|
||||||
|
@ -1045,8 +1044,7 @@ void A64EmitX64::EmitMemoryWrite(A64EmitContext& ctx, IR::Inst* inst) {
|
||||||
Common::BitCast<u64>(code.getCurr()),
|
Common::BitCast<u64>(code.getCurr()),
|
||||||
Common::BitCast<u64>(wrapped_fn),
|
Common::BitCast<u64>(wrapped_fn),
|
||||||
*fastmem_marker,
|
*fastmem_marker,
|
||||||
}
|
});
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
// Use page table
|
// Use page table
|
||||||
ASSERT(conf.page_table);
|
ASSERT(conf.page_table);
|
||||||
|
@ -1114,8 +1112,7 @@ void A64EmitX64::EmitA64ReadMemory128(A64EmitContext& ctx, IR::Inst* inst) {
|
||||||
Common::BitCast<u64>(code.getCurr()),
|
Common::BitCast<u64>(code.getCurr()),
|
||||||
Common::BitCast<u64>(wrapped_fn),
|
Common::BitCast<u64>(wrapped_fn),
|
||||||
*fastmem_marker,
|
*fastmem_marker,
|
||||||
}
|
});
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
// Use page table
|
// Use page table
|
||||||
ASSERT(conf.page_table);
|
ASSERT(conf.page_table);
|
||||||
|
@ -1187,8 +1184,7 @@ void A64EmitX64::EmitA64WriteMemory128(A64EmitContext& ctx, IR::Inst* inst) {
|
||||||
Common::BitCast<u64>(code.getCurr()),
|
Common::BitCast<u64>(code.getCurr()),
|
||||||
Common::BitCast<u64>(wrapped_fn),
|
Common::BitCast<u64>(wrapped_fn),
|
||||||
*fastmem_marker,
|
*fastmem_marker,
|
||||||
}
|
});
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
// Use page table
|
// Use page table
|
||||||
ASSERT(conf.page_table);
|
ASSERT(conf.page_table);
|
||||||
|
@ -1481,7 +1477,9 @@ void A64EmitX64::EmitPatchMovRcx(CodePtr target_code_ptr) {
|
||||||
void A64EmitX64::Unpatch(const IR::LocationDescriptor& location) {
|
void A64EmitX64::Unpatch(const IR::LocationDescriptor& location) {
|
||||||
EmitX64::Unpatch(location);
|
EmitX64::Unpatch(location);
|
||||||
if (conf.HasOptimization(OptimizationFlag::FastDispatch)) {
|
if (conf.HasOptimization(OptimizationFlag::FastDispatch)) {
|
||||||
|
code.DisableWriting();
|
||||||
(*fast_dispatch_table_lookup)(location.Value()) = {};
|
(*fast_dispatch_table_lookup)(location.Value()) = {};
|
||||||
|
code.EnableWriting();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue