Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Matthew Fortune <Matthew.Fortune@imgtec.com>
To: Mike Frysinger <vapier@gentoo.org>,
	Maciej Rozycki	<Maciej.Rozycki@imgtec.com>
Cc: Steve Ellcey <Steve.Ellcey@imgtec.com>,
	"gdb-patches@sourceware.org"	<gdb-patches@sourceware.org>
Subject: RE: MIPS simulator is broken
Date: Mon, 21 Mar 2016 11:54:00 -0000	[thread overview]
Message-ID: <6D39441BF12EF246A7ABCE6654B023537E3A3580@HHMAIL01.hh.imgtec.org> (raw)
In-Reply-To: <20160210072842.GX7732@vapier.lan>

Ping.

Matthew Fortune <matthew.fortune@imgtec.com> writes:
> Mike Frysinger <vapier@gentoo.org> writes:
> > since 64-bit address aren't actually being used in the 32-bit env, why
> > bother using them ?  seems like it'd be much easier to just use 32-bit
> > addresses and be done.
> 
> Hi Mike,
> 
> The problem here is fairly common and seems to boil down to a
> misunderstanding at some level of the MIPS trick for 32-bit running on
> 64-bit architectures.
> 
> I agree that the address translation logic for MIPS seems weird but I
> also don’t think it should not get changed just because it looks odd
> without understanding why it is that way. As such for the time being I
> propose reverting both changes to MIPS sim to get it working again:
> 
>     Revert "sim: mips: delete mmu stubs to move to common
> sim_{read,write}"
> 
>     This reverts commit 26f8bf63bf36f9062a5cc1afacf71462a4abe0c8.
> 
>     Revert "sim: mips: workaround 32-bit addr sign extensions"
> 
>     This reverts commit b36d953bced0a4fecdde1823abac70ed7038ee95.
> 
> I'd assume this is OK given it 'fixes' the regression despite taking the
> code back to its unusual, but working, state.
> 
> I don't fully understand GNUSIM internals so please bear with me while I
> get up to speed...
> 
> Let's assume we just delete the masking of address in
> address_translation:
> 
> diff --git a/sim/mips/sim-main.c b/sim/mips/sim-main.c index
> 916769e..8cf5743 100644
> --- a/sim/mips/sim-main.c
> +++ b/sim/mips/sim-main.c
> @@ -68,7 +68,7 @@ address_translation (SIM_DESC sd,
> 
>    /* For a simple (flat) memory model, we simply pass virtual
>       addressess through (mostly) unchanged. */
> -  vAddr &= 0xFFFFFFFF;
> +//  vAddr &= 0xFFFFFFFF;
> 
>    *pAddr = vAddr;              /* default for isTARGET */
>    *CCA = Uncached;             /* not used for isHOST */
> 
> Where we could aim for is that when simulating a 64-bit architecture
> then all addresses (including those coming from o32 or n32 applications)
> should be seen as 64-bit and sign extended (NOT zero extended) from the
> 32-bit values seen in the ELF.
> 
> This means code in an o32 ELF with address 0x80010000 should be loaded
> at 0xffffffff80010000 and executed from that 64-bit address. When
> presenting addresses to the user the upper 32-bits can be discarded as
> they are irrelevant but internally in the sim they could be represented.
> 
> It seems this is how things work and I see sections being loaded at sign
> extended 64-bit addresses addresses but even when I claim to have a
> memory region at that 64-bit address I still get the read to unmapped
> address error as the code does not appear to get loaded:
> 
> run --memory-region 0xffffffff80010000,0x10000  sanity.s.x Loading
> section .text, size 0x60 lma 0xffffffff80010000 Loading section
> .MIPS.abiflags, size 0x18 lma 0x400098 Loading section .data, size 0x1a
> lma 0xffffffff80010060
> mips-core: 4 byte read to unmapped address 0xffffffff80020000 at
> 0xffffffff80020000 program stopped with signal 10 (User defined signal
> 1).
> 
> The trace output shows this:
> 
> insn:     0x80010000 ---   _start         nop              - SLLb
> insn:     0x80010004 ---   _start         nop              - SLLb
> insn:     0x80010008 ---   _fail          nop              - SLLb
> insn:     0x8001000c ---   _fail          nop              - SLLb
> insn:     0x80010010 ---   _fail          nop              - SLLb
> insn:     0x80010014 ---   _fail          nop              - SLLb
> 
> Can you help me understand why the code does not get loaded and/or if
> there is somewhere else we may need to educate about sign extended
> addresses?
> 
> Thanks,
> Matthew

  parent reply	other threads:[~2016-03-21 11:54 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-08 22:30 Steve Ellcey 
2016-01-08 22:49 ` Mike Frysinger
2016-01-11 22:38   ` Steve Ellcey
2016-01-11 22:57     ` Mike Frysinger
2016-01-12  1:00 ` Mike Frysinger
2016-01-12  6:49   ` Mike Frysinger
2016-01-12 10:25   ` Pedro Alves
2016-01-30 16:10   ` Maciej W. Rozycki
2016-02-10  7:28     ` Mike Frysinger
2016-02-11 16:54       ` Maciej W. Rozycki
2016-03-10 14:09       ` Matthew Fortune
2016-03-21 11:54       ` Matthew Fortune [this message]
2016-04-05  8:33         ` Matthew Fortune

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=6D39441BF12EF246A7ABCE6654B023537E3A3580@HHMAIL01.hh.imgtec.org \
    --to=matthew.fortune@imgtec.com \
    --cc=Maciej.Rozycki@imgtec.com \
    --cc=Steve.Ellcey@imgtec.com \
    --cc=gdb-patches@sourceware.org \
    --cc=vapier@gentoo.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox