[PATCH] target/nios2: Pass semihosting arg to exit

Keith Packard via posted 1 patch 9 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20230801152245.332749-1-keithp@keithp.com
Maintainers: Chris Wulff <crwulff@gmail.com>, Marek Vasut <marex@denx.de>
target/nios2/nios2-semi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] target/nios2: Pass semihosting arg to exit
Posted by Keith Packard via 9 months ago
Instead of using R_ARG0 (the semihost function number), use R_ARG1
(the provided exit status).

Signed-off-by: Keith Packard <keithp@keithp.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 3738774976..f3b7aee4f1 100644
--- a/target/nios2/nios2-semi.c
+++ b/target/nios2/nios2-semi.c
@@ -133,8 +133,8 @@ void do_nios2_semihosting(CPUNios2State *env)
     args = env->regs[R_ARG1];
     switch (nr) {
     case HOSTED_EXIT:
-        gdb_exit(env->regs[R_ARG0]);
-        exit(env->regs[R_ARG0]);
+        gdb_exit(env->regs[R_ARG1]);
+        exit(env->regs[R_ARG1]);
 
     case HOSTED_OPEN:
         GET_ARG(0);
-- 
2.40.1
Re: [PATCH] target/nios2: Pass semihosting arg to exit
Posted by Philippe Mathieu-Daudé 9 months ago
On 1/8/23 17:22, Keith Packard via wrote:
> Instead of using R_ARG0 (the semihost function number), use R_ARG1
> (the provided exit status).
> 
> Signed-off-by: Keith Packard <keithp@keithp.com>
> ---
>   target/nios2/nios2-semi.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)

Thanks, queued via misc-fixes.
Re: [PATCH] target/nios2: Pass semihosting arg to exit
Posted by Peter Maydell 9 months ago
On Tue, 1 Aug 2023 at 16:23, Keith Packard via <qemu-devel@nongnu.org> wrote:
>
> Instead of using R_ARG0 (the semihost function number), use R_ARG1
> (the provided exit status).
>
> Signed-off-by: Keith Packard <keithp@keithp.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 3738774976..f3b7aee4f1 100644
> --- a/target/nios2/nios2-semi.c
> +++ b/target/nios2/nios2-semi.c
> @@ -133,8 +133,8 @@ void do_nios2_semihosting(CPUNios2State *env)
>      args = env->regs[R_ARG1];
>      switch (nr) {
>      case HOSTED_EXIT:
> -        gdb_exit(env->regs[R_ARG0]);
> -        exit(env->regs[R_ARG0]);
> +        gdb_exit(env->regs[R_ARG1]);
> +        exit(env->regs[R_ARG1]);
>

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM