Message ID | 20210913220552.604064-7-richard.henderson@linaro.org |
---|---|
State | New |
Headers | show |
Series | linux-user: Streamline handling of SIGSEGV/SIGBUS | expand |
On Mon, Sep 13, 2021 at 4:05 PM Richard Henderson < richard.henderson@linaro.org> wrote: > Remap the faulting address from the host address space into > the guest address space. > > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> > --- > linux-user/signal.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > Reviewed-by: Warner Losh <imp@bsdimp.com> If I'm understanding this right, the FreeBSD code in the bsd-user fork won't be affected by this change. (or conversely, it's so far behind the linux stuff that it will need to be completely revamped). Warner > diff --git a/linux-user/signal.c b/linux-user/signal.c > index a8faea6f09..73c0f9066b 100644 > --- a/linux-user/signal.c > +++ b/linux-user/signal.c > @@ -405,6 +405,15 @@ static inline void > host_to_target_siginfo_noswap(target_siginfo_t *tinfo, > tinfo->_sifields._sigpoll._fd = info->si_fd; > si_type = QEMU_SI_POLL; > break; > + case TARGET_SIGSEGV: > + case TARGET_SIGBUS: > + /* > + * Remap the host address into the target space. > + * Even an invalid guest address is still valid for a fault. > + */ > + tinfo->_sifields._sigfault._addr = h2g_nocheck(info->si_addr); > + si_type = QEMU_SI_FAULT; > + break; > default: > /* Assume a sigqueue()/mq_notify()/rt_sigqueueinfo() source. > */ > tinfo->_sifields._rt._pid = info->si_pid; > -- > 2.25.1 > > <div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Sep 13, 2021 at 4:05 PM Richard Henderson <<a href="mailto:richard.henderson@linaro.org">richard.henderson@linaro.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Remap the faulting address from the host address space into<br> the guest address space.<br> <br> Signed-off-by: Richard Henderson <<a href="mailto:richard.henderson@linaro.org" target="_blank">richard.henderson@linaro.org</a>><br> ---<br> linux-user/signal.c | 9 +++++++++<br> 1 file changed, 9 insertions(+)<br></blockquote><div><br></div><div>Reviewed-by: Warner Losh <<a href="mailto:imp@bsdimp.com">imp@bsdimp.com</a>></div><div><br></div><div>If I'm understanding this right, the FreeBSD code in the bsd-user fork won't be affected by this change.</div><div>(or conversely, it's so far behind the linux stuff that it will need to be completely</div><div>revamped).</div><div><br></div><div>Warner</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> diff --git a/linux-user/signal.c b/linux-user/signal.c<br> index a8faea6f09..73c0f9066b 100644<br> --- a/linux-user/signal.c<br> +++ b/linux-user/signal.c<br> @@ -405,6 +405,15 @@ static inline void host_to_target_siginfo_noswap(target_siginfo_t *tinfo,<br> tinfo->_sifields._sigpoll._fd = info->si_fd;<br> si_type = QEMU_SI_POLL;<br> break;<br> + case TARGET_SIGSEGV:<br> + case TARGET_SIGBUS:<br> + /*<br> + * Remap the host address into the target space.<br> + * Even an invalid guest address is still valid for a fault.<br> + */<br> + tinfo->_sifields._sigfault._addr = h2g_nocheck(info->si_addr);<br> + si_type = QEMU_SI_FAULT;<br> + break;<br> default:<br> /* Assume a sigqueue()/mq_notify()/rt_sigqueueinfo() source. */<br> tinfo->_sifields._rt._pid = info->si_pid;<br> -- <br> 2.25.1<br> <br> </blockquote></div></div>
On 9/15/21 9:23 AM, Warner Losh wrote: > > > On Mon, Sep 13, 2021 at 4:05 PM Richard Henderson <richard.henderson@linaro.org > <mailto:richard.henderson@linaro.org>> wrote: > > Remap the faulting address from the host address space into > the guest address space. > > Signed-off-by: Richard Henderson <richard.henderson@linaro.org > <mailto:richard.henderson@linaro.org>> > --- > linux-user/signal.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > > Reviewed-by: Warner Losh <imp@bsdimp.com <mailto:imp@bsdimp.com>> > > If I'm understanding this right, the FreeBSD code in the bsd-user fork won't be affected > by this change. > (or conversely, it's so far behind the linux stuff that it will need to be completely > revamped). The converse, yes. I haven't looked at your branch, but I assume that it'll be easier with this cleanup than without. FWIW. r~
diff --git a/linux-user/signal.c b/linux-user/signal.c index a8faea6f09..73c0f9066b 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -405,6 +405,15 @@ static inline void host_to_target_siginfo_noswap(target_siginfo_t *tinfo, tinfo->_sifields._sigpoll._fd = info->si_fd; si_type = QEMU_SI_POLL; break; + case TARGET_SIGSEGV: + case TARGET_SIGBUS: + /* + * Remap the host address into the target space. + * Even an invalid guest address is still valid for a fault. + */ + tinfo->_sifields._sigfault._addr = h2g_nocheck(info->si_addr); + si_type = QEMU_SI_FAULT; + break; default: /* Assume a sigqueue()/mq_notify()/rt_sigqueueinfo() source. */ tinfo->_sifields._rt._pid = info->si_pid;
Remap the faulting address from the host address space into the guest address space. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- linux-user/signal.c | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.25.1