aboutsummaryrefslogtreecommitdiffstats
path: root/mps/code
diff options
context:
space:
mode:
authorRichard Brooksby2012-08-13 13:53:20 +0100
committerRichard Brooksby2012-08-13 13:53:20 +0100
commitaffc709f2598a9952711be7f5d8c5aeb2bfc4422 (patch)
treecc474f55fcc9363ef5c03c10cc71997e44920979 /mps/code
parent8875cbfba9d7d48a001f87bfa27b60ca485f7fa3 (diff)
parent0720be47b8bf3aa1d7e8d3bc1636b2dad59e8a3c (diff)
downloademacs-affc709f2598a9952711be7f5d8c5aeb2bfc4422.tar.gz
emacs-affc709f2598a9952711be7f5d8c5aeb2bfc4422.zip
Merging 64-bit linux port from branch/2012-07-26/linux-catchup
Copied from Perforce Change: 178913 ServerID: perforce.ravenbrook.com
Diffstat (limited to 'mps/code')
-rw-r--r--mps/code/lii4gc.gmk2
-rw-r--r--mps/code/lii6gc.gmk71
-rw-r--r--mps/code/mps.c17
-rw-r--r--mps/code/mpstd.h17
-rw-r--r--mps/code/prmci6li.c123
-rw-r--r--mps/code/protlii6.c180
-rw-r--r--mps/code/ssixi6.c19
-rw-r--r--mps/code/thli.c (renamed from mps/code/thlii4.c)18
8 files changed, 428 insertions, 19 deletions
diff --git a/mps/code/lii4gc.gmk b/mps/code/lii4gc.gmk
index 2eceecb9827..6ed66a21f85 100644
--- a/mps/code/lii4gc.gmk
+++ b/mps/code/lii4gc.gmk
@@ -5,7 +5,7 @@
5 5
6PFM = lii4gc 6PFM = lii4gc
7 7
8THREADSRC = lockli.c thlii4.c pthrdext.c 8THREADSRC = lockli.c thli.c pthrdext.c
9THREADLIB = -lpthread 9THREADLIB = -lpthread
10 10
11# _XOPEN_SOURCE is to get the modern POSIX signal handling 11# _XOPEN_SOURCE is to get the modern POSIX signal handling
diff --git a/mps/code/lii6gc.gmk b/mps/code/lii6gc.gmk
new file mode 100644
index 00000000000..d072f5f62fd
--- /dev/null
+++ b/mps/code/lii6gc.gmk
@@ -0,0 +1,71 @@
1# lii6gc.gmk: BUILD FOR LINUX/x64/GCC PLATFORM
2#
3# $Id$
4# Copyright (c) 2001 Ravenbrook Limited. See end of file for license.
5
6PFM = lii6gc
7
8THREADSRC = lockli.c thli.c pthrdext.c
9THREADLIB = -lpthread
10
11# _XOPEN_SOURCE is to get the modern POSIX signal handling
12# _GNU_SOURCE is to get register numbers in prmci3li.c
13PFMDEFS = -D_REENTRANT -D_XOPEN_SOURCE=500 -D_GNU_SOURCE
14
15MPMPF = ${THREADSRC} vmix.c \
16 protix.c protlii6.c proti6.c prmci6li.c ssixi6.c span.c
17SWPF = than.c vmli.c protsw.c prmcan.c ssan.c
18
19LIBS = -lm ${THREADLIB}
20
21include gc.gmk
22
23CC = cc
24
25# Suppress some warnings (SuSE).
26# .void: -Wpointer-arith cannot be used because the string.h header does
27# arithmetic on void*.
28CFLAGSCOMPILER := -pthread $(subst -Wpointer-arith,,$(CFLAGSCOMPILER))
29
30include comm.gmk
31
32
33# C. COPYRIGHT AND LICENSE
34#
35# Copyright (C) 2001-2002 Ravenbrook Limited <http://www.ravenbrook.com/>.
36# All rights reserved. This is an open source license. Contact
37# Ravenbrook for commercial licensing options.
38#
39# Redistribution and use in source and binary forms, with or without
40# modification, are permitted provided that the following conditions are
41# met:
42#
43# 1. Redistributions of source code must retain the above copyright
44# notice, this list of conditions and the following disclaimer.
45#
46# 2. Redistributions in binary form must reproduce the above copyright
47# notice, this list of conditions and the following disclaimer in the
48# documentation and/or other materials provided with the distribution.
49#
50# 3. Redistributions in any form must be accompanied by information on how
51# to obtain complete source code for this software and any accompanying
52# software that uses this software. The source code must either be
53# included in the distribution or be available for no more than the cost
54# of distribution plus a nominal fee, and must be freely redistributable
55# under reasonable conditions. For an executable file, complete source
56# code means the source code for all modules it contains. It does not
57# include source code for modules or files that typically accompany the
58# major components of the operating system on which the executable file
59# runs.
60#
61# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
62# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
63# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
64# PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE
65# COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
66# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
67# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
68# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
69# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
70# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
71# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/mps/code/mps.c b/mps/code/mps.c
index 83ed13a477c..b2ddd0d2c1f 100644
--- a/mps/code/mps.c
+++ b/mps/code/mps.c
@@ -124,7 +124,7 @@
124#elif defined(MPS_PF_LII4GC) 124#elif defined(MPS_PF_LII4GC)
125 125
126#include "lockli.c" /* Linux locks */ 126#include "lockli.c" /* Linux locks */
127#include "thlii4.c" /* Linux on 32-bit Intel threading */ 127#include "thli.c" /* Linux on 32-bit Intel threading */
128#include "pthrdext.c" /* Posix thread extensions */ 128#include "pthrdext.c" /* Posix thread extensions */
129#include "vmix.c" /* Posix virtual memory */ 129#include "vmix.c" /* Posix virtual memory */
130#include "protix.c" /* Posix protection */ 130#include "protix.c" /* Posix protection */
@@ -134,6 +134,21 @@
134#include "span.c" /* generic stack probe */ 134#include "span.c" /* generic stack probe */
135#include "ssixi3.c" /* Posix on 32-bit Intel stack scan */ 135#include "ssixi3.c" /* Posix on 32-bit Intel stack scan */
136 136
137/* Linux on 64-bit Intel with GCC */
138
139#elif defined(MPS_PF_LII6GC)
140
141#include "lockli.c" /* Linux locks */
142#include "thli.c" /* Linux on 32-bit Intel threading */
143#include "pthrdext.c" /* Posix thread extensions */
144#include "vmix.c" /* Posix virtual memory */
145#include "protix.c" /* Posix protection */
146#include "protlii6.c" /* Linux on 32-bit Intel protection */
147#include "proti6.c" /* 32-bit Intel mutator context */
148#include "prmci6li.c" /* 32-bit Intel for Linux mutator context */
149#include "span.c" /* generic stack probe */
150#include "ssixi6.c" /* Posix on 32-bit Intel stack scan */
151
137/* Windows on 32-bit Intel with Microsoft Visual Studio */ 152/* Windows on 32-bit Intel with Microsoft Visual Studio */
138 153
139#elif defined(MPS_PF_W3I3MV) 154#elif defined(MPS_PF_W3I3MV)
diff --git a/mps/code/mpstd.h b/mps/code/mpstd.h
index 423292c4b04..c6343b7db59 100644
--- a/mps/code/mpstd.h
+++ b/mps/code/mpstd.h
@@ -183,6 +183,23 @@
183#define MPS_WORD_SHIFT 5 183#define MPS_WORD_SHIFT 5
184#define MPS_PF_ALIGN 4 184#define MPS_PF_ALIGN 4
185 185
186/* GCC 4.6.3, gcc -E -dM */
187
188#elif defined(__linux__) && defined(__x86_64) && defined(__GNUC__)
189#if defined(CONFIG_PF_STRING) && ! defined(CONFIG_PF_LII6GC)
190#error "specified CONFIG_PF_... inconsistent with detected lii6gc"
191#endif
192#define MPS_PF_LII6GC
193#define MPS_PF_STRING "lii6gc"
194#define MPS_OS_LI
195#define MPS_ARCH_I6
196#define MPS_BUILD_GC
197#define MPS_T_WORD unsigned long
198#define MPS_T_ULONGEST unsigned long
199#define MPS_WORD_WIDTH 64
200#define MPS_WORD_SHIFT 6
201#define MPS_PF_ALIGN 8
202
186/* GCC 2.7.2, gcc -E -dM */ 203/* GCC 2.7.2, gcc -E -dM */
187 204
188#elif defined(__linux__) && defined(__PPC__) && defined(__GNUC__) 205#elif defined(__linux__) && defined(__PPC__) && defined(__GNUC__)
diff --git a/mps/code/prmci6li.c b/mps/code/prmci6li.c
new file mode 100644
index 00000000000..e81a7cfd750
--- /dev/null
+++ b/mps/code/prmci6li.c
@@ -0,0 +1,123 @@
1/* prmci6li.c: PROTECTION MUTATOR CONTEXT x64 (LINUX)
2 *
3 * $Id$
4 * Copyright (c) 2001 Ravenbrook Limited. See end of file for license.
5 *
6 * .purpose: This module implements the part of the protection module
7 * that decodes the MutatorFaultContext.
8 *
9 *
10 * SOURCES
11 *
12 * .source.linux.kernel: Linux kernel source files.
13 *
14 *
15 * ASSUMPTIONS
16 *
17 * .assume.regref: The resisters in the context can be modified by
18 * storing into an MRef pointer.
19 */
20
21#include "prmcix.h"
22#include "prmci6.h"
23
24SRCID(prmci6li, "$Id$");
25
26
27/* Prmci6AddressHoldingReg -- return an address of a register in a context */
28
29MRef Prmci6AddressHoldingReg(MutatorFaultContext mfc, unsigned int regnum)
30{
31 Word *gregs;
32
33 AVER(regnum <= 15);
34 AVER(regnum >= 0);
35
36 gregs = (Word *)&mfc->ucontext->uc_mcontext.gregs;
37
38 /* .assume.regref */
39 /* The REG_EAX etc. symbols are only present if _GNU_SOURCE is defined.
40 * Currently this is in lii6gc.gmk in PFMDEFS. */
41 switch (regnum) {
42 case 0: return &gregs[REG_RAX];
43 case 1: return &gregs[REG_RCX];
44 case 2: return &gregs[REG_RDX];
45 case 3: return &gregs[REG_RBX];
46 case 4: return &gregs[REG_RSP];
47 case 5: return &gregs[REG_RBP];
48 case 6: return &gregs[REG_RSI];
49 case 7: return &gregs[REG_RDI];
50 case 8: return &gregs[REG_R8];
51 case 9: return &gregs[REG_R9];
52 case 10: return &gregs[REG_R10];
53 case 11: return &gregs[REG_R11];
54 case 12: return &gregs[REG_R12];
55 case 13: return &gregs[REG_R13];
56 case 14: return &gregs[REG_R14];
57 case 15: return &gregs[REG_R15];
58 }
59 NOTREACHED;
60 return (MRef)NULL; /* Avoids compiler warning. */
61}
62
63
64/* Prmci3DecodeFaultContext -- decode fault to find faulting address and IP */
65
66void Prmci6DecodeFaultContext(MRef *faultmemReturn,
67 Byte **insvecReturn,
68 MutatorFaultContext mfc)
69{
70 /* .source.linux.kernel (linux/arch/x86/mm/fault.c). */
71 *faultmemReturn = (MRef)mfc->info->si_addr;
72 *insvecReturn = (Byte*)mfc->ucontext->uc_mcontext.gregs[REG_RIP];
73}
74
75
76/* Prmci3StepOverIns -- modify context to step over instruction */
77
78void Prmci6StepOverIns(MutatorFaultContext mfc, Size inslen)
79{
80 mfc->ucontext->uc_mcontext.gregs[REG_RIP] += (Word)inslen;
81}
82
83
84/* C. COPYRIGHT AND LICENSE
85 *
86 * Copyright (C) 2001-2002 Ravenbrook Limited <http://www.ravenbrook.com/>.
87 * All rights reserved. This is an open source license. Contact
88 * Ravenbrook for commercial licensing options.
89 *
90 * Redistribution and use in source and binary forms, with or without
91 * modification, are permitted provided that the following conditions are
92 * met:
93 *
94 * 1. Redistributions of source code must retain the above copyright
95 * notice, this list of conditions and the following disclaimer.
96 *
97 * 2. Redistributions in binary form must reproduce the above copyright
98 * notice, this list of conditions and the following disclaimer in the
99 * documentation and/or other materials provided with the distribution.
100 *
101 * 3. Redistributions in any form must be accompanied by information on how
102 * to obtain complete source code for this software and any accompanying
103 * software that uses this software. The source code must either be
104 * included in the distribution or be available for no more than the cost
105 * of distribution plus a nominal fee, and must be freely redistributable
106 * under reasonable conditions. For an executable file, complete source
107 * code means the source code for all modules it contains. It does not
108 * include source code for modules or files that typically accompany the
109 * major components of the operating system on which the executable file
110 * runs.
111 *
112 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
113 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
114 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
115 * PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE
116 * COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
117 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
118 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
119 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
120 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
121 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
122 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
123 */
diff --git a/mps/code/protlii6.c b/mps/code/protlii6.c
new file mode 100644
index 00000000000..e149d5269ed
--- /dev/null
+++ b/mps/code/protlii6.c
@@ -0,0 +1,180 @@
1/* protlii6.c: PROTECTION FOR LINUX (x64)
2 *
3 * $Id$
4 * Copyright (c) 2001 Ravenbrook Limited. See end of file for license.
5 *
6 * SOURCES
7 *
8 * .source.linux.kernel: Linux kernel source files.
9 */
10
11#include "prmcix.h"
12
13#ifndef MPS_OS_LI
14#error "protlii6.c is Linux-specific, but MPS_OS_LI is not set"
15#endif
16#if !defined(MPS_ARCH_I6)
17#error "protlii6.c is x64, but MPS_ARCH_I6 is not set"
18#endif
19#ifndef PROTECTION
20#error "protlii6.c implements protection, but PROTECTION is not set"
21#endif
22
23#include <limits.h>
24#include <stddef.h>
25#include <stdlib.h>
26#include <signal.h>
27#include <unistd.h>
28
29SRCID(protlii6, "$Id$");
30
31
32
33/* The previously-installed signal action, as returned by */
34/* sigaction(3). See ProtSetup. */
35
36static struct sigaction sigNext;
37
38
39/* sigHandle -- protection signal handler
40 *
41 * This is the signal handler installed by ProtSetup to deal with
42 * protection faults. It is installed on the SIGSEGV signal.
43 * It decodes the protection fault details from the signal context
44 * and passes them to ArenaAccess, which attempts to handle the
45 * fault and remove its cause. If the fault is handled, then
46 * the handler returns and execution resumes. If it isn't handled,
47 * then sigHandle does its best to pass the signal on to the
48 * previously installed signal handler (sigNext).
49 *
50 * .sigh.context: We check si_code for being a memory access
51 * si_addr gives the fault address. See
52 * .source.linux.kernel (linux/arch/x86/mm/fault.c).
53 *
54 * .sigh.addr: We assume that the OS decodes the address to something
55 * sensible
56 */
57/* This is defined here to keep the sources closer to those in protsgix.c
58 * They can't be merged yet because protsgix doesn't pass the context to
59 * ArenaAccess */
60
61#define PROT_SIGNAL SIGSEGV
62
63static void sigHandle(int sig, siginfo_t *info, void *context) /* .sigh.args */
64{
65 int e;
66 /* sigset renamed to asigset due to clash with global on Darwin. */
67 sigset_t asigset, oldset;
68 struct sigaction sa;
69
70 AVER(sig == PROT_SIGNAL);
71
72 if(info->si_code == SEGV_ACCERR) { /* .sigh.context */
73 AccessSet mode;
74 Addr base;
75 ucontext_t *ucontext;
76 MutatorFaultContextStruct mfContext;
77
78 ucontext = (ucontext_t *)context;
79 mfContext.ucontext = ucontext;
80 mfContext.info = info;
81
82 /* on linux we used to be able to tell whether this was a read or a write */
83 mode = AccessREAD | AccessWRITE;
84
85 /* We assume that the access is for one word at the address. */
86 base = (Addr)info->si_addr; /* .sigh.addr */
87 /* limit = AddrAdd(base, (Size)sizeof(Addr)); */
88
89 /* Offer each protection structure the opportunity to handle the */
90 /* exception. If it succeeds, then allow the mutator to continue. */
91
92 if(ArenaAccess(base, mode, &mfContext))
93 return;
94 }
95
96 /* The exception was not handled by any known protection structure, */
97 /* so throw it to the previously installed handler. That handler won't */
98 /* get an accurate context (the MPS would fail if it were the second in */
99 /* line) but it's the best we can do. */
100
101 e = sigaction(PROT_SIGNAL, &sigNext, &sa);
102 AVER(e == 0);
103 sigemptyset(&asigset);
104 sigaddset(&asigset, PROT_SIGNAL);
105 e = sigprocmask(SIG_UNBLOCK, &asigset, &oldset);
106 AVER(e == 0);
107 kill(getpid(), PROT_SIGNAL);
108 e = sigprocmask(SIG_SETMASK, &oldset, NULL);
109 AVER(e == 0);
110 e = sigaction(PROT_SIGNAL, &sa, NULL);
111 AVER(e == 0);
112}
113
114
115/* ProtSetup -- global protection setup
116 *
117 * Under Linux, the global setup involves installing a signal handler
118 * on SIGSEGV to catch and handle page faults (see sigHandle).
119 * The previous handler is recorded so that it can be reached from
120 * sigHandle if it fails to handle the fault.
121 *
122 * NOTE: There are problems with this approach:
123 * 1. we can't honor the sa_flags for the previous handler,
124 * 2. what if this thread is suspended just after calling signal(3)?
125 * The sigNext variable will never be initialized!
126 */
127
128void ProtSetup(void)
129{
130 struct sigaction sa;
131 int result;
132
133 sa.sa_sigaction = sigHandle;
134 sigemptyset(&sa.sa_mask);
135 sa.sa_flags = SA_SIGINFO;
136
137 result = sigaction(PROT_SIGNAL, &sa, &sigNext);
138 AVER(result == 0);
139}
140
141/* C. COPYRIGHT AND LICENSE
142 *
143 * Copyright (C) 2001-2002 Ravenbrook Limited <http://www.ravenbrook.com/>.
144 * All rights reserved. This is an open source license. Contact
145 * Ravenbrook for commercial licensing options.
146 *
147 * Redistribution and use in source and binary forms, with or without
148 * modification, are permitted provided that the following conditions are
149 * met:
150 *
151 * 1. Redistributions of source code must retain the above copyright
152 * notice, this list of conditions and the following disclaimer.
153 *
154 * 2. Redistributions in binary form must reproduce the above copyright
155 * notice, this list of conditions and the following disclaimer in the
156 * documentation and/or other materials provided with the distribution.
157 *
158 * 3. Redistributions in any form must be accompanied by information on how
159 * to obtain complete source code for this software and any accompanying
160 * software that uses this software. The source code must either be
161 * included in the distribution or be available for no more than the cost
162 * of distribution plus a nominal fee, and must be freely redistributable
163 * under reasonable conditions. For an executable file, complete source
164 * code means the source code for all modules it contains. It does not
165 * include source code for modules or files that typically accompany the
166 * major components of the operating system on which the executable file
167 * runs.
168 *
169 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
170 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
171 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
172 * PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE
173 * COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
174 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
175 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
176 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
177 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
178 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
179 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
180 */
diff --git a/mps/code/ssixi6.c b/mps/code/ssixi6.c
index 6732f850b3b..6b425bed804 100644
--- a/mps/code/ssixi6.c
+++ b/mps/code/ssixi6.c
@@ -1,4 +1,4 @@
1/* ssixi6.c: UNIX/INTEL STACK SCANNING 1/* ssixi6.c: UNIX/x64 STACK SCANNING
2 * 2 *
3 * $Id$ 3 * $Id$
4 * Copyright (c) 2001 Ravenbrook Limited. See end of file for license. 4 * Copyright (c) 2001 Ravenbrook Limited. See end of file for license.
@@ -49,22 +49,21 @@ SRCID(ssixi6, "$Id$");
49 49
50Res StackScan(ScanState ss, Addr *stackBot) 50Res StackScan(ScanState ss, Addr *stackBot)
51{ 51{
52 Addr calleeSaveRegs[6];
52 Addr *stackTop; 53 Addr *stackTop;
53 Res res; 54 Res res;
54 55
55 ASMV("push %rbp"); 56 ASMV("mov %%rbp, %0" : "=m" (calleeSaveRegs[0]));
56 ASMV("push %rbx"); 57 ASMV("mov %%rbx, %0" : "=m" (calleeSaveRegs[1]));
57 ASMV("push %r12"); 58 ASMV("mov %%r12, %0" : "=m" (calleeSaveRegs[2]));
58 ASMV("push %r13"); 59 ASMV("mov %%r13, %0" : "=m" (calleeSaveRegs[3]));
59 ASMV("push %r14"); 60 ASMV("mov %%r14, %0" : "=m" (calleeSaveRegs[4]));
60 ASMV("push %r15"); 61 ASMV("mov %%r15, %0" : "=m" (calleeSaveRegs[5]));
61 ASMV("mov %%rsp, %0" : "=r" (stackTop) :); /* stackTop = esp */ 62 ASMV("mov %%rsp, %0" : "=r" (stackTop) :); /* stackTop = rsp */
62 63
63 AVER(AddrIsAligned((Addr)stackTop, sizeof(Addr))); /* .assume.align */ 64 AVER(AddrIsAligned((Addr)stackTop, sizeof(Addr))); /* .assume.align */
64 res = TraceScanArea(ss, stackTop, stackBot); 65 res = TraceScanArea(ss, stackTop, stackBot);
65 66
66 ASMV("add $48, %rsp"); /* pop 6 regs to restore the stack pointer */
67
68 return res; 67 return res;
69} 68}
70 69
diff --git a/mps/code/thlii4.c b/mps/code/thli.c
index 4f96e9c5fb1..a486e9ab9b6 100644
--- a/mps/code/thlii4.c
+++ b/mps/code/thli.c
@@ -1,4 +1,4 @@
1/* thlii4.c: Threads Manager for Intel x86 systems with LinuxThreads 1/* thli.c: Threads Manager for LinuxThreads
2 * 2 *
3 * $Id$ 3 * $Id$
4 * Copyright (c) 2001 Ravenbrook Limited. See end of file for license. 4 * Copyright (c) 2001 Ravenbrook Limited. See end of file for license.
@@ -31,22 +31,26 @@
31 * but don't assume that the stack pointer is necessarily 31 * but don't assume that the stack pointer is necessarily
32 * word-aligned at the time of reading the context of another thread. 32 * word-aligned at the time of reading the context of another thread.
33 * 33 *
34 * .sp: The stack pointer in the context is ESP. 34 * .sp: The stack pointer in the context is uc_stack.ss_sp.
35 * .context.regroots: The root regs are EDI, ESI, EBX, EDX, ECX, EAX are 35 * .context.regroots: The root regs are
36 * assumed to be recorded in the context at pointer-aligned boundaries. 36 * assumed to be recorded in the context at pointer-aligned boundaries.
37 */ 37 */
38 38
39#include "prmcix.h" 39#include "prmcix.h"
40#include "mpm.h" 40#include "mpm.h"
41 41
42#if !defined(MPS_OS_LI) || !defined(MPS_ARCH_I4) 42#if !defined(MPS_OS_LI)
43#error "Compiling thlii4 when MPS_OS_LI or MPS_ARCH_I4 not defined." 43#error "Compiling thli when MPS_OS_LI is not defined."
44#endif
45
46#if !(defined(MPS_ARCH_I4) || defined(MPS_ARCH_I6))
47#error "Need to check assumptions for thli.c are true for this architecture"
44#endif 48#endif
45 49
46#include <pthread.h> 50#include <pthread.h>
47#include "pthrdext.h" 51#include "pthrdext.h"
48 52
49SRCID(thlii4, "$Id$"); 53SRCID(thli, "$Id$");
50 54
51 55
52/* ThreadStruct -- thread desriptor */ 56/* ThreadStruct -- thread desriptor */
@@ -254,7 +258,7 @@ Res ThreadScan(ScanState ss, Thread thread, void *stackBot)
254 return ResOK; 258 return ResOK;
255 } 259 }
256 260
257 stackPtr = (Addr)mfc->ucontext->uc_stack.ss_sp; /* .i3.sp */ 261 stackPtr = (Addr)mfc->ucontext->uc_stack.ss_sp; /* .sp */
258 /* .stack.align */ 262 /* .stack.align */
259 stackBase = (Addr *)AddrAlignUp(stackPtr, sizeof(Addr)); 263 stackBase = (Addr *)AddrAlignUp(stackPtr, sizeof(Addr));
260 stackLimit = (Addr *)stackBot; 264 stackLimit = (Addr *)stackBot;