From patchwork Thu Mar 20 15:01:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 332221 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B2662C00A6 for ; Fri, 21 Mar 2014 02:03:35 +1100 (EST) Received: from localhost ([::1]:47477 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQeVI-0007hx-SL for incoming@patchwork.ozlabs.org; Thu, 20 Mar 2014 11:03:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50581) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQeUZ-0007U8-UT for qemu-devel@nongnu.org; Thu, 20 Mar 2014 11:02:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQeUS-0001X0-Tz for qemu-devel@nongnu.org; Thu, 20 Mar 2014 11:02:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:19420) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQeUS-0001Wq-Kb for qemu-devel@nongnu.org; Thu, 20 Mar 2014 11:02:40 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s2KF2b0R029406 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 20 Mar 2014 11:02:38 -0400 Received: from dell-pet610-01.lab.eng.brq.redhat.com (dell-pet610-01.lab.eng.brq.redhat.com [10.34.42.20]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s2KF2Mjj022015; Thu, 20 Mar 2014 11:02:35 -0400 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 20 Mar 2014 16:01:15 +0100 Message-Id: <1395327676-29753-8-git-send-email-imammedo@redhat.com> In-Reply-To: <1395327676-29753-1-git-send-email-imammedo@redhat.com> References: <1395327676-29753-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: marcel.a@redhat.com, mst@redhat.com, vasilis.liaskovitis@profitbricks.com, aliguori@amazon.com, pbonzini@redhat.com, afaerber@suse.de Subject: [Qemu-devel] [RFC 7/8] pc: initialize memory hotplug address space X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Igor Mammedov --- 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 { /* */ DimmDevice *memory_slots[PC_MAX_DIMM_SLOTS]; + + ram_addr_t hotplug_memory_base; + MemoryRegion hotplug_memory; }; typedef struct PCMachineState PCMachineState;