qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Emilio G. Cota" <cota@braap.org>
To: Eric Blake <eblake@redhat.com>
Cc: Richard Henderson <richard.henderson@linaro.org>,
	Bastian Koppelmann <kbastian@mail.uni-paderborn.de>,
	Michael Clark <mjc@sifive.com>,
	Palmer Dabbelt <palmer@sifive.com>,
	qemu-devel@nongnu.org,
	Sagar Karandikar <sagark@eecs.berkeley.edu>
Subject: Re: [Qemu-devel] [PATCH v2 17/17] target/riscv: convert to TranslatorOps
Date: Tue, 10 Apr 2018 10:38:58 -0400	[thread overview]
Message-ID: <20180410143858.GB22989@flamenco> (raw)
In-Reply-To: <af72f45e-f6e5-9c29-4325-bc1fdfc37987@redhat.com>

On Tue, Apr 10, 2018 at 09:05:06 -0500, Eric Blake wrote:
> On 04/10/2018 07:59 AM, Emilio G. Cota wrote:
> > On Tue, Apr 10, 2018 at 11:24:37 +1000, Richard Henderson wrote:
> >> On 04/07/2018 04:20 AM, Emilio G. Cota wrote:
> >>> +        next_page = (ctx->base.pc_first & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;
> >>> +        if (ctx->base.pc_next >= next_page) {
> >>
> >> This fails for the last page of the address space.
> >> Better is
> >>
> >>   page_start = ctx->base.pc_first & TARGET_PAGE_MASK;
> >>   if (ctx->base.pc_next - page_start >= TARGET_PAGE_SIZE) {
> > 
> > Apart from the variable name change, I fail to see how this (A - B >= C)
> > is not equivalent to the above (A => B + C). What am I missing?
> 
> Integer overflow.  Adding TARGET_PAGE_SIZE might wrap next_page to 0,
> which changes the semantics of the conditional; while performing the
> subtraction avoids the case of overflow.

Ah indeed. Thanks.

Turns out we have this problem in other targets as well -- will fix.

		E.

  reply	other threads:[~2018-04-10 14:39 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-06 18:19 [Qemu-devel] [PATCH v2 00/17] Translation loop conversion for sh4/sparc/mips/s390x/openrisc/riscv targets Emilio G. Cota
2018-04-06 18:19 ` [Qemu-devel] [PATCH v2 01/17] translator: merge max_insns into DisasContextBase Emilio G. Cota
2018-04-06 18:19 ` [Qemu-devel] [PATCH v2 02/17] target/sh4: convert to TranslatorOps Emilio G. Cota
2018-04-06 18:19 ` [Qemu-devel] [PATCH v2 03/17] target/sparc: convert to DisasJumpType Emilio G. Cota
2018-04-06 18:19 ` [Qemu-devel] [PATCH v2 04/17] target/sparc: convert to DisasContextBase Emilio G. Cota
2018-04-10  3:22   ` Richard Henderson
2018-04-06 18:19 ` [Qemu-devel] [PATCH v2 05/17] target/sparc: convert to TranslatorOps Emilio G. Cota
2018-04-10  3:24   ` Richard Henderson
2018-04-06 18:19 ` [Qemu-devel] [PATCH v2 06/17] target/mips: convert to DisasJumpType Emilio G. Cota
2018-04-10  3:56   ` Richard Henderson
2018-04-10 14:23     ` Emilio G. Cota
2018-04-10 23:27       ` Richard Henderson
2018-04-11 16:30         ` Emilio G. Cota
2018-04-06 18:19 ` [Qemu-devel] [PATCH v2 07/17] target/mips: convert to DisasContextBase Emilio G. Cota
2018-04-10  3:57   ` Richard Henderson
2018-04-06 18:19 ` [Qemu-devel] [PATCH v2 08/17] target/mips: use *ctx for DisasContext Emilio G. Cota
2018-04-10  3:57   ` Richard Henderson
2018-04-06 18:19 ` [Qemu-devel] [PATCH v2 09/17] target/mips: convert to TranslatorOps Emilio G. Cota
2018-04-10  4:02   ` Richard Henderson
2018-04-06 18:19 ` [Qemu-devel] [PATCH v2 10/17] target/s390x: convert to DisasJumpType Emilio G. Cota
2018-04-06 18:19 ` [Qemu-devel] [PATCH v2 11/17] target/s390x: convert to DisasContextBase Emilio G. Cota
2018-04-10  4:07   ` Richard Henderson
2018-04-06 18:19 ` [Qemu-devel] [PATCH v2 12/17] target/s390x: convert to TranslatorOps Emilio G. Cota
2018-04-10  4:10   ` Richard Henderson
2018-04-06 18:19 ` [Qemu-devel] [PATCH v2 13/17] target/openrisc: convert to DisasContextBase Emilio G. Cota
2018-04-10  4:13   ` Richard Henderson
2018-04-06 18:19 ` [Qemu-devel] [PATCH v2 14/17] target/openrisc: convert to TranslatorOps Emilio G. Cota
2018-04-10  4:23   ` Richard Henderson
2018-04-06 18:19 ` [Qemu-devel] [PATCH v2 15/17] target/riscv: convert to DisasJumpType Emilio G. Cota
2018-04-09 14:03   ` Bastian Koppelmann
2018-04-13  4:24   ` Richard Henderson
2018-04-06 18:19 ` [Qemu-devel] [PATCH v2 16/17] target/riscv: convert to DisasContextBase Emilio G. Cota
2018-04-09 14:22   ` Bastian Koppelmann
2018-04-09 16:01     ` Emilio G. Cota
2018-04-13  4:36   ` Richard Henderson
2018-04-06 18:20 ` [Qemu-devel] [PATCH v2 17/17] target/riscv: convert to TranslatorOps Emilio G. Cota
2018-04-10  1:24   ` Richard Henderson
2018-04-10 12:59     ` Emilio G. Cota
2018-04-10 14:05       ` Eric Blake
2018-04-10 14:38         ` Emilio G. Cota [this message]
2018-04-13  4:40   ` Richard Henderson
2018-04-06 18:39 ` [Qemu-devel] [PATCH v2 00/17] Translation loop conversion for sh4/sparc/mips/s390x/openrisc/riscv targets no-reply
2018-04-09 14:01 ` Bastian Koppelmann
2018-04-09 16:11   ` Emilio G. Cota
2018-04-10  4:24     ` Richard Henderson
2018-04-10 13:03       ` Emilio G. Cota
2018-04-10 13:16         ` Bastian Koppelmann
2018-04-10 13:40           ` Emilio G. Cota
2018-04-10 13:45             ` Bastian Koppelmann
2018-04-10 23:33               ` 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=20180410143858.GB22989@flamenco \
    --to=cota@braap.org \
    --cc=eblake@redhat.com \
    --cc=kbastian@mail.uni-paderborn.de \
    --cc=mjc@sifive.com \
    --cc=palmer@sifive.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=sagark@eecs.berkeley.edu \
    /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).