qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [RFC 7/8] pc: initialize memory hotplug address space


From: Igor Mammedov
Subject: [Qemu-devel] [RFC 7/8] pc: initialize memory hotplug address space
Date: Thu, 20 Mar 2014 16:01:15 +0100

Signed-off-by: Igor Mammedov <address@hidden>
---
 hw/i386/pc.c         |   18 ++++++++++++++++--
 include/hw/i386/pc.h |    3 +++
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 7bfd2c9..1824c3d 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1155,6 +1155,7 @@ FWCfgState *pc_memory_init(MemoryRegion *system_memory,
     MemoryRegion *ram, *option_rom_mr;
     MemoryRegion *ram_below_4g, *ram_above_4g;
     FWCfgState *fw_cfg;
+    ram_addr_t ram_size = below_4g_mem_size + above_4g_mem_size;
     uint64_t ram_slot;
     MachineState *machine = MACHINE(qdev_get_machine());
     PCMachineState *pcms = PC_MACHINE(machine);
@@ -1166,8 +1167,7 @@ FWCfgState *pc_memory_init(MemoryRegion *system_memory,
      * with older qemus that used qemu_ram_alloc().
      */
     ram = g_malloc(sizeof(*ram));
-    memory_region_init_ram(ram, NULL, "pc.ram",
-                           below_4g_mem_size + above_4g_mem_size);
+    memory_region_init_ram(ram, NULL, "pc.ram", ram_size);
     vmstate_register_ram_global(ram);
     *ram_memory = ram;
     ram_below_4g = g_malloc(sizeof(*ram_below_4g));
@@ -1184,6 +1184,20 @@ FWCfgState *pc_memory_init(MemoryRegion *system_memory,
         e820_add_entry(0x100000000ULL, above_4g_mem_size, E820_RAM);
     }
 
+    /* initialize memory hotplug address space */
+    if (ram_size < machine->init_args.maxram_size) {
+        ram_addr_t hotplug_mem_size =
+            machine->init_args.maxram_size - ram_size;
+
+        pcms->hotplug_memory_base =
+            ROUND_UP(0x100000000ULL + above_4g_mem_size, 1ULL << 30);
+
+        memory_region_init(&pcms->hotplug_memory, OBJECT(pcms),
+                           "hotplug-memory", hotplug_mem_size);
+        memory_region_add_subregion(system_memory, pcms->hotplug_memory_base,
+                                    &pcms->hotplug_memory);
+    }
+
     for (ram_slot = 0; ram_slot < machine->init_args.ram_slots; ram_slot++) {
         char *dimm_name;
 
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 277bbb9..a25957d 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -25,6 +25,9 @@ struct PCMachineState {
 
     /* <public> */
     DimmDevice *memory_slots[PC_MAX_DIMM_SLOTS];
+
+    ram_addr_t hotplug_memory_base;
+    MemoryRegion hotplug_memory;
 };
 
 typedef struct PCMachineState PCMachineState;
-- 
1.7.1




reply via email to

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