From: Paul Burton <paul.burton@imgtec.com>
To: "Maciej W. Rozycki" <macro@linux-mips.org>
Cc: Ralf Baechle <ralf@linux-mips.org>,
"linux-mips@linux-mips.org" <linux-mips@linux-mips.org>
Subject: Re: R2300 (not the hay baler)
Date: Wed, 27 Nov 2013 17:11:48 +0000 [thread overview]
Message-ID: <529627D4.1060204@imgtec.com> (raw)
In-Reply-To: <alpine.LFD.2.03.1311211934420.3267@linux-mips.org>
On 21/11/13 19:52, Maciej W. Rozycki wrote:
>>> If you are concerned about register layout in ptrace packets, then please
>>> see mips_read_fp_register_single and mips_read_fp_register_double in GDB
>>> sources and the comment above them; notice the register buffer offset of 4
>>> applied in the big-endian case -- what r2300_switch.S does is exactly what
>>> the userland expects (of course it might be that r4k_switch.S is wrong in
>>> some cases; actually I remember a discussion with Ralf where we came to
>>> this very conclusion and rather than converting r4k_switch.S to use
>>> LWC1/SWC1 -- that would degrade performance a bit for FP context switches
>>> -- considered a helper to convert between the internal and the ptrace
>>> format).
>>
>> Do you know what happened to that or have a link to that discussion? I
>> don't see that conversion being done at the moment, which makes me
>> suspect that the kernel might handle ptrace incorrectly (arguably
>> more nicely, but still incorrectly) for mips32 tasks with FR=0 on an
>> R4K class CPU. I'll have a look.
>
> I think the discussion was off-list (Ralf, would you mind if I digged up
> any clues from there?). The format has been set long ago, and is also odd
> enough to have 32 64-bit slots in the PTRACE_GETFPREGS/PTRACE_SETFPREGS
> structure even for o32 processes (that now should be unexpectedly helpful
> for FP64 o32 processes though), so there's little sense discussing its
> prettiness or ugliness at this point in the game.
>
> Also I'm not sure what the core file format is for the FP context, it may
> be worth double-checking too.
>
> Please feel free to poke me directly if you have any further issues about
> MIPS I ISA compatibility.
Ok I finally had time to look at this. It seems that r2300_switch.S used
to match the current behaviour of r4k_switch.S. Ralf made it that way by
saving to the appropriate 32 bits of the even numbered 64 bit values of
the FP context, taking endianness into account, in the following commit:
http://git.linux-mips.org/?p=ralf/linux.git;a=commitdiff;h=42533948caacb82574ccf91cae84df851d4f0521#patch28
...and then you fixed up ptrace to always expect values stored in the
format now used by r4k_switch.S (& at the time used by r2300_switch.S too):
http://git.linux-mips.org/?p=ralf/linux.git;a=commitdiff;h=849fa7a50dff104cbf6654c421b666eefd6da0c1;hp=364e85467c9c08c803087c5b75ae2e70540e3bb5
Unfortunately later when Ralf replaced the FPU_SAVE_SINGLE macro with
the fpu_save_single macro in this commit:
http://git.linux-mips.org/?p=ralf/linux.git;a=commitdiff;h=bf0b3bb876115b1e69b2266477128d8270d0b356;hp=39507fed032849b72552062883d143025be8be36
...he effectively reverted r2300_switch.S to its old behaviour, whilst
ptrace continues to expect the r4k_switch.S-like behaviour. So as far as
I can tell the original intended FP register layout was that currently
used by r4k_switch.S. That makes r2300_switch.S the incorrect one -
fixed 11 years ago & broken again 10 years ago.
What I'm less sure about right now is what gdb has come to expect in the
meantime - but from your description it sounds like it expects the
r2300_switch.S behaviour? In which case I suspect that although it seems
the original intended ptrace ABI was broken long ago & the easiest fix
may be for the kernel to just go with the unintended ABI on r4k-class
cores too? I'll have a read through more gdb code & try to confirm.
Thanks,
Paul
next prev parent reply other threads:[~2013-11-27 17:12 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-19 11:07 R2300 (not the hay baler) Paul Burton
2013-11-19 11:21 ` Ralf Baechle
2013-11-19 11:31 ` Paul Burton
2013-11-19 12:27 ` Maciej W. Rozycki
2013-11-19 12:59 ` Paul Burton
2013-11-21 19:52 ` Maciej W. Rozycki
2013-11-21 22:43 ` Ralf Baechle
2013-11-22 0:32 ` Maciej W. Rozycki
2013-11-27 17:11 ` Paul Burton [this message]
2013-12-03 16:49 ` MASS MAILING: " Paul Burton
2013-11-19 13:09 ` Ralf Baechle
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=529627D4.1060204@imgtec.com \
--to=paul.burton@imgtec.com \
--cc=linux-mips@linux-mips.org \
--cc=macro@linux-mips.org \
--cc=ralf@linux-mips.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.