On 25 January 2012 19:25, Xin Tong <xerox.time.t...@gmail.com> wrote:
> as I mentioned. In my current implementation of coremu, the code could
> be executed when it is modified. so the modifications need to be
> atomic. I think I need a scratch area in which the restore_cpu_state
> needs to be generated while leaving the already generated code in
> tact. would this solve the problem ?

No, the code must be regenerated at the same absolute address,
because the TCG code generation routines might otherwise produce
different (different size!) output. Consider the case of a jump
instruction, where for example on x86 we might generate a short
or a longer instruction depending on how far the target was from
where we were writing the code.

It should be entirely fine to have code being executed while it
is being "modified", because the cpu_restore_state can only ever
write exactly identical bytes to memory that were there to start
with, so there will never be an issue with a core executing code
finding half an instruction, or with icache/dcache incoherence
on architectures which need explicit cache maintenance (ie non-x86).

-- PMM

Reply via email to