qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 4/8] disas: Support the Capstone disassembler


From: Richard Henderson
Subject: Re: [Qemu-devel] [PATCH v2 4/8] disas: Support the Capstone disassembler library
Date: Tue, 26 Sep 2017 11:20:07 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0

On 09/19/2017 08:03 AM, Richard Henderson wrote:
> +    while (1) {
> +        /* We want to read memory for one insn, but generically we do not
> +           know how much memory that is.  We have a small buffer which is
> +           known to be sufficient for all supported targets.  Try to not
> +           read beyond the page, Just In Case.  For even more simplicity,
> +           ignore the actual target page size and use a 1k boundary.  If
> +           that turns out to be insufficient, we'll come back around the
> +           loop and read more.  */
> +        uint64_t epc = QEMU_ALIGN_UP(pc + csize, 1024);
> +        size_t tsize = MIN(sizeof(cap_buf) - csize, epc - pc);
...
> +        assert(tsize != 0);

By inspection, epc must be computed from pc + csize + 1.
If csize = 0 and pc % 1024 == 0, epc == pc and tsize == 0,
which will assert.


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]