From patchwork Fri Apr 24 06:47:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bharata B Rao X-Patchwork-Id: 464139 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 413B71400A0 for ; Fri, 24 Apr 2015 17:03:01 +1000 (AEST) Received: from localhost ([::1]:43223 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YlXdb-0000ZF-Hp for incoming@patchwork.ozlabs.org; Fri, 24 Apr 2015 03:02:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54183) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YlXV1-0001sF-FW for qemu-devel@nongnu.org; Fri, 24 Apr 2015 02:54:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YlXUx-0005wn-7X for qemu-devel@nongnu.org; Fri, 24 Apr 2015 02:54:07 -0400 Received: from e23smtp08.au.ibm.com ([202.81.31.141]:60824) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YlXUw-0005vn-EM for qemu-devel@nongnu.org; Fri, 24 Apr 2015 02:54:03 -0400 Received: from /spool/local by e23smtp08.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 24 Apr 2015 16:54:00 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp08.au.ibm.com (202.81.31.205) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 24 Apr 2015 16:53:58 +1000 Received: from d23relay09.au.ibm.com (d23relay09.au.ibm.com [9.185.63.181]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 008A12CE8050; Fri, 24 Apr 2015 16:53:58 +1000 (EST) Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay09.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t3O6rn4J39911640; Fri, 24 Apr 2015 16:53:57 +1000 Received: from d23av02.au.ibm.com (localhost [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t3O6rO5R032508; Fri, 24 Apr 2015 16:53:24 +1000 Received: from bharata.in.ibm.com ([9.79.216.71]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t3O6m5Qx023890; Fri, 24 Apr 2015 16:53:12 +1000 From: Bharata B Rao To: qemu-devel@nongnu.org Date: Fri, 24 Apr 2015 12:17:43 +0530 Message-Id: <1429858066-12088-22-git-send-email-bharata@linux.vnet.ibm.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1429858066-12088-1-git-send-email-bharata@linux.vnet.ibm.com> References: <1429858066-12088-1-git-send-email-bharata@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15042406-0029-0000-0000-00000174D548 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 202.81.31.141 Cc: aik@ozlabs.ru, Bharata B Rao , mdroth@linux.vnet.ibm.com, agraf@suse.de, qemu-ppc@nongnu.org, tyreld@linux.vnet.ibm.com, nfont@linux.vnet.ibm.com, imammedo@redhat.com, afaerber@suse.de, david@gibson.dropbear.id.au Subject: [Qemu-devel] [RFC PATCH v3 21/24] spapr: Initialize hotplug memory 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 Initialize a hotplug memory region under which all the hotplugged memory is accommodated. Also enable memory hotplug by setting CONFIG_MEM_HOTPLUG. Modelled on i386 memory hotplug. Signed-off-by: Bharata B Rao --- default-configs/ppc64-softmmu.mak | 1 + hw/ppc/spapr.c | 38 ++++++++++++++++++++++++++++++++++++++ include/hw/ppc/spapr.h | 12 ++++++++++++ 3 files changed, 51 insertions(+) diff --git a/default-configs/ppc64-softmmu.mak b/default-configs/ppc64-softmmu.mak index 22ef132..16b3011 100644 --- a/default-configs/ppc64-softmmu.mak +++ b/default-configs/ppc64-softmmu.mak @@ -51,3 +51,4 @@ CONFIG_XICS_KVM=$(and $(CONFIG_PSERIES),$(CONFIG_KVM)) # For PReP CONFIG_MC146818RTC=y CONFIG_ISA_TESTDEV=y +CONFIG_MEM_HOTPLUG=y diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 910a50f..9dc4c36 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -125,6 +125,9 @@ struct sPAPRMachineState { /*< public >*/ char *kvm_type; + ram_addr_t hotplug_memory_base; + MemoryRegion hotplug_memory; + bool enforce_aligned_dimm; }; sPAPREnvironment *spapr; @@ -1514,6 +1517,7 @@ static void ppc_spapr_init(MachineState *machine) QemuOpts *opts = qemu_opts_find(qemu_find_opts("smp-opts"), NULL); int sockets = opts ? qemu_opt_get_number(opts, "sockets", 0) : 0; int cores = (smp_cpus/smp_threads) ? smp_cpus/smp_threads : 1; + sPAPRMachineState *ms = SPAPR_MACHINE(machine); sockets = sockets ? sockets : cores; msi_supported = true; @@ -1613,6 +1617,36 @@ static void ppc_spapr_init(MachineState *machine) memory_region_add_subregion(sysmem, 0, rma_region); } + /* initialize hotplug memory address space */ + if (machine->ram_size < machine->maxram_size) { + ram_addr_t hotplug_mem_size = + machine->maxram_size - machine->ram_size; + + if (machine->ram_slots > SPAPR_MAX_RAM_SLOTS) { + error_report("unsupported amount of memory slots: %"PRIu64, + machine->ram_slots); + exit(EXIT_FAILURE); + } + + ms->hotplug_memory_base = ROUND_UP(machine->ram_size, + SPAPR_HOTPLUG_MEM_ALIGN); + + if (ms->enforce_aligned_dimm) { + hotplug_mem_size += SPAPR_HOTPLUG_MEM_ALIGN * machine->ram_slots; + } + + if ((ms->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(&ms->hotplug_memory, OBJECT(ms), + "hotplug-memory", hotplug_mem_size); + memory_region_add_subregion(sysmem, ms->hotplug_memory_base, + &ms->hotplug_memory); + } + filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, "spapr-rtas.bin"); spapr->rtas_size = get_image_size(filename); spapr->rtas_blob = g_malloc(spapr->rtas_size); @@ -1844,11 +1878,15 @@ static void spapr_set_kvm_type(Object *obj, const char *value, Error **errp) static void spapr_machine_initfn(Object *obj) { + sPAPRMachineState *ms = SPAPR_MACHINE(obj); + object_property_add_str(obj, "kvm-type", spapr_get_kvm_type, spapr_set_kvm_type, NULL); object_property_set_description(obj, "kvm-type", "Specifies the KVM virtualization mode (HV, PR)", NULL); + + ms->enforce_aligned_dimm = true; } static void ppc_cpu_do_nmi_on_cpu(void *arg) diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index ecac6e3..53560e9 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -542,6 +542,18 @@ struct sPAPREventLogEntry { #define SPAPR_MEMORY_BLOCK_SIZE (1 << 28) /* 256MB */ +/* + * This defines the maximum number of DIMM slots we can have for sPAPR + * guest. This is not defined by sPAPR but we are defining it to 4096 slots + * here. With the worst case addition of SPAPR_MEMORY_BLOCK_SIZE + * (256MB) memory per slot, we should be able to support 1TB of guest + * hotpluggable memory. + */ +#define SPAPR_MAX_RAM_SLOTS (1ULL << 12) + +/* 1GB alignment for hotplug memory region */ +#define SPAPR_HOTPLUG_MEM_ALIGN (1ULL << 30) + void spapr_events_init(sPAPREnvironment *spapr); void spapr_events_fdt_skel(void *fdt, uint32_t epow_irq); int spapr_h_cas_compose_response(target_ulong addr, target_ulong size);