From: gang.chen.5i5j@gmail.com
To: riku.voipio@iki.fi, peter.maydell@linaro.org, rth@twiddle.net
Cc: qemu-devel@nongnu.org, xili_gchen_5257@hotmail.com,
Chen Gang <gang.chen.5i5j@gmail.com>
Subject: [Qemu-devel] [PATCH v2] linux-user/signal.c: Fix several issues for target alpha
Date: Tue, 15 Sep 2015 03:48:03 +0800 [thread overview]
Message-ID: <1442260083-3123-1-git-send-email-gang.chen.5i5j@gmail.com> (raw)
From: Chen Gang <gang.chen.5i5j@gmail.com>
Remove useless variable err in setup_frame() and setup_rt_frame().
Add unlock_user_struct() for setup_rt_frame().
Do not call unlock_user_struct() when lock_user_struct() failed in
do_rt_sigreturn().
Remove white space of label badframe in do_sigreturn().
Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
linux-user/signal.c | 41 ++++++++++++++++++++---------------------
1 file changed, 20 insertions(+), 21 deletions(-)
diff --git a/linux-user/signal.c b/linux-user/signal.c
index 502efd9..e188931 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -5396,7 +5396,6 @@ static void setup_frame(int sig, struct target_sigaction *ka,
{
abi_ulong frame_addr, r26;
struct target_sigframe *frame;
- int err = 0;
frame_addr = get_sigframe(ka, env, sizeof(*frame));
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) {
@@ -5418,20 +5417,19 @@ static void setup_frame(int sig, struct target_sigaction *ka,
unlock_user_struct(frame, frame_addr, 1);
- if (err) {
- give_sigsegv:
- if (sig == TARGET_SIGSEGV) {
- ka->_sa_handler = TARGET_SIG_DFL;
- }
- force_sig(TARGET_SIGSEGV);
- }
-
env->ir[IR_RA] = r26;
env->ir[IR_PV] = env->pc = ka->_sa_handler;
env->ir[IR_A0] = sig;
env->ir[IR_A1] = 0;
env->ir[IR_A2] = frame_addr + offsetof(struct target_sigframe, sc);
env->ir[IR_SP] = frame_addr;
+ return;
+
+give_sigsegv:
+ if (sig == TARGET_SIGSEGV) {
+ ka->_sa_handler = TARGET_SIG_DFL;
+ }
+ force_sig(TARGET_SIGSEGV);
}
static void setup_rt_frame(int sig, struct target_sigaction *ka,
@@ -5440,7 +5438,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
{
abi_ulong frame_addr, r26;
struct target_rt_sigframe *frame;
- int i, err = 0;
+ int i;
frame_addr = get_sigframe(ka, env, sizeof(*frame));
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) {
@@ -5474,13 +5472,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
r26 = frame_addr;
}
- if (err) {
- give_sigsegv:
- if (sig == TARGET_SIGSEGV) {
- ka->_sa_handler = TARGET_SIG_DFL;
- }
- force_sig(TARGET_SIGSEGV);
- }
+ unlock_user_struct(frame, frame_addr, 1);
env->ir[IR_RA] = r26;
env->ir[IR_PV] = env->pc = ka->_sa_handler;
@@ -5488,6 +5480,13 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
env->ir[IR_A1] = frame_addr + offsetof(struct target_rt_sigframe, info);
env->ir[IR_A2] = frame_addr + offsetof(struct target_rt_sigframe, uc);
env->ir[IR_SP] = frame_addr;
+ return;
+
+give_sigsegv:
+ if (sig == TARGET_SIGSEGV) {
+ ka->_sa_handler = TARGET_SIG_DFL;
+ }
+ force_sig(TARGET_SIGSEGV);
}
long do_sigreturn(CPUAlphaState *env)
@@ -5511,7 +5510,7 @@ long do_sigreturn(CPUAlphaState *env)
unlock_user_struct(sc, sc_addr, 0);
return env->ir[IR_V0];
- badframe:
+badframe:
force_sig(TARGET_SIGSEGV);
}
@@ -5522,7 +5521,7 @@ long do_rt_sigreturn(CPUAlphaState *env)
sigset_t set;
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) {
- goto badframe;
+ goto err;
}
target_to_host_sigset(&set, &frame->uc.tuc_sigmask);
do_sigprocmask(SIG_SETMASK, &set, NULL);
@@ -5537,9 +5536,9 @@ long do_rt_sigreturn(CPUAlphaState *env)
unlock_user_struct(frame, frame_addr, 0);
return env->ir[IR_V0];
-
- badframe:
+badframe:
unlock_user_struct(frame, frame_addr, 0);
+err:
force_sig(TARGET_SIGSEGV);
}
--
1.9.3
reply other threads:[~2015-09-14 19:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1442260083-3123-1-git-send-email-gang.chen.5i5j@gmail.com \
--to=gang.chen.5i5j@gmail.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=riku.voipio@iki.fi \
--cc=rth@twiddle.net \
--cc=xili_gchen_5257@hotmail.com \
/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).