Implemented arch_debug_call_with_fault_handler for x86_64.
This commit is contained in:
@@ -260,3 +260,50 @@ FUNCTION(arch_cpu_user_strlcpy):
|
|||||||
movq $-1, %rax
|
movq $-1, %rax
|
||||||
ret
|
ret
|
||||||
FUNCTION_END(arch_cpu_user_strlcpy)
|
FUNCTION_END(arch_cpu_user_strlcpy)
|
||||||
|
|
||||||
|
|
||||||
|
/*! \fn void arch_debug_call_with_fault_handler(cpu_ent* cpu,
|
||||||
|
jmp_buf jumpBuffer, void (*function)(void*), void* parameter)
|
||||||
|
|
||||||
|
Called by debug_call_with_fault_handler() to do the dirty work of setting
|
||||||
|
the fault handler and calling the function. If the function causes a page
|
||||||
|
fault, the arch_debug_call_with_fault_handler() calls longjmp() with the
|
||||||
|
given \a jumpBuffer. Otherwise it returns normally.
|
||||||
|
|
||||||
|
debug_call_with_fault_handler() has already saved the CPU's fault_handler
|
||||||
|
and fault_handler_stack_pointer and will reset them later, so
|
||||||
|
arch_debug_call_with_fault_handler() doesn't need to care about it.
|
||||||
|
|
||||||
|
\param cpu The \c cpu_ent for the current CPU.
|
||||||
|
\param jumpBuffer Buffer to be used for longjmp().
|
||||||
|
\param function The function to be called.
|
||||||
|
\param parameter The parameter to be passed to the function to be called.
|
||||||
|
*/
|
||||||
|
FUNCTION(arch_debug_call_with_fault_handler):
|
||||||
|
push %rbp
|
||||||
|
movq %rsp, %rbp
|
||||||
|
|
||||||
|
// Preserve the jump buffer address for the fault return.
|
||||||
|
push %rsi
|
||||||
|
|
||||||
|
// Set fault handler address, and fault handler stack pointer address. We
|
||||||
|
// don't need to save the previous values, since that's done by the caller.
|
||||||
|
movq $.L_debug_call_fault_handler, CPU_ENT_fault_handler(%rdi)
|
||||||
|
movq %rbp, CPU_ENT_fault_handler_stack_pointer(%rdi)
|
||||||
|
|
||||||
|
// Call the function.
|
||||||
|
movq %rcx, %rdi
|
||||||
|
call *%rdx
|
||||||
|
|
||||||
|
// Regular return.
|
||||||
|
movq %rbp, %rsp
|
||||||
|
pop %rbp
|
||||||
|
ret
|
||||||
|
|
||||||
|
.L_debug_call_fault_handler:
|
||||||
|
// Fault -- return via longjmp(jumpBuffer, 1)
|
||||||
|
movq %rbp, %rsp
|
||||||
|
movq -8(%rsp), %rdi
|
||||||
|
movq $1, %rsi
|
||||||
|
call longjmp
|
||||||
|
FUNCTION_END(arch_debug_call_with_fault_handler)
|
||||||
|
|||||||
@@ -51,16 +51,6 @@ arch_commpage_init_post_cpus(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
arch_debug_call_with_fault_handler(cpu_ent* cpu, jmp_buf jumpBuffer,
|
|
||||||
void (*function)(void*), void* parameter)
|
|
||||||
{
|
|
||||||
// To be implemented in asm, not here.
|
|
||||||
|
|
||||||
function(parameter);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// The software breakpoint instruction (int3).
|
// The software breakpoint instruction (int3).
|
||||||
const uint8 kX86SoftwareBreakpoint[1] = { 0xcc };
|
const uint8 kX86SoftwareBreakpoint[1] = { 0xcc };
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user