[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 09/15] memory: Introduce memory_region_init_reser
From: |
Jan Kiszka |
Subject: |
[Qemu-devel] [PATCH v4 09/15] memory: Introduce memory_region_init_reservation |
Date: |
Thu, 8 Dec 2011 12:52:28 +0100 |
Introduce a memory region type that can reserve I/O space. Such regions
are useful for modeling I/O that is only handled outside of QEMU, i.e.
in the context of an accelerator like KVM.
Any access to such a region from QEMU is a bug, but could theoretically
be triggered by guest code (DMA to reserved region). So only warning
about such events once, then ignore them.
Signed-off-by: Jan Kiszka <address@hidden>
---
memory.c | 36 ++++++++++++++++++++++++++++++++++++
memory.h | 16 ++++++++++++++++
2 files changed, 52 insertions(+), 0 deletions(-)
diff --git a/memory.c b/memory.c
index adfdf14..71a252a 100644
--- a/memory.c
+++ b/memory.c
@@ -1031,6 +1031,42 @@ void memory_region_init_rom_device(MemoryRegion *mr,
mr->backend_registered = true;
}
+static uint64_t invalid_read(void *opaque, target_phys_addr_t addr,
+ unsigned size)
+{
+ MemoryRegion *mr = opaque;
+
+ if (!mr->warning_printed) {
+ fprintf(stderr, "Invalid read from memory region %s\n", mr->name);
+ mr->warning_printed = true;
+ }
+ return -1U;
+}
+
+static void invalid_write(void *opaque, target_phys_addr_t addr, uint64_t data,
+ unsigned size)
+{
+ MemoryRegion *mr = opaque;
+
+ if (!mr->warning_printed) {
+ fprintf(stderr, "Invalid write to memory region %s\n", mr->name);
+ mr->warning_printed = true;
+ }
+}
+
+static const MemoryRegionOps reservation_ops = {
+ .read = invalid_read,
+ .write = invalid_write,
+ .endianness = DEVICE_NATIVE_ENDIAN,
+};
+
+void memory_region_init_reservation(MemoryRegion *mr,
+ const char *name,
+ uint64_t size)
+{
+ memory_region_init_io(mr, &reservation_ops, mr, name, size);
+}
+
void memory_region_destroy(MemoryRegion *mr)
{
assert(QTAILQ_EMPTY(&mr->subregions));
diff --git a/memory.h b/memory.h
index 53bf261..1097eac 100644
--- a/memory.h
+++ b/memory.h
@@ -123,6 +123,7 @@ struct MemoryRegion {
bool terminates;
bool readable;
bool readonly; /* For RAM regions */
+ bool warning_printed; /* For reservations */
MemoryRegion *alias;
target_phys_addr_t alias_offset;
unsigned priority;
@@ -250,6 +251,21 @@ void memory_region_init_rom_device(MemoryRegion *mr,
uint64_t size);
/**
+ * memory_region_init_reservation: Initialize a memory region that reserves
+ * I/O space.
+ *
+ * A reservation region primariy serves debugging purposes. It claims I/O
+ * space that is not supposed to be handled by QEMU itself. Any access via
+ * the memory API will cause an abort().
+ *
+ * @mr: the #MemoryRegion to be initialized
+ * @name: used for debugging; not visible to the user or ABI
+ * @size: size of the region.
+ */
+void memory_region_init_reservation(MemoryRegion *mr,
+ const char *name,
+ uint64_t size);
+/**
* memory_region_destroy: Destroy a memory region and relaim all resources.
*
* @mr: the region to be destroyed. May not currently be a subregion
--
1.7.3.4
- [Qemu-devel] [PATCH v4 00/15] uq/master: Introduce basic irqchip support, Jan Kiszka, 2011/12/08
- [Qemu-devel] [PATCH v4 15/15] kvm: Arm in-kernel irqchip support, Jan Kiszka, 2011/12/08
- [Qemu-devel] [PATCH v4 08/15] ioapic: Introduce backend/frontend infrastructure for KVM reuse, Jan Kiszka, 2011/12/08
- [Qemu-devel] [PATCH v4 14/15] kvm: x86: Add user space part for in-kernel IOAPIC, Jan Kiszka, 2011/12/08
- [Qemu-devel] [PATCH v4 01/15] msi: Generalize msix_supported to msi_supported, Jan Kiszka, 2011/12/08
- [Qemu-devel] [PATCH v4 11/15] kvm: x86: Establish IRQ0 override control, Jan Kiszka, 2011/12/08
- [Qemu-devel] [PATCH v4 09/15] memory: Introduce memory_region_init_reservation,
Jan Kiszka <=
- [Qemu-devel] [PATCH v4 07/15] i8259: Introduce backend/frontend infrastructure for KVM reuse, Jan Kiszka, 2011/12/08
- [Qemu-devel] [PATCH v4 05/15] apic: Introduce backend/frontend infrastructure for KVM reuse, Jan Kiszka, 2011/12/08
- [Qemu-devel] [PATCH v4 13/15] kvm: x86: Add user space part for in-kernel i8259, Jan Kiszka, 2011/12/08
- [Qemu-devel] [PATCH v4 06/15] apic: Open-code timer save/restore, Jan Kiszka, 2011/12/08
- [Qemu-devel] [PATCH v4 10/15] kvm: Introduce core services for in-kernel irqchip support, Jan Kiszka, 2011/12/08
- [Qemu-devel] [PATCH v4 03/15] apic: Stop timer on reset, Jan Kiszka, 2011/12/08
- [Qemu-devel] [PATCH v4 12/15] kvm: x86: Add user space part for in-kernel APIC, Jan Kiszka, 2011/12/08