qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] Question regarding self-modifying code.


From: farmdve
Subject: Re: [Qemu-devel] Question regarding self-modifying code.
Date: Thu, 14 Jan 2016 12:15:29 +0200

Sorry about that. Somehow Google decided it should reply to you, rather than the mailing list. It was an honest mistake.

Original question is below


I am unable to get this part here if (!(tb_end <= start || tb_start >= end)) in tb_invalidate_phys_page_range

What would happen if code forward modifies itself, but that condition evaluates to true? 

Then this piece here won't get executed

> #ifdef TARGET_HAS_PRECISE_SMC
            if (current_tb_not_found) {
                current_tb_not_found = 0;
                current_tb = NULL;
                if (cpu->mem_io_pc) {
                    /* now we have a real cpu fault */
                    current_tb = tb_find_pc(uc, cpu->mem_io_pc);
                }
            }
           if (current_tb == tb &&
                (current_tb->cflags & CF_COUNT_MASK) != 1) {
                /* If we are modifying the current TB, we must stop
                its execution. We could be more precise by checking
                that the modification is after the current PC, but it
                would require a specialized function to partially
                restore the CPU state */

               current_tb_modified = 1;
                // self-modifying code will restore state from TB
                cpu_restore_state_from_tb(cpu, current_tb, cpu->mem_io_pc);
                cpu_get_tb_cpu_state(env, &current_pc, &current_cs_base,
                                     &current_flags);
           }
#endif /* TARGET_HAS_PRECISE_SMC */

It just so happens I am experiencing such a case.

On 14 January 2016 at 11:58, Peter Maydell <address@hidden> wrote:
On 14 January 2016 at 00:37, farmdve <address@hidden> wrote:
> I am unable to get this part here if (!(tb_end <= start || tb_start >= end))
> in tb_invalidate_phys_page_range
>
> What would happen if code forward modifies itself, but that condition
> evaluates to true?

Please can you send questions to the mailing list, not to
me personally. That way anybody who knows and has time to
answer can do so.

thanks
-- PMM


reply via email to

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