From 2a8de5f7333de3fd50c6dddefad5123772ec550c Mon Sep 17 00:00:00 2001 From: MerryMage Date: Tue, 5 Jun 2018 13:05:41 +0100 Subject: [PATCH] a64_emit_x64: Clear exclusive state in EmitA64CallSupervisor The kernel would have to execute an ERET instruction to return to userland; this clears exclusive state. --- src/backend_x64/a64_emit_x64.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/backend_x64/a64_emit_x64.cpp b/src/backend_x64/a64_emit_x64.cpp index 7079bad1..54c4163c 100644 --- a/src/backend_x64/a64_emit_x64.cpp +++ b/src/backend_x64/a64_emit_x64.cpp @@ -486,6 +486,8 @@ void A64EmitX64::EmitA64CallSupervisor(A64EmitContext& ctx, IR::Inst* inst) { DEVIRT(conf.callbacks, &A64::UserCallbacks::CallSVC).EmitCall(code, [&](RegList param) { code.mov(param[0], imm); }); + // The kernel would have to execute ERET to get here, which would clear exclusive state. + code.mov(code.byte[r15 + offsetof(A64JitState, exclusive_state)], u8(0)); } void A64EmitX64::EmitA64ExceptionRaised(A64EmitContext& ctx, IR::Inst* inst) {