From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44716) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WW4KL-0001jW-Ue for qemu-devel@nongnu.org; Fri, 04 Apr 2014 09:38:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WW4KF-00066t-Ao for qemu-devel@nongnu.org; Fri, 04 Apr 2014 09:38:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51381) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WW4KF-00066p-2Y for qemu-devel@nongnu.org; Fri, 04 Apr 2014 09:38:31 -0400 From: Igor Mammedov Date: Fri, 4 Apr 2014 15:36:38 +0200 Message-Id: <1396618620-27823-14-git-send-email-imammedo@redhat.com> In-Reply-To: <1396618620-27823-1-git-send-email-imammedo@redhat.com> References: <1396618620-27823-1-git-send-email-imammedo@redhat.com> Subject: [Qemu-devel] [PATCH 13/35] pc: initialize memory hotplug address space List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, mst@redhat.com, aik@ozlabs.ru, hutao@cn.fujitsu.com, mjt@tls.msk.ru, lcapitulino@redhat.com, kraxel@redhat.com, akong@redhat.com, quintela@redhat.com, armbru@redhat.com, aliguori@amazon.com, jan.kiszka@siemens.com, lersek@redhat.com, ehabkost@redhat.com, marcel.a@redhat.com, stefanha@redhat.com, chegu_vinod@hp.com, rth@twiddle.net, kwolf@redhat.com, s.priebe@profihost.ag, mreitz@redhat.com, vasilis.liaskovitis@profitbricks.com, pbonzini@redhat.com, afaerber@suse.de initialize and map hotplug memory address space container into guest's RAM address space. Signed-off-by: Igor Mammedov --- hw/i386/pc.c | 19 +++++++++++++++++-- include/hw/i386/pc.h | 10 ++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 32b4003..69e4225 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1171,6 +1171,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); @@ -1179,8 +1182,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)); @@ -1197,6 +1199,19 @@ 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->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); + } /* 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 b3bc0f7..a1f21ba 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; + + /* */ + ram_addr_t hotplug_memory_base; + MemoryRegion hotplug_memory; }; struct PCMachineClass { -- 1.9.0