[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH v2 21/23] spapr: Initialize hotplug memory addre
From: |
Bharata B Rao |
Subject: |
[Qemu-devel] [RFC PATCH v2 21/23] spapr: Initialize hotplug memory address space |
Date: |
Mon, 23 Mar 2015 19:06:02 +0530 |
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 <address@hidden>
---
default-configs/ppc64-softmmu.mak | 1 +
hw/ppc/spapr.c | 50 +++++++++++++++++++++++++++++++++++++++
include/hw/ppc/spapr.h | 12 ++++++++++
3 files changed, 63 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 3e56d9e..e43bb49 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -125,8 +125,13 @@ struct sPAPRMachineState {
/*< public >*/
char *kvm_type;
+ ram_addr_t hotplug_memory_base;
+ MemoryRegion hotplug_memory;
+ bool enforce_aligned_dimm;
};
+#define SPAPR_MACHINE_ENFORCE_ALIGNED_DIMM "enforce-aligned-dimm"
+
sPAPREnvironment *spapr;
static XICSState *try_create_xics(const char *type, int nr_servers,
@@ -1499,6 +1504,7 @@ static void ppc_spapr_init(MachineState *machine)
int smt = kvmppc_smt_threads();
Object *socket;
int sockets;
+ sPAPRMachineState *ms = SPAPR_MACHINE(machine);
msi_supported = true;
@@ -1585,6 +1591,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);
@@ -1827,13 +1863,27 @@ static void spapr_set_kvm_type(Object *obj, const char
*value, Error **errp)
sm->kvm_type = g_strdup(value);
}
+static bool spapr_machine_get_aligned_dimm(Object *obj, Error **errp)
+{
+ sPAPRMachineState *ms = SPAPR_MACHINE(obj);
+
+ return ms->enforce_aligned_dimm;
+}
+
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;
+ object_property_add_bool(obj, SPAPR_MACHINE_ENFORCE_ALIGNED_DIMM,
+ spapr_machine_get_aligned_dimm,
+ NULL, NULL);
}
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);
--
2.1.0
- Re: [Qemu-devel] [RFC PATCH v2 18/23] xics_kvm: Add cpu_destroy method to XICS, (continued)
- [Qemu-devel] [RFC PATCH v2 20/23] spapr: Remove vCPU objects after CPU hot unplug, Bharata B Rao, 2015/03/23
- [Qemu-devel] [RFC PATCH v2 19/23] spapr: CPU hot unplug support, Bharata B Rao, 2015/03/23
- [Qemu-devel] [RFC PATCH v2 22/23] spapr: Support ibm, dynamic-reconfiguration-memory, Bharata B Rao, 2015/03/23
- [Qemu-devel] [RFC PATCH v2 23/23] spapr: Memory hotplug support, Bharata B Rao, 2015/03/23
- [Qemu-devel] [RFC PATCH v2 21/23] spapr: Initialize hotplug memory address space,
Bharata B Rao <=
- Re: [Qemu-devel] [RFC PATCH v2 00/23] CPU and Memory hotplug for PowerPC sPAPR guests, David Gibson, 2015/03/25