[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 13/34] pc: initialize memory hotplug address spac
From: |
Igor Mammedov |
Subject: |
[Qemu-devel] [PATCH v3 13/34] pc: initialize memory hotplug address space |
Date: |
Tue, 27 May 2014 15:01:10 +0200 |
initialize and map hotplug memory address space container
into guest's RAM address space.
Signed-off-by: Igor Mammedov <address@hidden>
---
v2:
* fix uint64_t overflow reported by Hu Tao
* rebase on top of Marcel's patch
"machine: Conversion of QEMUMachineInitArgs to MachineState"
---
hw/i386/pc.c | 26 ++++++++++++++++++++++++--
include/hw/i386/pc.h | 10 ++++++++++
2 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index f6781d8..f94cfd9 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1201,6 +1201,9 @@ 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;
+ MachineState *machine = MACHINE(qdev_get_machine());
+ PCMachineState *pcms = PC_MACHINE(machine);
linux_boot = (kernel_filename != NULL);
@@ -1209,8 +1212,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));
@@ -1227,6 +1229,26 @@ FWCfgState *pc_memory_init(MemoryRegion *system_memory,
e820_add_entry(0x100000000ULL, above_4g_mem_size, E820_RAM);
}
+ /* initialize hotplug memory address space */
+ if (ram_size < machine->maxram_size) {
+ ram_addr_t hotplug_mem_size =
+ machine->maxram_size - ram_size;
+
+ pcms->hotplug_memory_base =
+ ROUND_UP(0x100000000ULL + above_4g_mem_size, 1ULL << 30);
+
+ if ((pcms->hotplug_memory_base + hotplug_mem_size) <
+ hotplug_mem_size) {
+ error_report("unsupported amount of maximum memory: %"PRIu64,
+ machine->maxram_size);
+ exit(EXIT_FAILURE);
+ }
+
+ 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);
+ }
/* Initialize PC system firmware */
pc_system_firmware_init(rom_memory, guest_info->isapc_ram_fw);
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index c7b053c..3ae6c56 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -16,9 +16,19 @@
#define HPET_INTCAP "hpet-intcap"
+/**
+ * PCMachineState:
+ * @hotplug_memory_base: address in guest RAM address space where hotplug
memory
+ * address space begins.
+ * @hotplug_memory: hotplug memory addess space container
+ */
struct PCMachineState {
/*< private >*/
MachineState parent_obj;
+
+ /* <public> */
+ ram_addr_t hotplug_memory_base;
+ MemoryRegion hotplug_memory;
};
struct PCMachineClass {
--
1.7.1
- [Qemu-devel] [PATCH v3 01/34] machine: Conversion of QEMUMachineInitArgs to MachineState, (continued)
- [Qemu-devel] [PATCH v3 01/34] machine: Conversion of QEMUMachineInitArgs to MachineState, Igor Mammedov, 2014/05/27
- [Qemu-devel] [PATCH v3 07/34] pc: create custom generic PC machine type, Igor Mammedov, 2014/05/27
- [Qemu-devel] [PATCH v3 09/34] qdev: expose DeviceState.hotplugged field as a property, Igor Mammedov, 2014/05/27
- [Qemu-devel] [PATCH v3 08/34] qdev: hotplug for buss-less devices, Igor Mammedov, 2014/05/27
- [Qemu-devel] [PATCH v3 10/34] dimm: implement dimm device abstraction, Igor Mammedov, 2014/05/27
- [Qemu-devel] [PATCH v3 11/34] memory: add memory_region_is_mapped() API, Igor Mammedov, 2014/05/27
- [Qemu-devel] [PATCH v3 13/34] pc: initialize memory hotplug address space,
Igor Mammedov <=
- [Qemu-devel] [PATCH v3 14/34] pc: exit QEMU if number of slots more than supported 256, Igor Mammedov, 2014/05/27
- [Qemu-devel] [PATCH v3 17/34] pc: add memory hotplug handler to PC_MACHINE, Igor Mammedov, 2014/05/27
- [Qemu-devel] [PATCH v3 18/34] dimm: add busy address check and address auto-allocation, Igor Mammedov, 2014/05/27
- [Qemu-devel] [PATCH v3 22/34] trace: add acpi memory hotplug IO region events, Igor Mammedov, 2014/05/27
- [Qemu-devel] [PATCH v3 21/34] acpi: memory hotplug ACPI hardware implementation, Igor Mammedov, 2014/05/27
- [Qemu-devel] [PATCH v3 23/34] trace: pc: add DIMM slot & address allocation, Igor Mammedov, 2014/05/27
- [Qemu-devel] [PATCH v3 24/34] acpi:piix4: allow plug/unlug callbacks handle not only PCI devices, Igor Mammedov, 2014/05/27
- [Qemu-devel] [PATCH v3 25/34] acpi:piix4: add memory hotplug handling, Igor Mammedov, 2014/05/27