From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: marex@denx.de, crwulff@gmail.com, alex.bennee@linaro.org,
laurent@vivier.eu
Subject: [PATCH 6/9] linux-user/nios2: Fix EA vs PC confusion
Date: Fri, 1 Oct 2021 11:33:44 -0400 [thread overview]
Message-ID: <20211001153347.1736014-9-richard.henderson@linaro.org> (raw)
In-Reply-To: <20211001153347.1736014-1-richard.henderson@linaro.org>
The real kernel will talk about the user PC as EA,
because that's where the hardware will have copied it,
and where it expects to put it to then use ERET.
But qemu does not emulate all of the exception stuff
while emulating user-only. Manipulate PC directly.
This fixes signal entry and return, and eliminates
some slight confusion from target_cpu_copy_regs.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
linux-user/nios2/cpu_loop.c | 5 +----
linux-user/nios2/signal.c | 6 +++---
2 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/linux-user/nios2/cpu_loop.c b/linux-user/nios2/cpu_loop.c
index de0fc63e21..1e93ef34e6 100644
--- a/linux-user/nios2/cpu_loop.c
+++ b/linux-user/nios2/cpu_loop.c
@@ -155,9 +155,6 @@ void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
env->regs[R_SP] = regs->sp;
env->regs[R_GP] = regs->gp;
env->regs[CR_ESTATUS] = regs->estatus;
- env->regs[R_EA] = regs->ea;
- /* TODO: unsigned long orig_r7; */
-
- /* Emulate eret when starting thread. */
env->regs[R_PC] = regs->ea;
+ /* TODO: unsigned long orig_r7; */
}
diff --git a/linux-user/nios2/signal.c b/linux-user/nios2/signal.c
index adbffe32e3..20b65aa06e 100644
--- a/linux-user/nios2/signal.c
+++ b/linux-user/nios2/signal.c
@@ -73,7 +73,7 @@ static void rt_setup_ucontext(struct target_ucontext *uc, CPUNios2State *env)
__put_user(env->regs[R_RA], &gregs[23]);
__put_user(env->regs[R_FP], &gregs[24]);
__put_user(env->regs[R_GP], &gregs[25]);
- __put_user(env->regs[R_EA], &gregs[27]);
+ __put_user(env->regs[R_PC], &gregs[27]);
__put_user(env->regs[R_SP], &gregs[28]);
}
@@ -122,7 +122,7 @@ static int rt_restore_ucontext(CPUNios2State *env, struct target_ucontext *uc,
__get_user(env->regs[R_GP], &gregs[25]);
/* Not really necessary no user settable bits */
__get_user(temp, &gregs[26]);
- __get_user(env->regs[R_EA], &gregs[27]);
+ __get_user(env->regs[R_PC], &gregs[27]);
__get_user(env->regs[R_RA], &gregs[23]);
__get_user(env->regs[R_SP], &gregs[28]);
@@ -181,7 +181,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka,
env->regs[4] = sig;
env->regs[5] = frame_addr + offsetof(struct target_rt_sigframe, info);
env->regs[6] = frame_addr + offsetof(struct target_rt_sigframe, uc);
- env->regs[R_EA] = ka->_sa_handler;
+ env->regs[R_PC] = ka->_sa_handler;
unlock_user_struct(frame, frame_addr, 1);
}
--
2.25.1
next prev parent reply other threads:[~2021-10-01 15:43 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-01 15:33 [PATCH 0/9] nios2: Enable cross compile and fix signals Richard Henderson
2021-10-01 15:33 ` [PATCH 1/9] tests/docker: Add debian-nios2-cross image Richard Henderson
2021-10-12 17:03 ` Alex Bennée
2021-10-12 18:24 ` Richard Henderson
2021-10-12 18:33 ` Alex Bennée
2021-10-14 9:34 ` Alex Bennée
2021-10-14 17:17 ` Richard Henderson
2021-10-14 17:25 ` Alex Bennée
2021-10-01 15:33 ` [PATCH 1/2] tests/docker: Remove fedora-i386-cross from DOCKER_PARTIAL_IMAGES Richard Henderson
2021-10-14 9:35 ` Alex Bennée
2021-10-01 15:33 ` [PATCH 2/9] linux-user/nios2: Properly emulate EXCP_TRAP Richard Henderson
2021-10-14 9:36 ` Alex Bennée
2021-10-01 15:33 ` [PATCH 2/2] tests/docker: Fix fedora-i386-cross Richard Henderson
2021-10-14 9:38 ` Alex Bennée
2021-10-01 15:33 ` [PATCH 3/9] linux-user/nios2: Fixes for signal frame setup Richard Henderson
2021-10-14 9:43 ` Alex Bennée
2021-10-01 15:33 ` [PATCH 4/9] linux-user/elfload: Rename ARM_COMMPAGE to HI_COMMPAGE Richard Henderson
2021-10-12 6:11 ` Laurent Vivier
2021-10-01 15:33 ` [PATCH 5/9] linux-user/nios2: Map a real kuser page Richard Henderson
2021-10-01 15:33 ` Richard Henderson [this message]
2021-10-01 15:33 ` [PATCH 7/9] linux-user/nios2: Fix sigmask in setup_rt_frame Richard Henderson
2021-10-12 6:16 ` Laurent Vivier
2021-10-01 15:33 ` [PATCH 8/9] linux-user/nios2: Use set_sigmask in do_rt_sigreturn Richard Henderson
2021-10-12 6:29 ` Laurent Vivier
2021-10-01 15:33 ` [PATCH 9/9] tests/tcg: Enable container_cross_cc for nios2 Richard Henderson
2021-10-11 19:06 ` [PATCH 0/9] nios2: Enable cross compile and fix signals Richard Henderson
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=20211001153347.1736014-9-richard.henderson@linaro.org \
--to=richard.henderson@linaro.org \
--cc=alex.bennee@linaro.org \
--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).