qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Rémi Denis-Courmont" <remi@remlab.net>
To: Richard Henderson <richard.henderson@linaro.org>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] tcg: assert last byte is in guest space
Date: Fri, 08 Feb 2019 20:32:34 +0200	[thread overview]
Message-ID: <2034657.8N3RCfXzMK@basile.remlab.net> (raw)
In-Reply-To: <8f51cf7f-ba18-a123-e31d-a95d18918cb8@linaro.org>

Le perjantaina 8. helmikuuta 2019, 20.12.13 EET Richard Henderson a écrit :
> On 2/8/19 8:37 AM, Rémi Denis-Courmont wrote:
> > Rather than assert that the first byte of a checked range is within the
> > guest address space, assert that the last byte is. The assertion is
> > moved past the overflow check to ensure that the last byte is actually
> > the one with the highest address.
> > 
> > Signed-off-by: Rémi Denis-Courmont <remi@remlab.net>
> > ---
> > 
> >  accel/tcg/translate-all.c | 14 +++++++-------
> >  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> What are you trying to fix here?

As far as I can tell, the following code assumes that the entire range of 
checked addresses falls within the guest address range. So it makes sense to 
fail the assertion if the any byte is out of range, rather than only the first 
one.

> You've moved the assert past some returns, so that some cases that should
> not be handled by this function no longer get checked.  As the comment
> says, the address should already have been filtered by h2g_valid.

I find it generally hard to argue what an assertion should or should not do 
insofar as an assertion failure is supposed to be impossible. I am not in a 
position to decide if the assertion should fail in error cases that would be 
handled properly with a safe failure anyway - namely 0 bytes ranges and 
wrapping-around ranges.

However, it seems odd to live some undefined cases not failing the assertion, 
and I would not dare to add an extra assertion, so I replaced the one.

-- 
Rémi Denis-Courmont
http://www.remlab.net/

  reply	other threads:[~2019-02-08 21:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-08 16:37 [Qemu-devel] [PATCH] tcg: assert last byte is in guest space Rémi Denis-Courmont
2019-02-08 18:12 ` Richard Henderson
2019-02-08 18:32   ` Rémi Denis-Courmont [this message]
2019-02-08 20:27     ` 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=2034657.8N3RCfXzMK@basile.remlab.net \
    --to=remi@remlab.net \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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).