From: Aurelien Jarno <aurelien@aurel32.net>
To: qiaochong <qiaochong@loongson.cn>
Cc: qemu-devel@nongnu.org, rth@twiddle.net
Subject: Re: [Qemu-devel] [PATCH] add cacheflush in tcg_gen_code_search_pc.
Date: Fri, 7 Jan 2011 00:02:27 +0100 [thread overview]
Message-ID: <20110106230227.GA7242@volta.aurel32.net> (raw)
In-Reply-To: <1286184186-24431-1-git-send-email-qiaochong@loongson.cn>
Hi,
On Mon, Oct 04, 2010 at 05:23:06PM +0800, qiaochong wrote:
> Without cacheflush,qemu sometimes fail with segment fault on loongson
> cpu,which often happens when linux begin to run init.Because user
> porgram tlb refill,tlbl,tlbs,tlbm exception will often happen,
> cpu_restore_state,tcg_gen_code-pc will be called frequently.
It should not be needed to flush the cache after code retranslation, as
it is not supposed to change the code. The problem you see there is
actually a bug in the code generation that make the code to be
(temporarily) different during the code retranslation.
See http://lists.nongnu.org/archive/html/qemu-devel/2011-01/msg00552.html
and http://lists.nongnu.org/archive/html/qemu-devel/2011-01/msg00553.html
for more details.
Aurelien
> Signed-off-by: qiaochong <qiaochong@loongson.cn>
> ---
> tcg/tcg.c | 7 ++++++-
> 1 files changed, 6 insertions(+), 1 deletions(-)
>
> diff --git a/tcg/tcg.c b/tcg/tcg.c
> index e0a9030..b5e274c 100644
> --- a/tcg/tcg.c
> +++ b/tcg/tcg.c
> @@ -2120,7 +2120,12 @@ int tcg_gen_code(TCGContext *s, uint8_t *gen_code_buf)
> Return -1 if not found. */
> int tcg_gen_code_search_pc(TCGContext *s, uint8_t *gen_code_buf, long offset)
> {
> - return tcg_gen_code_common(s, gen_code_buf, offset);
> + int ret;
> + ret = tcg_gen_code_common(s, gen_code_buf, offset);
> + /* flush instruction cache */
> + flush_icache_range((unsigned long)gen_code_buf,
> + (unsigned long)s->code_ptr);
> + return ret;
> }
>
> #ifdef CONFIG_PROFILER
> --
> 1.7.0.3.dirty
>
>
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien@aurel32.net http://www.aurel32.net
prev parent reply other threads:[~2011-01-06 23:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-04 9:23 [Qemu-devel] [PATCH] add cacheflush in tcg_gen_code_search_pc qiaochong
2011-01-06 23:02 ` Aurelien Jarno [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=20110106230227.GA7242@volta.aurel32.net \
--to=aurelien@aurel32.net \
--cc=qemu-devel@nongnu.org \
--cc=qiaochong@loongson.cn \
--cc=rth@twiddle.net \
/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).