qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v21 4/7] target/avr: Add instruction translation


From: Richard Henderson
Subject: Re: [Qemu-devel] [PATCH v21 4/7] target/avr: Add instruction translation
Date: Mon, 10 Jun 2019 13:50:02 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0

On 6/6/19 12:30 PM, Michael Rolnik wrote:
> +        if ((ctx.cpc & (TARGET_PAGE_SIZE - 1)) == 0) {
> +            break; /* page boundary */
> +        }

This test isn't right, because this ended the TB if the *first* instruction was
located on the page boundary.  It also fails to allow for a 32-bit opcode to
span 0xff - 0x101, since we did not see an instruction boundary at 0x100.

Since there is no MMU, we do not have to protect against permissions changes.
All we have to worry about is QEMU's code that detects self-modifying code.
This requires the code for each TranslationBlocks be contained within no more
than two pages.  Therefore,

    /* Do not allow the next insn to cross into a third code page.  */
    if ((ctx.npc - pc_start) * 2 >= TARGET_PAGE_SIZE - 4) {
        break;
    }

is the better condition.  Subtracting 4 allows for the next instruction to be a
32-bit opcode.  Limiting to TARGET_PAGE_SIZE allows pc_start to be located
anywhere in the first code page without allowing npc to cross into a third code
page.


r~



reply via email to

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