qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel]  The reason behind block linking constraint?
@ 2011-08-18  6:33 陳韋任
  2011-08-18  9:31 ` Max Filippov
  0 siblings, 1 reply; 12+ messages in thread
From: 陳韋任 @ 2011-08-18  6:33 UTC (permalink / raw)
  To: qemu-devel

Hi, all

  I am trying to figure out why QEMU put some constraints on block
linking (chaining). Take x86 as an example, there are two places
put constraints on block linking, gen_goto_tb and cpu_exec.

----------------- gen_goto_tb (target-i386/translate.c) ---------------
  /* NOTE: we handle the case where the TB spans two pages here */
  if ((pc & TARGET_PAGE_MASK) == (tb->pc & TARGET_PAGE_MASK) ||
      (pc & TARGET_PAGE_MASK) == ((s->pc - 1) & TARGET_PAGE_MASK))  {
      /* jump to same page: we can use a direct jump */
      tcg_gen_goto_tb(tb_num);
      gen_jmp_im(eip);
      tcg_gen_exit_tb((tcg_target_long)tb + tb_num);
  } else {
      /* jump to another page: currently not optimized */
      gen_jmp_im(eip);
      gen_eob(s);
  }
-----------------------------------------------------------------------

----------------------- cpu_exec (cpu-exec.c) -------------------------
  /* see if we can patch the calling TB. When the TB
     spans two pages, we cannot safely do a direct
     jump. */
  if (next_tb != 0 && tb->page_addr[1] == -1) {
      tb_add_jump((TranslationBlock *)(next_tb & ~3), next_tb & 3, tb);
  }
-----------------------------------------------------------------------

  Is it just because we cannot optimize block linking which crosses page
boundary, or there are some correctness/safety issues should be considered?

  I did some experiments myself. First, I removed the if-else condition
in gen_goto_tb (always go to if branch) and leave cpu_exec alone. In this
case, user mode works fine, but system mode crashes while booting linux.

  Then, I removed the "tb->page_addr[1]" check and leave gen_goto_tb
alone. This time, both user mode and system mode works fine. I use the
disk image and user mode tests downloaded from the website as the test
case.

  Could someone kindly explain why there are constraints on block
linking? Thanks!

Regards,
chenwj

-- 
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2011-09-27 13:27 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-18  6:33 [Qemu-devel] The reason behind block linking constraint? 陳韋任
2011-08-18  9:31 ` Max Filippov
2011-08-18  9:39   ` 陳韋任
2011-08-18 10:04     ` Max Filippov
2011-09-24  7:00       ` 陳韋任
2011-09-25 21:47         ` Max Filippov
2011-09-26 10:49           ` 陳韋任
2011-09-26 11:41             ` Max Filippov
2011-09-27  2:40               ` 陳韋任
2011-08-20 20:54   ` Rob Landley
2011-09-27  3:13     ` 陳韋任
2011-09-27 13:27       ` Rob Landley

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).