[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 14/20] memory: Introduce memory_region_init_reservat
From: |
Marcelo Tosatti |
Subject: |
[Qemu-devel] [PATCH 14/20] memory: Introduce memory_region_init_reservation |
Date: |
Fri, 20 Jan 2012 15:26:40 -0200 |
From: Jan Kiszka <address@hidden>
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 6201a37..68e5cdf 100644
--- a/memory.c
+++ b/memory.c
@@ -1049,6 +1049,42 @@ void memory_region_init_rom_device(MemoryRegion *mr,
mr->ram_addr |= cpu_register_io_memory(mr);
}
+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 d48b08b..34c69cf 100644
--- a/memory.h
+++ b/memory.h
@@ -126,6 +126,7 @@ struct MemoryRegion {
bool readonly; /* For RAM regions */
bool enabled;
bool rom_device;
+ bool warning_printed; /* For reservations */
MemoryRegion *alias;
target_phys_addr_t alias_offset;
unsigned priority;
@@ -280,6 +281,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 reclaim all resources.
*
* @mr: the region to be destroyed. May not currently be a subregion
--
1.7.6.4
- [Qemu-devel] [PATCH 00/20] [PULL] qemu-kvm.git uq/master queue, Marcelo Tosatti, 2012/01/20
- [Qemu-devel] [PATCH 02/20] hyper-v: initialize Hyper-V CPUID leaves., Marcelo Tosatti, 2012/01/20
- [Qemu-devel] [PATCH 05/20] apic: Stop timer on reset, Marcelo Tosatti, 2012/01/20
- [Qemu-devel] [PATCH 15/20] kvm: Introduce core services for in-kernel irqchip support, Marcelo Tosatti, 2012/01/20
- [Qemu-devel] [PATCH 16/20] kvm: x86: Establish IRQ0 override control, Marcelo Tosatti, 2012/01/20
- [Qemu-devel] [PATCH 14/20] memory: Introduce memory_region_init_reservation,
Marcelo Tosatti <=
- [Qemu-devel] [PATCH 10/20] i8259: Completely privatize PicState, Marcelo Tosatti, 2012/01/20
- [Qemu-devel] [PATCH 09/20] apic: Open-code timer save/restore, Marcelo Tosatti, 2012/01/20
- [Qemu-devel] [PATCH 07/20] apic: Introduce apic_report_irq_delivered, Marcelo Tosatti, 2012/01/20
- [Qemu-devel] [PATCH 04/20] kvm: Move kvmclock into hw/kvm folder, Marcelo Tosatti, 2012/01/20
- [Qemu-devel] [PATCH 12/20] ioapic: Drop post-load irr initialization, Marcelo Tosatti, 2012/01/20
- [Qemu-devel] [PATCH 20/20] kvm: Activate in-kernel irqchip support, Marcelo Tosatti, 2012/01/20
- [Qemu-devel] [PATCH 06/20] apic: Inject external NMI events via LINT1, Marcelo Tosatti, 2012/01/20
- [Qemu-devel] [PATCH 03/20] msi: Generalize msix_supported to msi_supported, Marcelo Tosatti, 2012/01/20
- [Qemu-devel] [PATCH 17/20] kvm: x86: Add user space part for in-kernel APIC, Marcelo Tosatti, 2012/01/20
- [Qemu-devel] [PATCH 01/20] hyper-v: introduce Hyper-V support infrastructure., Marcelo Tosatti, 2012/01/20