staticvoid sigtrap(int sig, siginfo_t *info, void *ctx_void)
{ /* * KVM has some bugs that can cause us to stop making progress. * detect them and complain, but don't infinite loop or fail the * test.
*/
if (*ip == 0x340f || *ip == 0x050f) { /* The trap was on SYSCALL or SYSENTER */
sigtrap_consecutive_syscalls++; if (sigtrap_consecutive_syscalls > 3) {
printf("[WARN]\tGot stuck single-stepping -- you probably have a KVM bug\n");
siglongjmp(jmpbuf, 1);
}
} else {
sigtrap_consecutive_syscalls = 0;
}
}
if (*ip == 0x0b0f) { /* one of the ud2 instructions faulted */
printf("[OK]\tSYSCALL returned normally\n");
} else {
printf("[SKIP]\tIllegal instruction\n");
}
siglongjmp(jmpbuf, 1);
}
sethandler(SIGSEGV, sigsegv_or_sigbus, SA_ONSTACK); /* * The actual exception can vary. On Atom CPUs, we get #SS * instead of #PF when the vDSO fails to access the stack when * ESP is too close to 2^32, and #SS causes SIGBUS.
*/
sethandler(SIGBUS, sigsegv_or_sigbus, SA_ONSTACK);
sethandler(SIGILL, sigill, SA_ONSTACK);
/* * Exercise another nasty special case. The 32-bit SYSCALL * and SYSENTER instructions (even in compat mode) each * clobber one register. A Linux system call has a syscall * number and six arguments, and the user stack pointer * needs to live in some register on return. That means * that we need eight registers, but SYSCALL and SYSENTER * only preserve seven registers. As a result, one argument * ends up on the stack. The stack is user memory, which * means that the kernel can fail to read it. * * The 32-bit fast system calls don't have a defined ABI: * we're supposed to invoke them through the vDSO. So we'll * fudge it: we set all regs to invalid pointer values and * invoke the entry instruction. The return will fail no * matter what, and we completely lose our program state, * but we can fix it up with a signal handler.
*/
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.