From patchwork Fri Aug 23 07:59:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Alrae X-Patchwork-Id: 269328 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BD9BA2C009A for ; Fri, 23 Aug 2013 18:01:33 +1000 (EST) Received: from localhost ([::1]:35603 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VCmJH-0006T5-Hv for incoming@patchwork.ozlabs.org; Fri, 23 Aug 2013 04:01:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54922) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VCmIv-0006So-1l for qemu-devel@nongnu.org; Fri, 23 Aug 2013 04:01:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VCmIl-0000Sc-2m for qemu-devel@nongnu.org; Fri, 23 Aug 2013 04:01:08 -0400 Received: from multi.imgtec.com ([194.200.65.239]:8090) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VCmIk-0000SA-SN for qemu-devel@nongnu.org; Fri, 23 Aug 2013 04:00:58 -0400 From: Leon Alrae To: Date: Fri, 23 Aug 2013 08:59:51 +0100 Message-ID: <1377244791-56856-1-git-send-email-leon.alrae@imgtec.com> X-Mailer: git-send-email 1.7.5.4 MIME-Version: 1.0 X-Originating-IP: [192.168.14.85] X-SEF-Processed: 7_3_0_01192__2013_08_23_09_00_57 X-detected-operating-system: by eggs.gnu.org: Windows XP X-Received-From: 194.200.65.239 Cc: james.hogan@imgtec.com, paul.burton@imgtec.com, yongbok.kim@imgtec.com, cristian.cuna@imgtec.com, leon.alrae@imgtec.com, aurelien@aurel32.net Subject: [Qemu-devel] [PATCH] mips/malta: prevent writes to reset flash mapping faulting X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: James Hogan Commit a427338 (mips_malta: correct reading MIPS revision at 0x1fc00010) altered the behaviour of the monitor flash mapping at the reset address by making it read only. However this causes data bus error exceptions when it is written to since it is effectively unassigned memory for writes. This isn't how the real hardware behaves. That memory can be written to (even with the MFWR jumper not fitted) and the new value read back from, but it doesn't get written back to the monitor flash so is volatile. This is fixed by converting the bios copy from read only ram to a bios device with a nop write callback. Signed-off-by: James Hogan Cc: Paul Burton Cc: Leon Alrae Cc: Aurelien Jarno Signed-off-by: Leon Alrae --- hw/mips/mips_malta.c | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-) diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c index f8d064c..9e721d3 100644 --- a/hw/mips/mips_malta.c +++ b/hw/mips/mips_malta.c @@ -873,6 +873,16 @@ static void cpu_request_exit(void *opaque, int irq, int level) } } +static void monflash_copy_mem_write(void *opaque, hwaddr ram_addr, + uint64_t val, unsigned size) +{ +} + +static const MemoryRegionOps monflash_copy_mem_ops = { + .write = monflash_copy_mem_write, + .endianness = DEVICE_NATIVE_ENDIAN, +}; + static void mips_malta_init(QEMUMachineInitArgs *args) { @@ -1043,13 +1053,13 @@ void mips_malta_init(QEMUMachineInitArgs *args) * handled by an overlapping region as the resulting ROM code subpage * regions are not executable. */ - memory_region_init_ram(bios_copy, NULL, "bios.1fc", BIOS_SIZE); + memory_region_init_rom_device(bios_copy, NULL, &monflash_copy_mem_ops, NULL, + "bios.1fc", BIOS_SIZE); if (!rom_copy(memory_region_get_ram_ptr(bios_copy), FLASH_ADDRESS, BIOS_SIZE)) { memcpy(memory_region_get_ram_ptr(bios_copy), memory_region_get_ram_ptr(bios), BIOS_SIZE); } - memory_region_set_readonly(bios_copy, true); memory_region_add_subregion(system_memory, RESET_ADDRESS, bios_copy); /* Board ID = 0x420 (Malta Board with CoreLV) */