From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39313) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YyCnm-0003gx-Ev for qemu-devel@nongnu.org; Fri, 29 May 2015 01:25:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YyCni-0004ZC-7o for qemu-devel@nongnu.org; Fri, 29 May 2015 01:25:50 -0400 Received: from mail-pa0-x22e.google.com ([2607:f8b0:400e:c03::22e]:33737) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YyCnh-0004Z3-RC for qemu-devel@nongnu.org; Fri, 29 May 2015 01:25:46 -0400 Received: by padbw4 with SMTP id bw4so43009684pad.0 for ; Thu, 28 May 2015 22:25:45 -0700 (PDT) Date: Fri, 29 May 2015 15:21:15 +1000 From: "Edgar E. Iglesias" Message-ID: <20150529052115.GH17116@toto> References: <0279412b5ad90c5aa113c349941b319b28672f1b.1432506704.git.crosthwaite.peter@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0279412b5ad90c5aa113c349941b319b28672f1b.1432506704.git.crosthwaite.peter@gmail.com> Subject: Re: [Qemu-devel] [PATCH v3 6/7] disas: cris: Fix 0 buffer length case List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Crosthwaite Cc: peter.maydell@linaro.org, Peter Crosthwaite , claudio.fontana@huawei.com, qemu-devel@nongnu.org, rth@twiddle.net, afaerber@suse.de, egdar.iglesias@gmail.com On Sun, May 24, 2015 at 03:47:19PM -0700, Peter Crosthwaite wrote: > Cris has the complication of variable length instructions and has > a check in place to clamp memory reads in case the disas request > doesn't have enough bytes for the instruction being disas'd. This > breaks down in the case where disassembling for the monitor where > the buffer length is defaulted to 0. > > The buffer length should never be zero for a regular target_disas, > so we can safely assume the 0 case is for the monitor in which case > consider the buffer length to be the max for cris instructions. > > Signed-off-by: Peter Crosthwaite Reviewed-by: Edgar E. Iglesias > --- > disas/cris.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/disas/cris.c b/disas/cris.c > index e6cff7a..1b76a09 100644 > --- a/disas/cris.c > +++ b/disas/cris.c > @@ -2575,9 +2575,9 @@ print_insn_cris_generic (bfd_vma memaddr, > If we can't get any data, or we do not get enough data, we print > the error message. */ > > - nbytes = info->buffer_length; > - if (nbytes > MAX_BYTES_PER_CRIS_INSN) > - nbytes = MAX_BYTES_PER_CRIS_INSN; > + nbytes = info->buffer_length ? info->buffer_length > + : MAX_BYTES_PER_CRIS_INSN; > + nbytes = MIN(nbytes, MAX_BYTES_PER_CRIS_INSN); > status = (*info->read_memory_func) (memaddr, buffer, nbytes, info); > > /* If we did not get all we asked for, then clear the rest. > -- > 1.9.1 > >