qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefano Bonifazi <stefboombastic@gmail.com>
To: Blue Swirl <blauwirbel@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] TCG flow vs dyngen
Date: Tue, 14 Dec 2010 21:17:35 +0100	[thread overview]
Message-ID: <4D07D0DF.3090303@gmail.com> (raw)
In-Reply-To: <AANLkTi=e-BTWSHmAAKKMyBCtQfMvGwPP-JewuToibuk8@mail.gmail.com>

On 12/11/2010 03:44 PM, Blue Swirl wrote:
> On Sat, Dec 11, 2010 at 2:32 PM, Stefano Bonifazi
> <stefboombastic@gmail.com>  wrote:
>> Where does the execution of host binary take place in the previous list of events?  Between point 5) and 6) ?
>> After 6) ? In what QEMU source code file/function does the final execution of host binary take place?
>>
>> In the previous list of events, when does the translator try to chain the current TB with previous ones?  Before TCG generates the binary in order to feed it with "linked micro code"?
> All of this happens in cpu-exec.c:581 to 618.
Hi!
Thank you very much! Knowing exactly where I should check, in a so big 
project helped me very much!!
Anyway after having spent more than 2 days on that code I still can't 
understand how it works the real execution:

in cpu-exec.c : cpu_exec_nocache i find:

> /* execute the generated code */
>     next_tb = tcg_qemu_tb_exec(tb->tc_ptr);
and in cpu-exec.c : cpu_exec

> /* execute the generated code */
>
>                     next_tb = tcg_qemu_tb_exec(tc_ptr);
so I thought tcg_qemu_tb_exec "function" should do the work of executing 
the translated binary in the host.
But then I found out it is just a define in tcg.h:

> #define tcg_qemu_tb_exec(tb_ptr) ((long REGPARM (*)(void 
> *))code_gen_prologue)(tb_ptr)
and again in exec.c

> uint8_t code_gen_prologue[1024] code_gen_section;
Maybe I have some problems with that C syntax, but I really don't 
understand what happens there.. how the execution happens!

Maybe I am too stuck to my idea of a common emulator "fetch -> decode -> 
execute" where an addition would be implemented simply as "env->regC = 
env->regA +env->regB" ... where this C instruction would be compiled 
offline into host machine binary by host compiler.. so the emulator 
would be a monolith block of host code just with branches for the 
different opcodes that would come from the target binary loaded at runtime..
Here instead  with QEMU/TCG I understood that at runtime the target 
binary is translated into host binary (somehow) .. but then.. how can 
this new host binary be run? Shall the host code at runtime do some sort 
of (assembly speaking) branch jump to an area of memory with new host 
binary instructions .. and then jump back to the old process binary code?
If so, can you explain me how this happens in those lines of code?
I am just a student.. unluckily at university they just tell you that a 
cpu follows some sort of "fetch ->decode->execute" flow .. but then you 
open QEMU.. and wow there is a huge gap for understanding it, and no 
books where to study it! ;)
Please help me understanding it :)
Thank you very very much in advance!
Stefano B.

  reply	other threads:[~2010-12-14 20:17 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-10 21:26 [Qemu-devel] TCG flow vs dyngen Stefano Bonifazi
2010-12-11 11:02 ` Blue Swirl
2010-12-11 12:29   ` Stefano Bonifazi
2010-12-11 13:11     ` Blue Swirl
2010-12-11 14:32       ` Stefano Bonifazi
2010-12-11 14:44         ` Blue Swirl
2010-12-14 20:17           ` Stefano Bonifazi [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-01-16 14:46 Raphael Lefevre
2011-01-16 15:21 ` Stefano Bonifazi
2011-01-16 16:01   ` Raphaël Lefèvre
2011-01-16 16:43     ` Stefano Bonifazi
2011-01-16 18:29       ` Peter Maydell
2011-01-16 19:02         ` Stefano Bonifazi
2011-01-16 19:24           ` Peter Maydell
2011-01-16 20:50           ` Stefano Bonifazi
2011-01-16 21:08             ` Raphaël Lefèvre
2011-01-17 11:59             ` Lluís
2011-01-16 19:16       ` Raphaël Lefèvre
2011-01-23 21:50     ` Rob Landley
2011-01-23 22:25       ` Stefano Bonifazi
2011-01-23 23:40         ` Rob Landley
2011-01-24 10:17           ` Stefano Bonifazi
2011-01-24 18:20             ` Rob Landley
2011-01-24 21:16               ` Stefano Bonifazi
2011-01-25  1:19                 ` Rob Landley
2011-01-25  8:53                   ` Stefano Bonifazi
2011-01-24 14:32       ` Peter Maydell
2011-01-24 14:56         ` Stefano Bonifazi
2011-01-24 15:15           ` Lluís
2011-01-24 18:02           ` Dushyant Bansal
2011-01-24 19:38             ` Stefano Bonifazi
2011-01-25  7:56               ` Dushyant Bansal
2011-01-25  9:04                 ` Stefano Bonifazi
2011-01-25  9:05                   ` Edgar E. Iglesias
2011-01-25  9:28                     ` Stefano Bonifazi

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=4D07D0DF.3090303@gmail.com \
    --to=stefboombastic@gmail.com \
    --cc=blauwirbel@gmail.com \
    --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).