From patchwork Mon Oct 4 09:23:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: QiaoChong X-Patchwork-Id: 66643 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 80F7BB70AE for ; Mon, 4 Oct 2010 20:57:14 +1100 (EST) Received: from localhost ([127.0.0.1]:35120 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P2hnC-0002dR-9b for incoming@patchwork.ozlabs.org; Mon, 04 Oct 2010 05:57:10 -0400 Received: from [140.186.70.92] (port=42509 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P2hOR-0005l8-2G for qemu-devel@nongnu.org; Mon, 04 Oct 2010 05:32:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P2hNf-0007WQ-FI for qemu-devel@nongnu.org; Mon, 04 Oct 2010 05:30:48 -0400 Received: from [159.226.40.154] (port=45245 helo=mail.loongson.cn) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P2hNf-0007Vn-3Y for qemu-devel@nongnu.org; Mon, 04 Oct 2010 05:30:47 -0400 Received: from localhost.localdomain (unknown [10.2.1.99]) by mail.loongson.cn (Postfix) with ESMTPA id E1A45C622B; Mon, 4 Oct 2010 17:30:27 +0800 (CST) From: qiaochong To: qemu-devel@nongnu.org Date: Mon, 4 Oct 2010 17:23:06 +0800 Message-Id: <1286184186-24431-1-git-send-email-qiaochong@loongson.cn> X-Mailer: git-send-email 1.7.0.3.dirty X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1) Cc: qiaochong , aurelien@aurel32.net, rth@twiddle.net Subject: [Qemu-devel] [PATCH] add cacheflush in tcg_gen_code_search_pc. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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. Signed-off-by: qiaochong --- 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