From: Mark Kettenis <mark.kettenis@xs4all.nl>
To: hjl.tools@gmail.com
Cc: dan@codesourcery.com, gdb-patches@sourceware.org,
suresh.b.siddha@intel.com, hpa@zytor.com
Subject: Re: PATCH: Enable x86 XML target descriptions
Date: Sun, 28 Feb 2010 20:12:00 -0000 [thread overview]
Message-ID: <201002282009.o1SK9JqK006858@glazunov.sibelius.xs4all.nl> (raw)
In-Reply-To: <6dc9ffc81002221341j735bdedeo7285951f4fc39c27@mail.gmail.com> (hjl.tools@gmail.com)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2934 bytes --]
> Date: Mon, 22 Feb 2010 13:41:07 -0800
> From: "H.J. Lu" <hjl.tools@gmail.com>
>
> On Mon, Feb 22, 2010 at 1:30 PM, Mark Kettenis <mark.kettenis@xs4all.nl> wrote:
> >> Date: Mon, 22 Feb 2010 13:06:31 -0800
> >> From: "H.J. Lu" <hjl.tools@gmail.com>
> >>
> >> On Mon, Feb 22, 2010 at 11:50 AM, Mark Kettenis <mark.kettenis@xs4all.nl> wrote:
> >> >> Date: Mon, 22 Feb 2010 12:03:03 -0500
> >> >> From: Daniel Jacobowitz <dan@codesourcery.com>
> >> >>
> >> >> On Mon, Feb 22, 2010 at 05:56:58PM +0100, Mark Kettenis wrote:
> >> >> > I've looked at the Linux kernel sources for the kernel on my
> >> >> > workstation (2.6.27 in its OpenSUSE incarnation), and the only way to
> >> >> > distinguish between a 32-bit and a 64-bit process seems to be to
> >> >> > attempt to write one of the debug address registers with a value
> >> >> > that's larger than 0xffffffff. If that fails, you have a 32-bit
> >> >> > process, otherwise it's a 64-bit process.
> >> >>
> >> >> Yuck :-( But I didn't see anything else either.
> >> >
> >> > Indeed.
> >> >
> >> >> Is there an eflags bit for this? Even if so, IIRC, we may not want to
> >> >> use it; it's possible to run 32-bit code in a 64-bit process and some
> >> >> overly clever programs may do so.
> >> >
> >> > Nope, there is no %eflags/%rflags bit for this. Not quite sure what
> >> > running 32-bit code in a 64-bit process actually means. But I'd guess
> >> > you want the 64-bit view on the registers in that case.
> >> >
> >> > Anyway, I think it's probably best if HJ leaves this bit out of this
> >> > diff for now. We can revisit the issue when AVX support is
> >> > introduced.
> >> >
> >>
> >> Please see if my latest patch is OK:
> >>
> >> ---
> >> /* Get CS register. */
> >> errno = 0;
> >> cs = ptrace (PTRACE_PEEKUSER, tid,
> >> offsetof (struct user_regs_struct, cs), 0);
> >> if (errno != 0)
> >> perror_with_name (_("Couldn't get CS register"));
> >>
> >> /* Value of CS register:
> >> 1. 64bit: 0x33.
> >> 2. 32bit: 0x23.
> >> */
> >> if (cs == 0x33)
> >> return tdesc_amd64_linux;
> >> else
> >> return tdesc_i386_linux;
> >> ---
> >>
> >> In kernel, there is
> >>
> >> regs->cs = test_thread_flag(TIF_64BIT_ILP32) ? __USER_CS : __USER32_CS;
> >
> > I fear that's rather fragile. I mean, the actual value of
> > __USER_CS/__USER32_CS is just an implementation detail isn't it?
> >
>
> That is how strace checks 32bit process on Linux/x86-64 I have
> discussed it with Peter and Suresh. It is very unlikely Linux kernel will
> break strace. In any case, we will add a new ptrace option to Linux
> 2.6.35 to get TIF_64BIT_ILP32 among other things. I will update gdb
> to try the new ptrace option first and then fail back to CS register.
OK, that makes it less fragile than I thought. But please use
#defines with meaningful names instead of magic constants.
next prev parent reply other threads:[~2010-02-28 20:12 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-10 20:03 H.J. Lu
2010-02-17 14:59 ` H.J. Lu
2010-02-17 15:23 ` Mark Kettenis
2010-02-17 15:42 ` H.J. Lu
2010-02-17 15:46 ` Daniel Jacobowitz
2010-02-17 16:19 ` Mark Kettenis
2010-02-18 5:44 ` H.J. Lu
2010-02-18 15:37 ` H.J. Lu
2010-02-18 23:01 ` H.J. Lu
2010-02-22 13:42 ` Mark Kettenis
2010-02-22 14:17 ` H.J. Lu
2010-02-22 15:01 ` Mark Kettenis
2010-02-22 15:27 ` H.J. Lu
2010-02-22 15:30 ` Daniel Jacobowitz
2010-02-22 15:39 ` H.J. Lu
2010-02-28 20:30 ` Mark Kettenis
2010-02-28 20:58 ` H.J. Lu
2010-02-28 22:23 ` Daniel Jacobowitz
2010-02-22 14:41 ` Daniel Jacobowitz
2010-02-22 15:34 ` H.J. Lu
2010-02-22 15:52 ` Daniel Jacobowitz
2010-02-22 15:58 ` H.J. Lu
2010-02-22 16:10 ` Daniel Jacobowitz
2010-02-22 16:58 ` Mark Kettenis
2010-02-22 17:03 ` Daniel Jacobowitz
2010-02-22 19:52 ` Mark Kettenis
2010-02-22 21:06 ` H.J. Lu
2010-02-22 21:31 ` Mark Kettenis
2010-02-22 21:41 ` H.J. Lu
2010-02-22 22:05 ` H. Peter Anvin
2010-02-22 22:07 ` H.J. Lu
2010-02-22 22:15 ` H. Peter Anvin
2010-02-22 22:21 ` H.J. Lu
2010-02-28 20:12 ` Mark Kettenis [this message]
2010-02-22 21:04 ` H.J. Lu
2010-02-28 21:16 ` H.J. Lu
2010-03-01 14:49 ` Mark Kettenis
2010-03-01 17:07 ` Daniel Jacobowitz
2010-03-01 17:09 ` H.J. Lu
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=201002282009.o1SK9JqK006858@glazunov.sibelius.xs4all.nl \
--to=mark.kettenis@xs4all.nl \
--cc=dan@codesourcery.com \
--cc=gdb-patches@sourceware.org \
--cc=hjl.tools@gmail.com \
--cc=hpa@zytor.com \
--cc=suresh.b.siddha@intel.com \
/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