Skip to content

Commit

Permalink
actually clear tf
Browse files Browse the repository at this point in the history
  • Loading branch information
0vercl0k committed Feb 28, 2025
1 parent 3742c7a commit d11279c
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/wtf/whv_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,9 @@ WhvBackend_t::OnDebugTrap(const WHV_RUN_VP_EXIT_CONTEXT &Exception) {
// to continue execution.
//

WhvDebugPrint("Received debug trap @ {:#x}\n", Exception.VpContext.Rip);
const auto Rflags = Exception.VpContext.Rflags & (~RFLAGS_TRAP_FLAG_FLAG);
const auto Rip = Exception.VpContext.Rip;
WhvDebugPrint("Received debug trap @ {:#x}\n", Rip);

if (TraceType_ == TraceType_t::Rip) {

Expand All @@ -1138,8 +1140,8 @@ WhvBackend_t::OnDebugTrap(const WHV_RUN_VP_EXIT_CONTEXT &Exception) {
return Hr;
}

LastTF_ = Exception.VpContext.Rip;
fmt::print(TraceFile_, "{:#x}\n", Exception.VpContext.Rip);
LastTF_ = Rip;
fmt::print(TraceFile_, "{:#x}\n", Rip);
}

//
Expand Down Expand Up @@ -1173,14 +1175,10 @@ WhvBackend_t::OnDebugTrap(const WHV_RUN_VP_EXIT_CONTEXT &Exception) {
// Either strip off or turn on TF.
//

if (TraceType_ == TraceType_t::Rip) {
WhvDebugPrint("Turning on RFLAGS.TF\n");
return SetReg64(WHvX64RegisterRflags,
Exception.VpContext.Rflags | RFLAGS_TRAP_FLAG_FLAG);
} else {
WhvDebugPrint("Turning off RFLAGS.TF\n");
return S_OK;
}
const bool Arm = TraceType_ == TraceType_t::Rip;
WhvDebugPrint("Turning {} RFLAGS.TF\n", Arm ? "on" : "off");
return SetReg64(WHvX64RegisterRflags,
Rflags | (Arm ? RFLAGS_TRAP_FLAG_FLAG : 0));
}

HRESULT
Expand Down

0 comments on commit d11279c

Please sign in to comment.