qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Steven <wangwangkang@gmail.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, "陳韋任 (Wei-Ren Chen)" <chenwj@iis.sinica.edu.tw>
Subject: Re: [Qemu-devel] qemu log function to print out the registers of the guest
Date: Thu, 16 Aug 2012 13:13:11 -0400	[thread overview]
Message-ID: <CAMTrTqXGFw=ickusCgov3274=_NnNCtWBeSMYK67B9AFDtNMYg@mail.gmail.com> (raw)
In-Reply-To: <CAFEAcA9UQk_BuGgLMZEEzfaQFj=XZ_B_cLsn1SMtqD=1Bs76_Q@mail.gmail.com>

On Thu, Aug 16, 2012 at 12:54 PM, Peter Maydell
<peter.maydell@linaro.org> wrote:
> On 16 August 2012 17:36, Steven <wangwangkang@gmail.com> wrote:
>> I would like to get a trace of guest memory access. So I can not use
>> "info registers".
>> What I want to do is that when tcg fetches a load instruction at
>> disas_insns(), the guest memory address should be calculated.
>
> You cannot calculate the guest memory address at the point where
> TCG is translating the load instruction. This is because that
> address depends on the values of guest registers at runtime.
> At translation time these values are not known. Also they may
> be different for different runs through the same generated code.

Thanks. Then what I thought is wrong.

>
> QEMU is a just-in-time translator (JIT). For a JIT it is
> important to remember the difference between:
>  * translation time. Here we know what the guest code (instructions)
> are, but we do not know what the guest CPU registers will be
>  * run time. This may be some time later, and we may execute
> the same code several times. We don't have any access to
> information about the guest code we are running unless
> we specifically recorded it at translation time.

Take this in_asm as example, mov 0x4(%ebx)  %eax. I saw the translated
host code for this single load instruction (using -d in_asm,out_asm)
are

OUT: [size=107]
0x4025d890:  mov    0x28(%r14),%rbp
0x4025d894:  add    $0xc,%rbp
0x4025d898:  mov    %ebp,%ebp
...
0x4025d8e8:  mov    %rbp,0x8(%r14)
0x4025d8ec:  xor    %eax,%eax
0x4025d8ee:  mov    $0x7fc1a598d176,%r10
0x4025d8f8:  jmpq   *%r10
So the run time function should be tcg_out_qemu_ld, right?
Could you provide some suggestion where I should add the record
information to help translate the guest memory address? Thanks.


>
> When you are reading (or trying to change) QEMU source code
> you need to know whether the QEMU code will be running at
> translation or run time. The answer affects what information
> you have access to, and what you can do to the guest.
>
> -- PMM

  reply	other threads:[~2012-08-16 17:13 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-16  7:21 [Qemu-devel] qemu log function to print out the registers of the guest Steven
2012-08-16  8:02 ` 陳韋任 (Wei-Ren Chen)
2012-08-16 16:36   ` Steven
2012-08-16 16:54     ` Peter Maydell
2012-08-16 17:13       ` Steven [this message]
2012-08-16 17:15         ` Peter Maydell
2012-08-16 17:26           ` Steven
2012-08-16 19:31       ` Steven
2012-08-17 10:26         ` 陳韋任 (Wei-Ren Chen)
2012-08-16 17:00     ` Max Filippov
2012-08-16 17:29       ` Steven
2012-08-16 17:37         ` Max Filippov
2012-08-16 17:43           ` Max Filippov
2012-08-16 17:49             ` Steven
2012-08-16 18:31               ` Max Filippov
2012-08-16 21:18                 ` Max Filippov
2012-08-17  5:38                   ` Steven
2012-08-17  6:38                     ` Max Filippov
2012-08-16 18:51               ` Laurent Desnogues
2012-08-16 19:02                 ` Steven
2012-08-17 11:14                   ` 陳韋任 (Wei-Ren Chen)
2012-08-17 11:57                     ` Max Filippov
2012-08-19  8:33                       ` 陳韋任 (Wei-Ren Chen)
2012-08-21  5:40                       ` Steven
2012-08-21  7:18                         ` Max Filippov
     [not found]                           ` <CAMTrTqVF0EGEqC8qZHOV5RHYxq=MHYuu_X0V5va5gkyaRQWJuw@mail.gmail.com>
2012-08-25 20:41                             ` Max Filippov
2012-08-27 16:15                               ` Steven
2012-08-28  3:14                                 ` 陳韋任 (Wei-Ren Chen)
2012-08-28  3:44                                   ` Steven
2012-08-28 10:48                                 ` 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='CAMTrTqXGFw=ickusCgov3274=_NnNCtWBeSMYK67B9AFDtNMYg@mail.gmail.com' \
    --to=wangwangkang@gmail.com \
    --cc=chenwj@iis.sinica.edu.tw \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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).