[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 13/15] softmmu/memory: Disallow short writes
From: |
Richard Henderson |
Subject: |
[PATCH 13/15] softmmu/memory: Disallow short writes |
Date: |
Sat, 19 Jun 2021 10:26:24 -0700 |
Writes smaller than impl.min_access_size would require a
read-modify-write cycle, which could have side effects.
The present behaviour seems to be to extend the current write
to min_access_size. While we could continue that, so far all
of the instances I have seen have been either device model
errors or the fuzzer intentionally doing bad things.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
softmmu/memory.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/softmmu/memory.c b/softmmu/memory.c
index 7373d89600..2fe237327d 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -548,6 +548,26 @@ static MemTxResult access_with_adjusted_size(hwaddr addr,
}
/* FIXME: support unaligned access? */
+ /*
+ * Check for a small access.
+ */
+ if (unlikely(size < access_size_min)) {
+ /*
+ * Logically, we cannot support short writes without a read-modify
+ * cycle, and many mmio registers have side-effects on read.
+ * In practice, this appears to be either (1) model error,
+ * or (2) guest error via the fuzzer.
+ */
+ if (write) {
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: Invalid short write: %s "
+ "hwaddr: 0x%" HWADDR_PRIx " size: %u "
+ "min: %u max: %u\n", __func__,
+ memory_region_name(mr), addr, size,
+ access_size_min, access_size_max);
+ return MEMTX_ERROR;
+ }
+ }
+
access_size = MAX(MIN(size, access_size_max), access_size_min);
access_mask = MAKE_64BIT_MASK(0, access_size * 8);
if (memory_region_big_endian(mr)) {
--
2.25.1
- Re: [PATCH 06/15] softmmu/memory: Inline memory_region_dispatch_read1, (continued)
- [PATCH 02/15] accel/tcg: Extract load_helper_unaligned from load_helper, Richard Henderson, 2021/06/19
- [PATCH 08/15] hw/net/e1000e: Fix size of io operations, Richard Henderson, 2021/06/19
- [PATCH 09/15] hw/net/e1000e: Fix impl.min_access_size, Richard Henderson, 2021/06/19
- [PATCH 07/15] softmmu/memory: Simplify access_with_adjusted_size interface, Richard Henderson, 2021/06/19
- [PATCH 11/15] hw/scsi/megasas: Fix megasas_mmio_ops sizes, Richard Henderson, 2021/06/19
- [PATCH 10/15] hw/pci-host/q35: Improve blackhole_ops, Richard Henderson, 2021/06/19
- [PATCH 13/15] softmmu/memory: Disallow short writes,
Richard Henderson <=
- [PATCH 12/15] hw/scsi/megasas: Improve megasas_queue_ops min_access_size, Richard Henderson, 2021/06/19
- [PATCH 15/15] RFC accel/tcg: Defer some unaligned accesses to memory subsystem, Richard Henderson, 2021/06/19
- [PATCH 14/15] softmmu/memory: Support some unaligned access, Richard Henderson, 2021/06/19
- Re: [PATCH 00/15] accel/tcg: Fix for #360 and other i/o alignment issues, Mark Cave-Ayland, 2021/06/20
- Re: [PATCH 00/15] accel/tcg: Fix for #360 and other i/o alignment issues, Peter Maydell, 2021/06/20