[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 012/106] pc: initialize memory hotplug address spa
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL v2 012/106] pc: initialize memory hotplug address space |
Date: |
Wed, 18 Jun 2014 19:16:15 +0300 |
From: Igor Mammedov <address@hidden>
initialize and map hotplug memory address space container
into guest's RAM address space.
Signed-off-by: Igor Mammedov <address@hidden>
Acked-by: Peter Crosthwaite <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
include/hw/i386/pc.h | 10 ++++++++++
hw/i386/pc.c | 26 ++++++++++++++++++++++++--
2 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index aade1b2..48d4c5e 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 {
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 77c587b..6cdcb00 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1197,6 +1197,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);
@@ -1205,8 +1208,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));
@@ -1223,6 +1225,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: " RAM_ADDR_FMT,
+ 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);
--
MST
- [Qemu-devel] [PULL v2 000/106] pc, pci, virtio, hotplug fixes, enhancements, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 001/106] pc: create custom generic PC machine type, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 002/106] pc: ACPI BIOS: use enum for defining memory affinity flags, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 003/106] object_add: allow completion handler to get canonical path, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 004/106] vl.c: daemonize before guest memory allocation, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 005/106] add memdev backend infrastructure, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 007/106] qdev: hotplug for bus-less devices, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 009/106] pc: implement pc-dimm device abstraction, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 011/106] pc-dimm: do not allow setting an in-use memdev, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 010/106] memory: add memory_region_is_mapped() API, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 012/106] pc: initialize memory hotplug address space,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL v2 014/106] pc: add 'etc/reserved-memory-end' fw_cfg interface for SeaBIOS, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 018/106] pc-dimm: add busy slot check and slot auto-allocation, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 021/106] trace: add acpi memory hotplug IO region events, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 022/106] trace: pc: add PC_DIMM slot & address allocation, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 023/106] acpi:piix4: allow plug/unlug callbacks handle not only PCI devices, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 025/106] pc: ich9 lpc: make it work with global/compat properties, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 024/106] acpi:piix4: add memory hotplug handling, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 026/106] acpi:ich9: add memory hotplug handling, Michael S. Tsirkin, 2014/06/18