qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Xin Tong <xerox.time.tech@gmail.com>
Cc: qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] TCG register allocator
Date: Wed, 25 Jan 2012 19:23:10 +0000	[thread overview]
Message-ID: <CAFEAcA9BkeMmmQ-eDP6FSRC0UyiDADwbW_uVmNhrm=GhZDOjJg@mail.gmail.com> (raw)
In-Reply-To: <CALKntY0b6m=9W1uJnfHJakQPTnnYr4e14L8Zc=bmohdfw5LvvA@mail.gmail.com>

On 25 January 2012 19:10, Xin Tong <xerox.time.tech@gmail.com> wrote:
Peter Maydell wrote:
>> cpu_restore_state() calls gen_intermediate_code_pc() to
>> request a retranslation of the TB with extra info to allow
>> us to do a host-PC-to-guest-PC lookup
>>  * Note that gen_intermediate_code_pc() overwrites the generated
>> code that already exists in memory, and stops as soon as it
>> reaches the point of the exception. This is harmless because
>> we are just rewriting the same bytes to memory that were there
>> already, but disastrous if...

> in the case you described above, which code guarantees that the
> re-generated code is laid down in the place where the old code is.
> This has to be do somewhere in tcg.

Actually, it's not in TCG but in the bit of QEMU which calls TCG.

When we first translate a block of code we decide where its
generated code will sit (in exec.c:tb_gen_code()) and set tb->tc_ptr
to point at this location. Then when translate-all.c:cpu_gen_code()
does this first translation it passes tcg_gen_code() a gen_code_buf
argument which is this tb->tc_ptr.
Later if we need to do a restore, translate-all.c:cpu_restore_state()
calls tcg_gen_code_search_pc(), and again it passes a gen_code_buf
argument for where generated code should be written. It uses tb->tc_ptr
for the TranslationBlock, so it will always be at the same place.

-- PMM

  parent reply	other threads:[~2012-01-25 19:23 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-25 14:24 [Qemu-devel] TCG register allocator Xin Tong
2012-01-25 15:19 ` Peter Maydell
2012-01-25 15:42   ` Xin Tong
2012-01-25 15:49     ` Peter Maydell
2012-01-25 15:54       ` Xin Tong
2012-01-25 15:55         ` Xin Tong
2012-01-25 16:22           ` Peter Maydell
2012-01-25 18:58             ` Xin Tong
2012-01-25 19:10               ` Xin Tong
2012-01-25 19:18                 ` James Greensky
2012-01-25 19:19                   ` Xin Tong
2012-01-25 19:23                 ` Peter Maydell [this message]
2012-01-25 19:25                   ` Xin Tong
2012-01-25 19:33                     ` Peter Maydell
2012-01-31  3:09               ` 陳韋任
2012-01-25 16:03         ` Max Filippov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFEAcA9BkeMmmQ-eDP6FSRC0UyiDADwbW_uVmNhrm=GhZDOjJg@mail.gmail.com' \
    --to=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=xerox.time.tech@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).