Date: Sun, 07 Dec 2003 09:43:08 +0800 From: David Xu <davidxu@freebsd.org> To: Peter Wemm <peter@wemm.org> Cc: Daniel Eischen <eischen@vigrid.com> Subject: Re: cvs commit: src/lib/libc/amd64/gen makecontext.c Message-ID: <3FD285AC.3080609@freebsd.org> In-Reply-To: <20031207011600.E70C32A7EA@canning.wemm.org> References: <20031207011600.E70C32A7EA@canning.wemm.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Peter Wemm wrote: >Daniel Eischen wrote: > > >>On Thu, 4 Dec 2003, Peter Wemm wrote: >> >> >> >>>peter 2003/12/04 17:36:44 PST >>> >>> FreeBSD src repository >>> >>> Modified files: >>> lib/libc/amd64/gen makecontext.c >>> Log: >>> "Fix" makecontext() so that the C code begins execution with its >>> ABI-required stack alignment. C code expects that the push of the >>> return address disturbed the 16 byte alignment and it will take correctiv >>> >>> > e > > >>> measures to fix it before making another call. Of course, if its wrong >>> to start with, then all hell breaks loose. Essentially we "fix" this >>> by making the stack alignment odd to start with. >>> >>> >>Hey, you didn't include this little bit of knowledge in your amd64 "notes" >>that you sent me ;-) >> >> > >Heh. I never get it right. I've had to resort to things like this: > > assert((((long)__builtin_frame_address(0)) & 15 == 0), "misaligned stack!"); > >The trick of course is that gcc-3.3.3 is broken and __builtin_frame_address(0) >doesn't actually work unless you compile *also* with -fno-omit-frame-pointer >on amd64. > >Anyway, thats the only way I've ever been able to get this stuff sorted out. :-) > > > I have found upcall stack is not aligned at 16 bytes. it is triggered when I add this test into kse_sched_multi in libkse, maybe the line contains "td->td_frame->tf_rsp -= 8;" in vm_machdep.c should be removed. >Cheers, >-Peter >-- >Peter Wemm - peter@wemm.org; peter@FreeBSD.org; peter@yahoo-inc.com >"All of this is for nothing if we don't go to the stars" - JMS/B5 > > >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3FD285AC.3080609>