From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Petr Vandrovec <vandrove@vc.cvut.cz>
Cc: Andi Kleen <ak@suse.de>,
Linux Kernel List <linux-kernel@vger.kernel.org>
Subject: Re: 32-bit syscalls from 64-bit process on x86-64?
Date: Sat, 04 Dec 2004 13:33:36 -0800 [thread overview]
Message-ID: <1102196016.5546.3.camel@minilith.goop.org> (raw)
In-Reply-To: <20041204144002.GA15404@vana.vc.cvut.cz>
On Sat, 2004-12-04 at 15:40 +0100, Petr Vandrovec wrote:
> On Fri, Dec 03, 2004 at 03:16:29PM -0800, Jeremy Fitzhardinge wrote:
> > On Fri, 2004-12-03 at 07:15 +0100, Andi Kleen wrote:
> > > int 0x80 from 64bit will call 32bit syscalls.
> >
> > Hm, that's not what I found. If I run int 0x80 with [re]ax=1, I get
> > exit with a 32-bit process and write with a 64-bit one.
>
> 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.
>
> > > But some things
> > > will not work properly, e.g. signals because they test the 32bit
> > > flag in the task_struct. So you would still get 64bit signal frames.
> >
> > OK, I can deal with that, since signals are never directly delivered to
> > the client.
> >
> > > There are some other such tests, but they probably wont affect you.
> > >
> > > There were some plans at one point to allow to toggle the flag
> > > using personality or prctl, but so far it hasn't been implemented.
> > > There is also no way to do 64bit calls from a 32bit executable.
> >
> > What about my idea of using distinct ranges of syscall numbers to
> > disambiguate them?
>
> What about this? This does 64bit syscalls from 32bit executable.
>
> Developed/tested on 2.6.10-rc2-mm2. You may want to replace $0x33 with
> some other value on 2.4.x kernels, but otherwise it should work fine for
> you. And well, you may want to do some additional coding so you can
> actually pass & retrieve 64bit values to/from syscalls.
>
> When it works correctly, program should print something and exit with code
> 111. If it sigsegvs or exits with 222, something went wrong.
Both of these work for me on a stock FC3 kernel (2.6.9-1.681_FC3). Not
sure what I was doing wrong...
Is 32-from-64 syscalls considered to be a documented API - something
which I can rely on?
The 64-from-32 switch is also very interesting; I hadn't realized you
could switch modes that easily within a process.
J
next prev parent reply other threads:[~2004-12-04 21:33 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-02 16:22 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 [this message]
2004-12-08 2:30 ` Jeremy Fitzhardinge
2004-12-14 7:45 ` Andi Kleen
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=1102196016.5546.3.camel@minilith.goop.org \
--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
Powered by JetHome