From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56355) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z7box-0001BV-0P for qemu-devel@nongnu.org; Tue, 23 Jun 2015 23:57:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z7bov-0007rz-Ul for qemu-devel@nongnu.org; Tue, 23 Jun 2015 23:57:54 -0400 Received: from mail-pa0-x22d.google.com ([2607:f8b0:400e:c03::22d]:33573) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z7bov-0007rt-Ot for qemu-devel@nongnu.org; Tue, 23 Jun 2015 23:57:53 -0400 Received: by padev16 with SMTP id ev16so20346888pad.0 for ; Tue, 23 Jun 2015 20:57:53 -0700 (PDT) From: Peter Crosthwaite Date: Tue, 23 Jun 2015 20:57:37 -0700 Message-Id: <22bbba694f8cdd2ccac41019d1be8412abff62ad.1435117090.git.crosthwaite.peter@gmail.com> In-Reply-To: References: In-Reply-To: References: Subject: [Qemu-devel] [PATCH qom v4 6/7] disas: cris: Fix 0 buffer length case List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, Peter Crosthwaite , claudio.fontana@huawei.com, edgar.iglesias@gmail.com, afaerber@suse.de, rth@twiddle.net 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