summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-01-14 22:13:02 (GMT)
committerH. Peter Anvin <hpa@zytor.com>2008-01-14 22:13:02 (GMT)
commit502c6bdd92e013384a9822ed1d91d6c6d533be52 (patch)
treedc46c8d2c1c74be29ab273b61e30a6e01574deaa
parentb76d86fdcd677dbeabf90f0ebe2e963b193c8d40 (diff)
downloadlpsm-502c6bdd92e013384a9822ed1d91d6c6d533be52.zip
lpsm-502c6bdd92e013384a9822ed1d91d6c6d533be52.tar.gz
lpsm-502c6bdd92e013384a9822ed1d91d6c6d533be52.tar.bz2
lpsm-502c6bdd92e013384a9822ed1d91d6c6d533be52.tar.xz
arena.c: clean up old i386-only hack for ancient Linux kernels
Hack for ancient Linux kernel was "dirty" on non-i386 platforms.
-rw-r--r--arena.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/arena.c b/arena.c
index da50254..a2b14bd 100644
--- a/arena.c
+++ b/arena.c
@@ -109,14 +109,13 @@ static void lpsm_sigsegv(int signal, siginfo_t *siginfo, void *ptr)
uintptr_t npage, offset;
char *pageinfo;
int old_errno = errno;
-#ifdef __linux__
- struct sigcontext *ctxt;
-
-# ifdef __i386__ /* This is so specific to Linux/i386 */
- /* Don't even begin to ask me where the 0x14 comes from */
- ctxt = (struct sigcontext *)((char *)ptr + 0x14);
+#if defined(__linux__) && defined(__i386__)
if ( siginfo->si_code == 0 ) {
+ struct sigcontext *ctxt;
+ /* Don't even begin to ask me where the 0x14 comes from */
+ ctxt = (struct sigcontext *)((char *)ptr + 0x14);
+
/* Old kernel. Fill in data to the best of our knowledge. */
if ( ctxt->trapno == 14 ) {
/* Linux/i386 uses unmapped pages to mimic PROT_NONE, so we can't
@@ -125,8 +124,7 @@ static void lpsm_sigsegv(int signal, siginfo_t *siginfo, void *ptr)
siginfo->si_addr = (void *)ctxt->cr2;
}
}
-# endif /* __i386__ */
-#endif /* __linux__ */
+#endif
page = (void *)((uintptr_t)siginfo->si_addr & ~(PM->pagesize-1));
offset = (uintptr_t)page - (uintptr_t)PM->arena;
@@ -142,13 +140,6 @@ static void lpsm_sigsegv(int signal, siginfo_t *siginfo, void *ptr)
dfl.sa_flags = SA_ONESHOT;
sigaction(SIGSEGV, &dfl, NULL);
-#ifdef __linux
-#ifdef __i386__
- /* Technically unsafe, but who cares at this point... */
- fprintf(stderr, "SIGSEGV at %p, %%eip = %p\n",
- siginfo->si_addr, (void *)ctxt->eip);
-#endif
-#endif
#ifdef PRINT_DEBUG_INFO
abort(); /* Easier to tell from SIGSEGV */
#endif