From: Laurent Vivier <laurent@vivier.eu>
To: Alistair Francis <alistair.francis@wdc.com>,
qemu-devel@nongnu.org, qemu-riscv@nongnu.org
Cc: alistair23@gmail.com, bmeng.cn@gmail.com, palmer@dabbelt.com
Subject: Re: [PATCH v1 1/1] linux-user/signal: Decode waitid si_code
Date: Mon, 18 Jan 2021 15:36:15 +0100 [thread overview]
Message-ID: <eac70d13-7e70-756e-503c-329fdb14a312@vivier.eu> (raw)
In-Reply-To: <1a4df1b5638d73b64200add175be9d69013418d8.1608401453.git.alistair.francis@wdc.com>
Le 19/12/2020 à 19:11, Alistair Francis a écrit :
> When mapping the host waitid status to the target status we previously
> just used decoding information in the status value. This doesn't follow
> what the waitid documentation describes, which instead suggests using
> the si_code value for the decoding. This results in the incorrect values
> seen when calling waitid. This is especially apparent on RV32 where all
> wait calls use waitid (see the bug case).
>
> This patch uses the si_code value to map the waitid status.
>
> Buglink: https://bugs.launchpad.net/qemu/+bug/1906193
> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
> ---
> linux-user/signal.c | 26 ++++++++++++++++++++++++--
> 1 file changed, 24 insertions(+), 2 deletions(-)
>
> diff --git a/linux-user/signal.c b/linux-user/signal.c
> index 73de934c65..b6c9326521 100644
> --- a/linux-user/signal.c
> +++ b/linux-user/signal.c
> @@ -305,6 +305,7 @@ static inline void host_to_target_siginfo_noswap(target_siginfo_t *tinfo,
> int sig = host_to_target_signal(info->si_signo);
> int si_code = info->si_code;
> int si_type;
> + int status = info->si_status;
> tinfo->si_signo = sig;
> tinfo->si_errno = 0;
> tinfo->si_code = info->si_code;
> @@ -349,8 +350,29 @@ static inline void host_to_target_siginfo_noswap(target_siginfo_t *tinfo,
> case TARGET_SIGCHLD:
> tinfo->_sifields._sigchld._pid = info->si_pid;
> tinfo->_sifields._sigchld._uid = info->si_uid;
> - tinfo->_sifields._sigchld._status
> - = host_to_target_waitstatus(info->si_status);
> +
> + /*
> + * Map host to target signal numbers for the waitid family of
> + * syscalls. This is similar to the functionality in
> + * host_to_target_waitstatus() except we use the si_code to
> + * determine the operation.
> + */
> + switch (info->si_code) {
> + case CLD_KILLED:
> + case CLD_DUMPED:
> + tinfo->_sifields._sigchld._status =
> + host_to_target_signal(WTERMSIG(status)) |
> + (status & ~0x7f);
> + break;
> + case CLD_STOPPED:
> + tinfo->_sifields._sigchld._status =
> + (host_to_target_signal(WSTOPSIG(status)) << 8) |
> + (status & 0xff);
> + break;
> + default:
I guess the the operation is not encoded in the status coming from the host as we need to use the
si_code to decode the status, so why do we need to encode it in the status we send to the guest?
Can it be only "tinfo->_sifields._sigchld._status = status" for all the cases?
Thanks,
Laurent
next prev parent reply other threads:[~2021-01-18 14:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-19 18:11 [PATCH v1 1/1] linux-user/signal: Decode waitid si_code Alistair Francis
2021-01-15 23:01 ` Alistair Francis
2021-01-16 18:57 ` Andreas K. Hüttel
2021-01-18 14:36 ` Laurent Vivier [this message]
2021-01-19 17:34 ` Alistair Francis
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=eac70d13-7e70-756e-503c-329fdb14a312@vivier.eu \
--to=laurent@vivier.eu \
--cc=alistair.francis@wdc.com \
--cc=alistair23@gmail.com \
--cc=bmeng.cn@gmail.com \
--cc=palmer@dabbelt.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@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).