From patchwork Wed Dec 13 17:52:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 121801 Delivered-To: patches@linaro.org Received: by 10.140.22.227 with SMTP id 90csp5779230qgn; Wed, 13 Dec 2017 09:52:39 -0800 (PST) X-Google-Smtp-Source: ACJfBotatjJnBq3TW/WpCLI8g27T8oyJdNnACgvmhuYMYrNyGlg8IZs9hcMKDYI/oFBjxwSN9Itu X-Received: by 10.101.90.138 with SMTP id c10mr5955150pgt.441.1513187559462; Wed, 13 Dec 2017 09:52:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513187559; cv=none; d=google.com; s=arc-20160816; b=xiK+HFo1zVSbPCJpvJU2QQ1rU6KtCVYUUPCPamUvhwp1BkNJVdpmU/9vosc8b68D4f hmzUx5emdDJM4d8XzW2VjEA1mwF3dINmIyt+o3zpxHWq1IkPqtR66Q+YXMN8hVJf5GpI qL1IeFQor+Uvg9Hu8MkI7UPTJKVWt7JIl6GHi0VtDpKOw1RaefzRkN0VPmFSOGMZyHi3 Q70JWiNZFZ6NTuMnCIAywlcrHr2Ree10s3WPP6DL+MXhgYDHDUOXejRaAnr0A+WM1xDf ze3pyimJoJ/daHbeJnw8wqzGtyYZlaequ0XvrBKAyf6NGhPTMi8ipPMa33mS+djdpVsK X/Ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=/sdnIQJa4p1fTvFWMoBoWF4vhTfrKggMgvJP/XaH9ZY=; b=lHBBJxIKCmWfNY3e2ktCTEf+eZ17e6fMgA7a0yikTuoYv8vYzvPQ3Yhok0a9I0kQTZ G/3mIYGAZTSYvUSb7oEZq4pBqcIefh70mqDu+KbVC1b8ei7teImDjzouewP9jyJH1+8y q5NrdTILC9SNyGaQvzY68RetWbLo/4rmWATgD+eFa9vO1Q8KbY8IMXGZQSq4paLkKvWf XgJm52SdnzV2WnDDHwJywL0Fb0IPFtuEPduXcAArsx5m/rMpsk4bC7yDAqAgrfzfqfxf CL1KK2S5cLe4XdoLX8MVPU41su2YXJdx2zujejwc9/YPGnfsgfUu/1RIi/RgWZFi0V/z gblg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by mx.google.com with ESMTPS id bf4si1736404plb.142.2017.12.13.09.52.38 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Dec 2017 09:52:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) client-ip=2001:8b0:1d0::2; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1ePBCp-0007VA-Sa; Wed, 13 Dec 2017 17:52:31 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Paolo Bonzini , Aurelien Jarno , Yongbok Kim , Paul Burton Subject: [PATCH 1/2] exec: Don't reuse unassigned_mem_ops for io_mem_rom Date: Wed, 13 Dec 2017 17:52:28 +0000 Message-Id: <1513187549-2435-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513187549-2435-1-git-send-email-peter.maydell@linaro.org> References: <1513187549-2435-1-git-send-email-peter.maydell@linaro.org> We set up the io_mem_rom special memory region using the unassigned_mem_ops structure; this is then used when a guest tries to write to ROM. This is incorrect, because the behaviour of unassigned memory may be different from that of ROM for writes. In particular, on some architectures writing to unassigned memory generates a guest exception, whereas writing to ROM is generally ignored. Use a special readonly_mem_ops for this purpose instead, so writes to ROM are ignored for all guest CPUs. Signed-off-by: Peter Maydell --- exec.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/exec.c b/exec.c index 03238a3..74b8727 100644 --- a/exec.c +++ b/exec.c @@ -2720,6 +2720,37 @@ static uint16_t dummy_section(PhysPageMap *map, FlatView *fv, MemoryRegion *mr) return phys_section_add(map, §ion); } +static void readonly_mem_write(void *opaque, hwaddr addr, + uint64_t val, unsigned size) +{ + /* Ignore any write to ROM. */ +} + +static bool readonly_mem_accepts(void *opaque, hwaddr addr, + unsigned size, bool is_write) +{ + return is_write; +} + +/* This will only be used for writes, because reads are special cased + * to directly access the underlying host ram. + */ +static const MemoryRegionOps readonly_mem_ops = { + .write = readonly_mem_write, + .valid.accepts = readonly_mem_accepts, + .endianness = DEVICE_NATIVE_ENDIAN, + .valid = { + .min_access_size = 1, + .max_access_size = 8, + .unaligned = false, + }, + .impl = { + .min_access_size = 1, + .max_access_size = 8, + .unaligned = false, + }, +}; + MemoryRegion *iotlb_to_region(CPUState *cpu, hwaddr index, MemTxAttrs attrs) { int asidx = cpu_asidx_from_attrs(cpu, attrs); @@ -2732,7 +2763,8 @@ MemoryRegion *iotlb_to_region(CPUState *cpu, hwaddr index, MemTxAttrs attrs) static void io_mem_init(void) { - memory_region_init_io(&io_mem_rom, NULL, &unassigned_mem_ops, NULL, NULL, UINT64_MAX); + memory_region_init_io(&io_mem_rom, NULL, &readonly_mem_ops, + NULL, NULL, UINT64_MAX); memory_region_init_io(&io_mem_unassigned, NULL, &unassigned_mem_ops, NULL, NULL, UINT64_MAX); From patchwork Wed Dec 13 17:52:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 121800 Delivered-To: patches@linaro.org Received: by 10.140.22.227 with SMTP id 90csp5779186qgn; Wed, 13 Dec 2017 09:52:36 -0800 (PST) X-Google-Smtp-Source: ACJfBot3bjTyZ9YpqpZseXjScVsIf/m0PKBmILjRr0Al5zR86pOKDsUL+TazNVZX9V/lidG5DVd6 X-Received: by 10.46.48.6 with SMTP id w6mr2059279ljw.10.1513187556161; Wed, 13 Dec 2017 09:52:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513187556; cv=none; d=google.com; s=arc-20160816; b=NPQbqhtXJtU7WX/CCrougjnbm8ZcBeSyliLXJFUN6NXd4xTtEghIrPp93uInhQr+Mw +MRxq9uYtOoMq2+RNPI+LArUidrntUOnI/ZXocodG5BYJQmncB475Vk+2R1WiOdzf9zM YkkJr3kqutDVbNx8+XnaqlsH4OO0P7gJg+5LoyECzrxQpgO4a1TNlurp3sqN4MEUvxcN Nfivyo9X3yk6DJfH9ofC9TNaq+7G/PthzPDDnWEqw59KHTtxlTnRk4K+NwqOmWK+8jqv hu9baPGI7jD3ImLbOlgAsHZxXtkTJD0FL9rNAolBpKCAyS5FBfQ41f2A7vsMh4M4bLBp gLYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=sktAE2zq8nRPYp0ubmH3UYbx+tviEMB+SQsc8W8j+yQ=; b=oJNVxyOss2Kp3sqmuTpbLzN6Iq362U5I4nHHUF+QQwAokhrh9Q+nmMtLeJZ8VYU1u7 q4ZxxUv3GMQKLR/k+nsDyJYsQA8qiNZ9wjJF/Lwu8CqMSRaXjNtaOKgzXIPsRzJHylus FE1dV3JNgKJm3HtfnfHM/t5+o7m2cVjoKBLIIvFmcPP9mBBE1wDuzDj0RLdHENzr5qbW uesC7eUXYOIbjuAmV20Ak0HdMSIF3NLBDvszq7ghtclf6BN8q3W+6prlXwb2Fx/ePB34 BC21hnEzCqFCR0yhjXFBDWdwYO8ti0bS6rqdltmI5xmR9owxXeG36YIwwEz5HwU0dC8z 5BNw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by mx.google.com with ESMTPS id i69si819459lfg.363.2017.12.13.09.52.35 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Dec 2017 09:52:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) client-ip=2001:8b0:1d0::2; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1ePBCq-0007VN-JB; Wed, 13 Dec 2017 17:52:32 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Paolo Bonzini , Aurelien Jarno , Yongbok Kim , Paul Burton Subject: [PATCH 2/2] hw/mips/boston: Remove workaround for writes to ROM aborting Date: Wed, 13 Dec 2017 17:52:29 +0000 Message-Id: <1513187549-2435-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513187549-2435-1-git-send-email-peter.maydell@linaro.org> References: <1513187549-2435-1-git-send-email-peter.maydell@linaro.org> Now that the memory system correctly handles writes to ROM for guest CPUs that may generate exceptions for decode errors, we can remove the workaround from the boston board. Signed-off-by: Peter Maydell --- Disclaimer: not tested beyond 'make check'... --- hw/mips/boston.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) -- 2.7.4 diff --git a/hw/mips/boston.c b/hw/mips/boston.c index 1cb4b6a..fb23161 100644 --- a/hw/mips/boston.c +++ b/hw/mips/boston.c @@ -248,16 +248,6 @@ static const MemoryRegionOps boston_platreg_ops = { .endianness = DEVICE_NATIVE_ENDIAN, }; -static void boston_flash_write(void *opaque, hwaddr addr, - uint64_t val, unsigned size) -{ -} - -static const MemoryRegionOps boston_flash_ops = { - .write = boston_flash_write, - .endianness = DEVICE_NATIVE_ENDIAN, -}; - static const TypeInfo boston_device = { .name = TYPE_MIPS_BOSTON, .parent = TYPE_SYS_BUS_DEVICE, @@ -481,8 +471,8 @@ static void boston_mach_init(MachineState *machine) sysbus_mmio_map_overlap(SYS_BUS_DEVICE(s->cps), 0, 0, 1); flash = g_new(MemoryRegion, 1); - memory_region_init_rom_device_nomigrate(flash, NULL, &boston_flash_ops, s, - "boston.flash", 128 * M_BYTE, &err); + memory_region_init_rom_nomigrate(flash, NULL, + "boston.flash", 128 * M_BYTE, &err); memory_region_add_subregion_overlap(sys_mem, 0x18000000, flash, 0); ddr = g_new(MemoryRegion, 1);