All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Liviu Ionescu <ilg@livius.net>
Cc: "QEMU Developers" <qemu-devel@nongnu.org>,
	"Alex Bennée" <alex.bennee@linaro.org>
Subject: Re: AArch64 semihosting?
Date: Thu, 26 May 2022 11:21:38 +0100	[thread overview]
Message-ID: <CAFEAcA981TZASA4g+Ggi1gmMnXYnu1xoaNdE8NmbC=6kDBBxpA@mail.gmail.com> (raw)
In-Reply-To: <CAFEAcA_beHgi7pg+ByW4ufG5qfz5n7o4ZP22WuayTtdGSQ_EQQ@mail.gmail.com>

On Thu, 26 May 2022 at 11:01, Peter Maydell <peter.maydell@linaro.org> wrote:
>
> On Thu, 26 May 2022 at 09:32, Liviu Ionescu <ilg@livius.net> wrote:
> > > On 26 May 2022, at 11:20, Peter Maydell <peter.maydell@linaro.org> wrote:
> > >
> > > ... can you provide us with
> > > a reproduce case (eg the binary you used here)?
> >
> > Sure. I'll try to attach it to this message, it is only 64K.
> >
> > The command I used to run the test is in the previous message.
> >
> > Please confirm that you get the same behaviour on your machine.
>
> Yes, I can reproduce this. What seems to be happening is that
> QEMU decides to do semihosting via gdb, but then crashes because
> gdbserver_state.c_cpu is NULL (which in turn is probably because
> there is no GDB connected). This is strange given the 'target=native'
> in the command line. I'll investigate further...

The failure to honour the 'target=native' option is the result of a
commandline parsing weirdness/bug. It happens because your command
line specifies two separate '--semihosting-config x=y,x=y...' option
groups, and the code was not written to take account of that
possibility. So in qemu_semihosting_config_options() it looks for
"did the user specify target=something" with the default being 'auto'.
This function gets run twice, once per --semihosting-config option
you have. So the first time around we set semihosting.enabled
to true and semihosting.target to SEMIHOSTING_TARGET_NATIVE.
But then the second time around we say "oh, the user didn't
specify either enabled or target, so default them to true and
SEMIHOSTING_TARGET_AUTO", overwriting the value that got set up
by the first call.

We should fix this (as well as the bug it reveals in the use
of 'target=auto|gdb' when the gdbstub is initialized but no gdb
is connected), but in the meantime you can work around it
by always providing just one --semihosting-config option, like this:
 --semihosting-config enable=on,target=native,arg=sample-test,arg=one,arg=two

I don't think any of this ought to be target-specific, so perhaps
the command line you use for 32-bit arm is slightly different
and avoided the bug by good fortune ?

thanks
-- PMM


  reply	other threads:[~2022-05-26 10:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-26  8:14 AArch64 semihosting? Liviu Ionescu
2022-05-26  8:20 ` Peter Maydell
2022-05-26  8:32   ` Liviu Ionescu
2022-05-26 10:01     ` Peter Maydell
2022-05-26 10:21       ` Peter Maydell [this message]
2022-05-26 11:03       ` Liviu Ionescu
2022-05-26 11:08         ` Peter Maydell
2022-05-26 11:46           ` Liviu Ionescu
2022-05-26  8:51   ` Liviu Ionescu

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='CAFEAcA981TZASA4g+Ggi1gmMnXYnu1xoaNdE8NmbC=6kDBBxpA@mail.gmail.com' \
    --to=peter.maydell@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=ilg@livius.net \
    --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 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.