From patchwork Wed May 12 07:56:31 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 52367 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 6F7F1B7DC1 for ; Wed, 12 May 2010 19:47:25 +1000 (EST) Received: from localhost ([127.0.0.1]:46399 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OC8XB-0002ny-1w for incoming@patchwork.ozlabs.org; Wed, 12 May 2010 05:47:21 -0400 Received: from [140.186.70.92] (port=57758 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OC8Vl-0002lg-Dg for qemu-devel@nongnu.org; Wed, 12 May 2010 05:45:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OC8Vg-0006g6-Pi for qemu-devel@nongnu.org; Wed, 12 May 2010 05:45:53 -0400 Received: from fmmailgate01.web.de ([217.72.192.221]:48018) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OC6o4-0006IG-Dt for qemu-devel@nongnu.org; Wed, 12 May 2010 03:56:41 -0400 Received: from smtp08.web.de ( [172.20.5.216]) by fmmailgate01.web.de (Postfix) with ESMTP id AE5B01595396C; Wed, 12 May 2010 09:56:36 +0200 (CEST) Received: from [88.64.22.236] (helo=[192.168.1.10]) by smtp08.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #4) id 1OC6o0-0007ZE-00; Wed, 12 May 2010 09:56:36 +0200 Message-ID: <4BEA5F2F.8090107@web.de> Date: Wed, 12 May 2010 09:56:31 +0200 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: Michael Walle References: <201004222338.06194.michael@walle.cc> <4BD14B05.3050301@web.de> <201005072257.57198.michael@walle.cc> In-Reply-To: <201005072257.57198.michael@walle.cc> X-Enigmail-Version: 0.95.7 X-Sender: jan.kiszka@web.de X-Provags-ID: V01U2FsdGVkX19XnTWs41leobavMNMJH9hUeRXAGvIAuISJRW2e cBhjGrmYDt5bycqvgdvbf9mpLSkWUKsuFgje6BFQMoSmgjZbx2 aUYne/ahU= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] Re: Commit 9c9bb6c89d4 breaks code execution from flash 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 Michael Walle wrote: > [sorry didn't see the CC to the mailinglist] > > Am Friday 23 April 2010 09:23:49 schrieb Jan Kiszka: >> Michael Walle wrote: >>> Hi Jan, >>> >>> your commit "Optimize consecutive CFI02 writes by remapping memory >>> lazily" breaks the code execution from flash. >>> >>> If you write to the flash, the flash will switch into I/O mode. Now if >>> code is executed from this flash, a cpu_abort will be raised ("Trying to >>> execute code outside RAM or ROM"). >> Hmm, guess I didn't test execute-in-place back then. Do you happen to >> have a test case for this scenario? I'll look into this. > Only for my qemu-lm32 port.. But reading the flash id, while executing this > code from flash should trigger the bug. > OK, that was a hard nut. After various dead ends, I think I found an possible solution. Can you give this a try? pflash_register_memory(pfl, 1); @@ -185,7 +185,7 @@ static uint32_t pflash_read (pflash_t *pfl, target_phys_addr_t offset, default: goto flash_read; } - DPRINTF("%s: ID " TARGET_FMT_pld " %x\n", __func__, boff, ret); + DPRINTF("%s: ID " TARGET_FMT_plx " %x\n", __func__, boff, ret); break; case 0xA0: case 0x10: Still requires proper patch split up, and I need to think about possible side effects. Jan diff --git a/exec-all.h b/exec-all.h index 1016de2..b070da9 100644 --- a/exec-all.h +++ b/exec-all.h @@ -329,6 +329,10 @@ static inline tb_page_addr_t get_page_addr_code(CPUState *env1, target_ulong add if (unlikely(env1->tlb_table[mmu_idx][page_index].addr_code != (addr & TARGET_PAGE_MASK))) { ldub_code(addr); + if (unlikely(env1->tlb_table[mmu_idx][page_index].addr_code & + TLB_INVALID_MASK)) { + ldub_code(addr); + } } pd = env1->tlb_table[mmu_idx][page_index].addr_code & ~TARGET_PAGE_MASK; if (pd > IO_MEM_ROM && !(pd & IO_MEM_ROMD)) { diff --git a/hw/pflash_cfi02.c b/hw/pflash_cfi02.c index f3d3f41..201e410 100644 --- a/hw/pflash_cfi02.c +++ b/hw/pflash_cfi02.c @@ -40,7 +40,7 @@ #include "qemu-timer.h" #include "block.h" -//#define PFLASH_DEBUG +#define PFLASH_DEBUG #ifdef PFLASH_DEBUG #define DPRINTF(fmt, ...) \ do { \ @@ -112,7 +112,7 @@ static uint32_t pflash_read (pflash_t *pfl, target_phys_addr_t offset, DPRINTF("%s: offset " TARGET_FMT_plx "\n", __func__, offset); ret = -1; - if (pfl->rom_mode) { + if (!pfl->rom_mode) { /* Lazy reset of to ROMD mode */ if (pfl->wcycle == 0)