qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH RFC 3/3] hw/pci-host: catch acesses to unassigned pc


From: Marcel Apfelbaum
Subject: [Qemu-devel] [PATCH RFC 3/3] hw/pci-host: catch acesses to unassigned pci addresses
Date: Mon, 2 Sep 2013 17:13:09 +0300

Added a memory region that has negative priority and
extends over all the pci adddress space. This region will
"catch" all the accesses to the unassigned pci
addresses and it will be possible to emulate the
master abort scenario (When no device on the bus claims
the transaction).

Signed-off-by: Marcel Apfelbaum <address@hidden>
---
 hw/pci-host/piix.c        |  8 ++++++++
 hw/pci-host/q35.c         | 19 ++++++++++++++++---
 include/hw/pci-host/q35.h |  1 +
 3 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
index dc1718f..27b04a6 100644
--- a/hw/pci-host/piix.c
+++ b/hw/pci-host/piix.c
@@ -104,6 +104,7 @@ struct PCII440FXState {
     MemoryRegion *ram_memory;
     MemoryRegion pci_hole;
     MemoryRegion pci_hole_64bit;
+    MemoryRegion pci_unassigned_memory;
     PAMMemoryRegion pam_regions[13];
     MemoryRegion smram_region;
     uint8_t smm_enabled;
@@ -347,6 +348,13 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state,
         i440fx->pci_info.w32.begin = 0xe0000000;
     }
 
+    memory_region_init_io(&f->pci_unassigned_memory, OBJECT(d),
+                          &pci_unassigned_mem_ops, d,
+                          "pci-hole-unassigned", pci_hole_size);
+    memory_region_add_subregion_overlap(f->pci_address_space, pci_hole_start,
+                                        &f->pci_unassigned_memory,
+                                        PCI_UNASSIGNED_MEM_PRIORITY);
+
     memory_region_init_alias(&f->pci_hole, OBJECT(d), "pci-hole", 
f->pci_address_space,
                              pci_hole_start, pci_hole_size);
     memory_region_add_subregion(f->system_memory, pci_hole_start, 
&f->pci_hole);
diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
index 12314d8..ee4a4f9 100644
--- a/hw/pci-host/q35.c
+++ b/hw/pci-host/q35.c
@@ -320,13 +320,26 @@ static int mch_init(PCIDevice *d)
 {
     int i;
     MCHPCIState *mch = MCH_PCI_DEVICE(d);
+    hwaddr pci_hole_start;
+    uint64_t pci_hole_size;
+
+    pci_hole_start = mch->below_4g_mem_size;
+    pci_hole_size = 0x100000000ULL - pci_hole_start;
+
+    memory_region_init_io(&mch->pci_unassigned_memory, OBJECT(d),
+                          &pci_unassigned_mem_ops, d,
+                          "pci-hole-unassigned", pci_hole_size);
+    memory_region_add_subregion_overlap(mch->pci_address_space, pci_hole_start,
+                                        &mch->pci_unassigned_memory,
+                                        PCI_UNASSIGNED_MEM_PRIORITY);
+
 
     /* setup pci memory regions */
     memory_region_init_alias(&mch->pci_hole, OBJECT(mch), "pci-hole",
                              mch->pci_address_space,
-                             mch->below_4g_mem_size,
-                             0x100000000ULL - mch->below_4g_mem_size);
-    memory_region_add_subregion(mch->system_memory, mch->below_4g_mem_size,
+                             pci_hole_start,
+                             pci_hole_size);
+    memory_region_add_subregion(mch->system_memory, pci_hole_start,
                                 &mch->pci_hole);
 
     pc_init_pci64_hole(&mch->pci_info, 0x100000000ULL + mch->above_4g_mem_size,
diff --git a/include/hw/pci-host/q35.h b/include/hw/pci-host/q35.h
index 6eb7ab6..c42fba3 100644
--- a/include/hw/pci-host/q35.h
+++ b/include/hw/pci-host/q35.h
@@ -55,6 +55,7 @@ typedef struct MCHPCIState {
     MemoryRegion smram_region;
     MemoryRegion pci_hole;
     MemoryRegion pci_hole_64bit;
+    MemoryRegion pci_unassigned_memory;
     PcPciInfo pci_info;
     uint8_t smm_enabled;
     ram_addr_t below_4g_mem_size;
-- 
1.8.3.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]