qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: casmac <climber.cui@qq.com>
Cc: "Peter&nbsp;Maydell" <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Subject: Re: Why QEMU translates one instruction to a TB?
Date: Thu, 17 Sep 2020 09:41:14 +0100	[thread overview]
Message-ID: <874knwztg5.fsf@linaro.org> (raw)
In-Reply-To: <tencent_EAC696641F035EB7E9885302EAAE37455907@qq.com>


casmac <climber.cui@qq.com> writes:

> Hi all, 
> &nbsp;&nbsp; &nbsp; We try to add DSP architecure to QEMU 4.2. To load the  COFF format object file, we have added loader code to load content from 
> &nbsp;  the object file. The rom_add_blob() function is used. We firstly  analyze the COFF file to figure out which sections are chained
> &nbsp; together(so each chain forms a "memory blob"), and then allocate the memory blobs. 
> &nbsp; 
> &nbsp; The psuedo code looks like:
> &nbsp; 
> &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; for(i=0; i<BADTYPE; i++){
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(ary_sect_chain[i].exist) &nbsp; //there is a chain of sections to allocate 
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ary_sect_chain[i].mem_region = g_new(MemoryRegion, 1);
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; memory_region_init_ram(...);
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; memory_region_add_subregion(sysmem, ....);
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rom_add_blob(....);
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
> &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; }
> &nbsp; 
<snip>

> &nbsp; &nbsp; if (unlikely(entry-&gt;addr_code &amp; TLB_MMIO)) {
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; /* The region is not backed by
> RAM.&nbsp; */

This is the crux of it. If the address looked up isn't in a RAM region
then the TLB code can't assume a contiguous page of instructions or that
the instruction executed on one read will be the same on the next so it
will only execute a single instruction at a time and not cache the
resulting TB either forcing a fresh re-translation each time.

All TLB_MMIO access basically force the slow path.

I suspect there is something wrong in your memory region mappings.

-- 
Alex Bennée


      parent reply	other threads:[~2020-09-17  8:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <tencent_EAC696641F035EB7E9885302EAAE37455907@qq.com>
2020-09-17  7:38 ` Why QEMU translates one instruction to a TB? Philippe Mathieu-Daudé
2020-09-17  7:45 ` Philippe Mathieu-Daudé
     [not found]   ` <tencent_6FBC0FD37CA798D4766FE6B2822DAC3E2908@qq.com>
2020-09-18  9:39     ` Peter Maydell
2020-09-18 10:04     ` 回复: " Alex Bennée
2020-09-17  8:41 ` Alex Bennée [this message]

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=874knwztg5.fsf@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=climber.cui@qq.com \
    --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).