This commit is contained in:
lizzie 2026-02-14 05:42:18 +00:00
parent 7361124602
commit 3b4b6976b6
1 changed files with 4 additions and 6 deletions

View File

@ -47,8 +47,8 @@ void* ArmNce::RestoreGuestContext(void* raw_context) {
auto* tpidr = reinterpret_cast<NativeExecutionParameters*>(CTX_X(9)); auto* tpidr = reinterpret_cast<NativeExecutionParameters*>(CTX_X(9));
auto* guest_ctx = static_cast<GuestContext*>(tpidr->native_context); auto* guest_ctx = static_cast<GuestContext*>(tpidr->native_context);
// Save host callee-saved registers. // Save host callee-saved registers.
std::memcpy(guest_ctx->host_ctx.host_saved_vregs.data(), &CTX_Q(8), std::memcpy(guest_ctx->host_ctx.host_saved_regs.data(), &CTX_X(19), sizeof(guest_ctx->host_ctx.host_saved_regs));
sizeof(guest_ctx->host_ctx.host_saved_vregs)); std::memcpy(guest_ctx->host_ctx.host_saved_vregs.data(), &CTX_Q(8), sizeof(guest_ctx->host_ctx.host_saved_vregs));
// Save stack pointer. // Save stack pointer.
guest_ctx->host_ctx.host_sp = CTX_SP; guest_ctx->host_ctx.host_sp = CTX_SP;
CTX_PC = guest_ctx->sp; CTX_PC = guest_ctx->sp;
@ -76,10 +76,8 @@ void ArmNce::SaveGuestContext(GuestContext* guest_ctx, void* raw_context) {
CTX_SP = guest_ctx->host_ctx.host_sp; CTX_SP = guest_ctx->host_ctx.host_sp;
// Restore host callee-saved registers. // Restore host callee-saved registers.
std::memcpy(&CTX_X(19), guest_ctx->host_ctx.host_saved_regs.data(), std::memcpy(&CTX_X(19), guest_ctx->host_ctx.host_saved_regs.data(), sizeof(guest_ctx->host_ctx.host_saved_regs));
sizeof(guest_ctx->host_ctx.host_saved_regs)); std::memcpy(&CTX_Q(8), guest_ctx->host_ctx.host_saved_vregs.data(), sizeof(guest_ctx->host_ctx.host_saved_vregs));
std::memcpy(&CTX_Q(8), guest_ctx->host_ctx.host_saved_vregs.data(),
sizeof(guest_ctx->host_ctx.host_saved_vregs));
// Return from the call on exit by setting pc to x30. // Return from the call on exit by setting pc to x30.
CTX_PC = guest_ctx->host_ctx.host_saved_regs[11]; CTX_PC = guest_ctx->host_ctx.host_saved_regs[11];
// Clear esr_el1 and return it. // Clear esr_el1 and return it.