add tseg window to smram region, so cpus can access it in smm mode.

Signed-off-by: Gerd Hoffmann <kra...@redhat.com>
---
 hw/pci-host/q35.c         | 13 +++++++++++++
 include/hw/pci-host/q35.h |  2 +-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
index 412ff0a..7d21399 100644
--- a/hw/pci-host/q35.c
+++ b/hw/pci-host/q35.c
@@ -345,6 +345,13 @@ static void mch_update_smram(MCHPCIState *mch)
                                         mch->below_4g_mem_size - tseg_size,
                                         &mch->tseg_blackhole, 1);
 
+    memory_region_set_enabled(&mch->tseg_window, tseg_size);
+    memory_region_set_size(&mch->tseg_window, tseg_size);
+    memory_region_set_address(&mch->tseg_window,
+                              mch->below_4g_mem_size - tseg_size);
+    memory_region_set_alias_offset(&mch->tseg_window,
+                                   mch->below_4g_mem_size - tseg_size);
+
     memory_region_transaction_commit();
 }
 
@@ -500,6 +507,12 @@ static void mch_realize(PCIDevice *d, Error **errp)
                                         mch->below_4g_mem_size,
                                         &mch->tseg_blackhole, 1);
 
+    memory_region_init_alias(&mch->tseg_window, OBJECT(mch), "tseg-window",
+                             mch->ram_memory, mch->below_4g_mem_size, 0);
+    memory_region_set_enabled(&mch->tseg_window, false);
+    memory_region_add_subregion(&mch->smram, mch->below_4g_mem_size,
+                                &mch->tseg_window);
+
     init_pam(DEVICE(mch), mch->ram_memory, mch->system_memory,
              mch->pci_address_space, &mch->pam_regions[0],
              PAM_BIOS_BASE, PAM_BIOS_SIZE);
diff --git a/include/hw/pci-host/q35.h b/include/hw/pci-host/q35.h
index ba64c70..23b7700 100644
--- a/include/hw/pci-host/q35.h
+++ b/include/hw/pci-host/q35.h
@@ -55,7 +55,7 @@ typedef struct MCHPCIState {
     PAMMemoryRegion pam_regions[13];
     MemoryRegion smram_region, open_high_smram;
     MemoryRegion smram, low_smram, high_smram;
-    MemoryRegion tseg_blackhole;
+    MemoryRegion tseg_blackhole, tseg_window;
     PcPciInfo pci_info;
     ram_addr_t below_4g_mem_size;
     ram_addr_t above_4g_mem_size;
-- 
1.8.3.1


Reply via email to