From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Petr Vandrovec <vandrove@vc.cvut.cz>
Cc: Andi Kleen <ak@suse.de>, linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: 32-bit syscalls from 64-bit process on x86-64?
Date: Tue, 07 Dec 2004 18:30:56 -0800 [thread overview]
Message-ID: <1102473057.11405.51.camel@localhost> (raw)
In-Reply-To: <20041204144002.GA15404@vana.vc.cvut.cz>
On Sat, 2004-12-04 at 15:40 +0100, Petr Vandrovec wrote:
> Seems to work for me. See second example below. If it won't work, you
> can always use reverse procedure to one I used in syscall.c - only
> problem is that you'll have to allocate some memory below 4GB to
> hold code & stack during 32bit syscall.
I've been playing with this.
If I have a 64-bit process, and I switch to the 32-bit segment with ljmp
it works fine - until I get a signal. The kernel doesn't reload cs with
the 64-bit segment before calling the handler, which causes an obvious
mess. I've been experimenting with setting the handler to this little
trampoline:
handler32:
.code32
ljmp *1f
.code64
1: .long handler /* x86-64 handler */
.word 0x33 /* USER_CS */
but this always gets a SIGSEGV on the ljmp. I don't know why - there
are lots of reasons for getting a GPF, and there doesn't seem to be a
way to distinguish them.
(Hm, if I change this to the "ljmp $0x33, $handler" form, it gets to
handler, but then crashes because rsp has been truncated to 32-bits.
Hmm2, OK, so if I set up a 32-bit stack and a signal stack, it all works
OK.)
Any ideas? Is this a kernel bug: should it always make sure that CS has
the right value before starting a signal handler? I notice that the
ia32 kernel reloads cs before starting a signal handler.
J
next prev parent reply other threads:[~2004-12-08 5:41 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-02 16:22 32-bit syscalls from 64-bit process on x86-64? Jeremy Fitzhardinge
2004-12-02 18:52 ` Jeremy Fitzhardinge
2004-12-03 6:15 ` Andi Kleen
2004-12-03 23:16 ` Jeremy Fitzhardinge
2004-12-04 14:40 ` Petr Vandrovec
2004-12-04 21:33 ` Jeremy Fitzhardinge
2004-12-08 2:30 ` Jeremy Fitzhardinge [this message]
2004-12-14 7:45 ` Andi Kleen
-- strict thread matches above, loose matches on Subject: below --
2004-12-14 22:01 Petr Vandrovec
2004-12-15 4:27 ` Andi Kleen
2004-12-15 10:50 ` Jeremy Fitzhardinge
2004-12-15 10:55 ` Andi Kleen
2004-12-15 20:58 ` Jeremy Fitzhardinge
2004-12-16 4:35 ` Andi Kleen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1102473057.11405.51.camel@localhost \
--to=jeremy@goop.org \
--cc=ak@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=vandrove@vc.cvut.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox