From: 陳韋任 <chenwj@iis.sinica.edu.tw>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>, Alexander Graf <agraf@suse.de>
Subject: Re: [Qemu-devel] throwing away translated code on CPU reset
Date: Fri, 13 Jan 2012 15:55:16 +0800 [thread overview]
Message-ID: <20120113075516.GA2355@cs.nctu.edu.tw> (raw)
In-Reply-To: <CAFEAcA9atCC11RiuORHAF7Nf6xnXBCDCM=GM7jDfOW9bsm7KYg@mail.gmail.com>
On Thu, Jan 12, 2012 at 02:00:38PM +0000, Peter Maydell wrote:
> When doing TCG code translation, the target-foo translate.c
> code is allowed to bake assumptions into the generated code from
> the current values of various fields in the CPUState. This then
> imposes the requirement that if the field is changed then tb_flush
> must be called to throw away the now-incorrect generated code.
>
> However, cpu_reset() changes (unsurprisingly) lots of fields in
> the CPUState, but it doesn't call tb_flush()...
I dig what tlb_flush does further and think maybe we don't need to call tb_flush
when tlb_flush is called.
First, look at tlb_flush (exec.c). It clears env's tb_jmp_cache which use GHA
as an index to search if there is a translated code. Since tb_jmp_cache is reset
now, QEMU is forced to call tb_find_slow which uses GPA as the index.
In tb_find_slow's for loop, it compares hit TranslationBlock's various fields
with current values. To be more specific,
static TranslationBlock *tb_find_slow(...) {
for(;;) {
tb = *ptb1;
if (!tb)
goto not_found;
if (tb->pc == pc && <--- Here
tb->page_addr[0] == phys_page1 &&
tb->cs_base == cs_base &&
tb->flags == flags) {
}
}
}
What do you think?
Regards,
chenwj
--
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667
Homepage: http://people.cs.nctu.edu.tw/~chenwj
next prev parent reply other threads:[~2012-01-13 7:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-12 14:00 [Qemu-devel] throwing away translated code on CPU reset Peter Maydell
2012-01-12 14:18 ` Andreas Färber
2012-01-13 7:55 ` 陳韋任 [this message]
2012-01-13 9:08 ` Peter Maydell
2012-01-14 14:48 ` Aurelien Jarno
2012-01-15 16:43 ` Peter Maydell
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=20120113075516.GA2355@cs.nctu.edu.tw \
--to=chenwj@iis.sinica.edu.tw \
--cc=agraf@suse.de \
--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).