From: Julian Brown <julian@codesourcery.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH 1/5] ARM BE8/BE32 semihosting and gdbstub support.
Date: Thu, 3 Nov 2016 23:34:19 +0000 [thread overview]
Message-ID: <20161103233419.26f4b7c7@squid.athome> (raw)
In-Reply-To: <CAFEAcA_Z88S+mMRjMzJg+iOx6t4_hwEsEYVuYBWgk6JJL2UEhg@mail.gmail.com>
On Thu, 3 Nov 2016 22:23:09 +0000
Peter Maydell <peter.maydell@linaro.org> wrote:
> On 3 November 2016 at 17:30, Julian Brown <julian@codesourcery.com>
> wrote:
> > This patch improves support for semihosting and debugging with the
> > in-built gdbstub for ARM system-mode emulation in big-endian mode
> > (either BE8 or BE32), after the fairly recent changes to allow a
> > single QEMU binary to deal with each of LE, BE8 and BE32 modes in
> > one. It's only currently good for little-endian host systems. The
> > relevant use case is using QEMU as a "bare metal" instruction-set
> > simulator, e.g. for toolchain testing.
> >
> > For semihosting, the softmmu-semi.h file is overridden with an
> > ARM-specific version that knows about byte-swapping target memory
> > into host order -- including that which has been byte-swapped at
> > load time for BE32 mode.
>
> Something here seems really weird. I would expect gdb
> to be able to cope with the target CPU's endianness
> settings. After all there is real world code which
> starts off in one endianness, temporarily swaps to
> the other and then switches back again, and gdb needs
> to be able to step through it without issues. So having
> code in the gdbstub interface that looks at arm_bswap_needed()
> seems rather odd and in the wrong place. What the guest
> CPU happens to be doing at any particular point shouldn't
> affect the way we talk to gdb.
I think the way it works is, if you invoke GDB with something like,
$ arm-eabi-gdb big-endian-binary.elf
then the remote protocol will talk in big-endian format (memory
read/write packets, register read/write packets, etc.) for that session.
I'm not sure if it'll transparently switch to little-endian remote
protocol format if the target does a SETEND instruction, or whatever.
I'd guess not.
So (IIRC!) the gdbstub needs to interpret some of these read/write
values on the host, i.e. in host byte ordering. "Traditionally", the
ldl_p and stl_p (etc.) macros would byteswap depending on the
TARGET_WORDS_BIGENDIAN setting -- that's how come our internal testing
using QEMU worked at all in the past. But that's changed with the
single-binary-for-all-endiannesses patches.
So -- all uses of ld*_p and st*_p, and the TARGET_WORDS_BIGENDIAN
macro, are now suspect in ARM system-emulation mode. The gdbstub.c
changes appear to fix some of those, but... yeah, there may be
subtleties remaining, like run-time endian switching by the target.
Generally it's not ideal, but I'm not sure how to do better.
Thanks,
Julian
next prev parent reply other threads:[~2016-11-03 23:34 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-03 17:30 [Qemu-devel] [PATCH 0/5] ARM BE8/BE32 big-endian system-mode fixes (semihosting, gdbstub) Julian Brown
2016-11-03 17:30 ` [Qemu-devel] [PATCH 1/5] ARM BE8/BE32 semihosting and gdbstub support Julian Brown
2016-11-03 22:23 ` Peter Maydell
2016-11-03 23:34 ` Julian Brown [this message]
2016-11-04 8:48 ` Paolo Bonzini
2016-11-04 10:25 ` Julian Brown
2016-11-04 11:01 ` Paolo Bonzini
2016-11-04 9:03 ` Paolo Bonzini
2016-12-06 15:11 ` Julian Brown
2016-12-06 15:44 ` Peter Maydell
2016-12-06 15:51 ` Julian Brown
2016-12-06 16:14 ` Peter Maydell
2016-11-03 17:30 ` [Qemu-devel] [PATCH 2/5] Fix Thumb-1 BE32 execution and disassembly Julian Brown
2016-11-04 13:30 ` Peter Maydell
2016-11-04 14:04 ` Julian Brown
2016-12-06 15:12 ` Julian Brown
2016-11-03 17:30 ` [Qemu-devel] [PATCH 3/5] Fix arm_semi_flen_cb for BE32 system mode Julian Brown
2016-11-04 9:00 ` Paolo Bonzini
2016-12-06 15:11 ` Julian Brown
2016-11-03 17:30 ` [Qemu-devel] [PATCH 4/5] ARM BE32 watchpoint fix Julian Brown
2016-11-03 23:14 ` Peter Maydell
2016-11-03 23:20 ` Julian Brown
2016-11-04 8:55 ` Paolo Bonzini
2016-12-06 15:12 ` Julian Brown
2016-11-03 21:26 ` [Qemu-devel] [PATCH 5/5] Fix typo in arm_cpu_do_interrupt_aarch32 Julian Brown
2016-11-04 13:02 ` Peter Maydell
2016-11-03 21:29 ` [Qemu-devel] [PATCH 0/5] ARM BE8/BE32 big-endian system-mode fixes (semihosting, gdbstub) no-reply
2016-11-03 21:37 ` no-reply
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=20161103233419.26f4b7c7@squid.athome \
--to=julian@codesourcery.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).