Commit 7d356ac4 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[Liftoff] Implement retpoline for indirect calls

As SSCA mitigation, use retpoline for each indirect call. We currently
only support retpolines on ia32 and x64.

R=titzer@chromium.org

Bug: v8:6600, chromium:798964
Change-Id: I32472c15e149977b00bf923f4d87e259b7b54800
Reviewed-on: https://chromium-review.googlesource.com/1052113Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53108}
parent c8ae9729
...@@ -1565,9 +1565,11 @@ void LiftoffAssembler::CallRuntime(Zone* zone, Runtime::FunctionId fid) { ...@@ -1565,9 +1565,11 @@ void LiftoffAssembler::CallRuntime(Zone* zone, Runtime::FunctionId fid) {
void LiftoffAssembler::CallIndirect(wasm::FunctionSig* sig, void LiftoffAssembler::CallIndirect(wasm::FunctionSig* sig,
compiler::CallDescriptor* call_descriptor, compiler::CallDescriptor* call_descriptor,
Register target) { Register target) {
if (target == no_reg) { // Since we have more cache registers than parameter registers, the
add(esp, Immediate(kPointerSize)); // {LiftoffCompiler} should always be able to place {target} in a register.
call(Operand(esp, -4)); DCHECK(target.is_valid());
if (FLAG_untrusted_code_mitigations) {
RetpolineCall(target);
} else { } else {
call(target); call(target);
} }
......
...@@ -1422,7 +1422,11 @@ void LiftoffAssembler::CallIndirect(wasm::FunctionSig* sig, ...@@ -1422,7 +1422,11 @@ void LiftoffAssembler::CallIndirect(wasm::FunctionSig* sig,
popq(kScratchRegister); popq(kScratchRegister);
target = kScratchRegister; target = kScratchRegister;
} }
if (FLAG_untrusted_code_mitigations) {
RetpolineCall(target);
} else {
call(target); call(target);
}
} }
void LiftoffAssembler::AllocateStackSlot(Register addr, uint32_t size) { void LiftoffAssembler::AllocateStackSlot(Register addr, uint32_t size) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment