[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 10/16] memory: Introduce memory_region_init_reser
From: |
Jan Kiszka |
Subject: |
[Qemu-devel] [PATCH v3 10/16] memory: Introduce memory_region_init_reservation |
Date: |
Tue, 6 Dec 2011 13:58:10 +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 dc5e35d..6d55cf6 100644
--- a/memory.c
+++ b/memory.c
@@ -1003,6 +1003,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 d5b47da..b479350 100644
--- a/memory.h
+++ b/memory.h
@@ -115,6 +115,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;
@@ -242,6 +243,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 v3 00/16] uq/master: Introduce basic irqchip support, Jan Kiszka, 2011/12/06
- [Qemu-devel] [PATCH v3 02/16] kvm: Move kvmclock into hw/kvm folder, Jan Kiszka, 2011/12/06
- [Qemu-devel] [PATCH v3 05/16] apic: Open-code timer save/restore, Jan Kiszka, 2011/12/06
- [Qemu-devel] [PATCH v3 12/16] kvm: x86: Establish IRQ0 override control, Jan Kiszka, 2011/12/06
- [Qemu-devel] [PATCH v3 04/16] apic: Introduce backend/frontend infrastructure for KVM reuse, Jan Kiszka, 2011/12/06
- [Qemu-devel] [PATCH v3 09/16] ioapic: Introduce backend/frontend infrastructure for KVM reuse, Jan Kiszka, 2011/12/06
- [Qemu-devel] [PATCH v3 01/16] msi: Generalize msix_supported to msi_supported, Jan Kiszka, 2011/12/06
- [Qemu-devel] [PATCH v3 10/16] memory: Introduce memory_region_init_reservation,
Jan Kiszka <=
- [Qemu-devel] [PATCH v3 07/16] ioapic: Convert to memory API, Jan Kiszka, 2011/12/06
- [Qemu-devel] [PATCH v3 11/16] kvm: Introduce core services for in-kernel irqchip support, Jan Kiszka, 2011/12/06
- [Qemu-devel] [PATCH v3 13/16] kvm: x86: Add user space part for in-kernel APIC, Jan Kiszka, 2011/12/06
- [Qemu-devel] [PATCH v3 15/16] kvm: x86: Add user space part for in-kernel IOAPIC, Jan Kiszka, 2011/12/06
- [Qemu-devel] [PATCH v3 08/16] ioapic: Reject non-dword accesses to IOWIN register, Jan Kiszka, 2011/12/06
- [Qemu-devel] [PATCH v3 14/16] kvm: x86: Add user space part for in-kernel i8259, Jan Kiszka, 2011/12/06
- [Qemu-devel] [PATCH v3 16/16] kvm: Arm in-kernel irqchip support, Jan Kiszka, 2011/12/06
- [Qemu-devel] [PATCH v3 03/16] apic: Stop timer on reset, Jan Kiszka, 2011/12/06
- [Qemu-devel] [PATCH v3 06/16] i8259: Introduce backend/frontend infrastructure for KVM reuse, Jan Kiszka, 2011/12/06
- Re: [Qemu-devel] [PATCH v3 00/16] uq/master: Introduce basic irqchip support, Avi Kivity, 2011/12/06