qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Sandra Loosemore <sandra@codesourcery.com>
To: Laurent Vivier <laurent@vivier.eu>, <qemu-devel@nongnu.org>
Cc: Marek Vasut <marex@denx.de>, Chris Wulff <crwulff@gmail.com>
Subject: Re: [Qemu-devel] [PATCH 1/2] target/nios2: Fix bug in semihosted exit handling
Date: Wed, 21 Aug 2019 09:27:54 -0600	[thread overview]
Message-ID: <608fde9c-bcac-9e6f-98f0-c208bda2eb5a@codesourcery.com> (raw)
In-Reply-To: <e84f586a-7238-7bbe-f519-bb7c370c404b@vivier.eu>

On 8/21/19 8:41 AM, Laurent Vivier wrote:
> Le 21/08/2019 à 16:21, Sandra Loosemore a écrit :
>> This patch fixes a bug that caused semihosted exit to always return
>> status 0; it was incorrectly using the value of register R_ARG0 (which
>> contains the HOSTED_EXIT request number) instead of register R_ARG1.
>>
>> Signed-off-by: Sandra Loosemore <sandra@codesourcery.com>
>> ---
>>   target/nios2/nios2-semi.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/target/nios2/nios2-semi.c b/target/nios2/nios2-semi.c
>> index d7a80dd..06c0861 100644
>> --- a/target/nios2/nios2-semi.c
>> +++ b/target/nios2/nios2-semi.c
>> @@ -215,8 +215,8 @@ void do_nios2_semihosting(CPUNios2State *env)
>>       args = env->regs[R_ARG1];
>>       switch (nr) {
>>       case HOSTED_EXIT:
>> -        gdb_exit(env, env->regs[R_ARG0]);
>> -        exit(env->regs[R_ARG0]);
>> +        gdb_exit(env, env->regs[R_ARG1]);
>> +        exit(env->regs[R_ARG1]);
> 
> It's weird: in line 215,  env->regs[R_ARG1] is args.
> 
> Are you sure it's not something like:
> 
>          GET_ARG(0)
>          gdb_exit(env, arg0);
>          exit(arg0);
> 
> same for m68k.
> 
> Did you check the kernel code?

It's not the kernel that's involved here, it's libgloss.  And yes, the 
HOSTED_EXIT case takes an immediate argument in the register rather than 
a pointer to an argument block.

Here's the documentation for nios2 semihosting.

https://www.sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=blob;f=libgloss/nios2/nios2-semi.txt;h=ded3a093c03dbae84cb95b4cd45bc3e0d751eda2;hb=HEAD

And m68k:

https://www.sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=blob;f=libgloss/m68k/m68k-semi.txt;h=50520c15292aa7edf7eef28e09fd9202ce75b153;hb=HEAD

Again, a lot of cutting and pasting involved here.  ;-)

-Sandra


  reply	other threads:[~2019-08-21 15:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-21 14:21 [Qemu-devel] [PATCH 0/2] Fix bug in nios2 and m68k semihosting Sandra Loosemore
2019-08-21 14:21 ` [Qemu-devel] [PATCH 1/2] target/nios2: Fix bug in semihosted exit handling Sandra Loosemore
2019-08-21 14:29   ` Philippe Mathieu-Daudé
2019-08-21 14:41   ` Laurent Vivier
2019-08-21 15:27     ` Sandra Loosemore [this message]
2019-08-21 15:41       ` Laurent Vivier
2019-08-21 17:48         ` Sandra Loosemore
2019-08-21 14:21 ` [Qemu-devel] [PATCH 2/2] target/m68k: " Sandra Loosemore
2019-08-21 14:31   ` Philippe Mathieu-Daudé
2019-08-21 15:41   ` Laurent Vivier

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=608fde9c-bcac-9e6f-98f0-c208bda2eb5a@codesourcery.com \
    --to=sandra@codesourcery.com \
    --cc=crwulff@gmail.com \
    --cc=laurent@vivier.eu \
    --cc=marex@denx.de \
    --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).