Machine queue, 2018-05-07
* pc-dimm: factor out MemoryDevice (virtio-pmem and virtio-mem will make use of the new abstraction later) * scripts/device-crash-test: Removed fixed CAN entries -----BEGIN PGP SIGNATURE----- iQIcBAABCAAGBQJa8IZ2AAoJECgHk2+YTcWmmD0P/2Lddw+ilGhGS/CWarq4uLSF ILtEMwNgbJeJAEza6IQx/IIuUER3H5UcxgZhO49nELpurobhl5yW9JKP1qjH9z9i 7hVPORGioiyGkjgjbm8jWtljePAloTIwEiIcrqYkVHpWDCUJaZ7SES2VQL7ltY/W AU3uSFQQMDfVqr/MXDxZq084wFK3Jm2aIE+p8a0MF7B+29RSHdFU9iKysCC1Wu/1 AllXCkQ4yWHCGoSRBfzFz9EWBb4VlzM+VNj9nhHu75zdF3hm7J05yIiGuZLiOjmB MDOkvKhSeXNj+21mXVLmSxkfI65z6jrq3aI7iTp4+orrd2SCXoHsOZoj4Q2cRSnw kJlY62+p85H9NYIKTgMCM/oURpL2ZnqPKmCto1NRFywSBGLXll2weyKpX9ByvXe2 gL8hqra/K8eUPW4zSsPYbbN1b16EnK4MY2nkYvG0Y/aAXGZF6V9zQwKNT4/F5GyY SRMC4c2OtQOgZNDSuPdgZ5Lu5PXfetvvcqWCj0tXNdaScOp6Omsc/i/YCUtu6r/3 IbBIclJ+K5aD+U4QP4DKZ+DJbEkIGMU4pSHgR2i8bK7MmoJpJcAIB1mL5nA/TknP /RVgtnP7gVbfGIVVwjUw9bMurvOti4PBp0/DxC/VqUqGs9e8avE1yb9grVJdj/jA oEGJ6EIsmO1URbk1+f93 =Hhge -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/ehabkost/tags/machine-next-pull-request' into staging Machine queue, 2018-05-07 * pc-dimm: factor out MemoryDevice (virtio-pmem and virtio-mem will make use of the new abstraction later) * scripts/device-crash-test: Removed fixed CAN entries # gpg: Signature made Mon 07 May 2018 18:01:42 BST # gpg: using RSA key 2807936F984DC5A6 # gpg: Good signature from "Eduardo Habkost <ehabkost@redhat.com>" # Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF D1AA 2807 936F 984D C5A6 * remotes/ehabkost/tags/machine-next-pull-request: scripts/device-crash-test: Removed fixed CAN entries vl: allow 'maxmem' without 'slot' spapr: rename "hotplug memory" terminology to "device memory" pc: rename "hotplug memory" terminology to "device memory" machine: rename MemoryHotplugState to DeviceMemoryState pc-dimm: move actual plug/unplug of a memory region to MemoryDevice pc-dimm: factor out capacity and slot checks into MemoryDevice pc-dimm: factor out address search into MemoryDevice code pc-dimm: pass in the machine and to the MemoryHotplugState pc-dimm: no need to pass the memory region machine: make MemoryHotplugState accessible via the machine pc-dimm: factor out MemoryDevice interface Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
		
						commit
						cc8f8ba754
					
				@ -46,6 +46,7 @@
 | 
				
			|||||||
#include "hw/acpi/vmgenid.h"
 | 
					#include "hw/acpi/vmgenid.h"
 | 
				
			||||||
#include "sysemu/tpm_backend.h"
 | 
					#include "sysemu/tpm_backend.h"
 | 
				
			||||||
#include "hw/timer/mc146818rtc_regs.h"
 | 
					#include "hw/timer/mc146818rtc_regs.h"
 | 
				
			||||||
 | 
					#include "hw/mem/memory-device.h"
 | 
				
			||||||
#include "sysemu/numa.h"
 | 
					#include "sysemu/numa.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Supported chipsets: */
 | 
					/* Supported chipsets: */
 | 
				
			||||||
@ -2253,7 +2254,7 @@ build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog)
 | 
				
			|||||||
static void build_srat_hotpluggable_memory(GArray *table_data, uint64_t base,
 | 
					static void build_srat_hotpluggable_memory(GArray *table_data, uint64_t base,
 | 
				
			||||||
                                           uint64_t len, int default_node)
 | 
					                                           uint64_t len, int default_node)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    MemoryDeviceInfoList *info_list = qmp_pc_dimm_device_list();
 | 
					    MemoryDeviceInfoList *info_list = qmp_memory_device_list();
 | 
				
			||||||
    MemoryDeviceInfoList *info;
 | 
					    MemoryDeviceInfoList *info;
 | 
				
			||||||
    MemoryDeviceInfo *mi;
 | 
					    MemoryDeviceInfo *mi;
 | 
				
			||||||
    PCDIMMDeviceInfo *di;
 | 
					    PCDIMMDeviceInfo *di;
 | 
				
			||||||
@ -2312,7 +2313,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine)
 | 
				
			|||||||
    const CPUArchIdList *apic_ids = mc->possible_cpu_arch_ids(machine);
 | 
					    const CPUArchIdList *apic_ids = mc->possible_cpu_arch_ids(machine);
 | 
				
			||||||
    PCMachineState *pcms = PC_MACHINE(machine);
 | 
					    PCMachineState *pcms = PC_MACHINE(machine);
 | 
				
			||||||
    ram_addr_t hotplugabble_address_space_size =
 | 
					    ram_addr_t hotplugabble_address_space_size =
 | 
				
			||||||
        object_property_get_int(OBJECT(pcms), PC_MACHINE_MEMHP_REGION_SIZE,
 | 
					        object_property_get_int(OBJECT(pcms), PC_MACHINE_DEVMEM_REGION_SIZE,
 | 
				
			||||||
                                NULL);
 | 
					                                NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    srat_start = table_data->len;
 | 
					    srat_start = table_data->len;
 | 
				
			||||||
@ -2410,7 +2411,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine)
 | 
				
			|||||||
     * providing _PXM method if necessary.
 | 
					     * providing _PXM method if necessary.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    if (hotplugabble_address_space_size) {
 | 
					    if (hotplugabble_address_space_size) {
 | 
				
			||||||
        build_srat_hotpluggable_memory(table_data, pcms->hotplug_memory.base,
 | 
					        build_srat_hotpluggable_memory(table_data, machine->device_memory->base,
 | 
				
			||||||
                                       hotplugabble_address_space_size,
 | 
					                                       hotplugabble_address_space_size,
 | 
				
			||||||
                                       pcms->numa_nodes - 1);
 | 
					                                       pcms->numa_nodes - 1);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										65
									
								
								hw/i386/pc.c
									
									
									
									
									
								
							
							
						
						
									
										65
									
								
								hw/i386/pc.c
									
									
									
									
									
								
							@ -1371,11 +1371,13 @@ void pc_memory_init(PCMachineState *pcms,
 | 
				
			|||||||
        exit(EXIT_FAILURE);
 | 
					        exit(EXIT_FAILURE);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* initialize hotplug memory address space */
 | 
					    /* always allocate the device memory information */
 | 
				
			||||||
 | 
					    machine->device_memory = g_malloc0(sizeof(*machine->device_memory));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* initialize device memory address space */
 | 
				
			||||||
    if (pcmc->has_reserved_memory &&
 | 
					    if (pcmc->has_reserved_memory &&
 | 
				
			||||||
        (machine->ram_size < machine->maxram_size)) {
 | 
					        (machine->ram_size < machine->maxram_size)) {
 | 
				
			||||||
        ram_addr_t hotplug_mem_size =
 | 
					        ram_addr_t device_mem_size = machine->maxram_size - machine->ram_size;
 | 
				
			||||||
            machine->maxram_size - machine->ram_size;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (machine->ram_slots > ACPI_MAX_RAM_SLOTS) {
 | 
					        if (machine->ram_slots > ACPI_MAX_RAM_SLOTS) {
 | 
				
			||||||
            error_report("unsupported amount of memory slots: %"PRIu64,
 | 
					            error_report("unsupported amount of memory slots: %"PRIu64,
 | 
				
			||||||
@ -1390,25 +1392,25 @@ void pc_memory_init(PCMachineState *pcms,
 | 
				
			|||||||
            exit(EXIT_FAILURE);
 | 
					            exit(EXIT_FAILURE);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        pcms->hotplug_memory.base =
 | 
					        machine->device_memory->base =
 | 
				
			||||||
            ROUND_UP(0x100000000ULL + pcms->above_4g_mem_size, 1ULL << 30);
 | 
					            ROUND_UP(0x100000000ULL + pcms->above_4g_mem_size, 1ULL << 30);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (pcmc->enforce_aligned_dimm) {
 | 
					        if (pcmc->enforce_aligned_dimm) {
 | 
				
			||||||
            /* size hotplug region assuming 1G page max alignment per slot */
 | 
					            /* size device region assuming 1G page max alignment per slot */
 | 
				
			||||||
            hotplug_mem_size += (1ULL << 30) * machine->ram_slots;
 | 
					            device_mem_size += (1ULL << 30) * machine->ram_slots;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ((pcms->hotplug_memory.base + hotplug_mem_size) <
 | 
					        if ((machine->device_memory->base + device_mem_size) <
 | 
				
			||||||
            hotplug_mem_size) {
 | 
					            device_mem_size) {
 | 
				
			||||||
            error_report("unsupported amount of maximum memory: " RAM_ADDR_FMT,
 | 
					            error_report("unsupported amount of maximum memory: " RAM_ADDR_FMT,
 | 
				
			||||||
                         machine->maxram_size);
 | 
					                         machine->maxram_size);
 | 
				
			||||||
            exit(EXIT_FAILURE);
 | 
					            exit(EXIT_FAILURE);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        memory_region_init(&pcms->hotplug_memory.mr, OBJECT(pcms),
 | 
					        memory_region_init(&machine->device_memory->mr, OBJECT(pcms),
 | 
				
			||||||
                           "hotplug-memory", hotplug_mem_size);
 | 
					                           "device-memory", device_mem_size);
 | 
				
			||||||
        memory_region_add_subregion(system_memory, pcms->hotplug_memory.base,
 | 
					        memory_region_add_subregion(system_memory, machine->device_memory->base,
 | 
				
			||||||
                                    &pcms->hotplug_memory.mr);
 | 
					                                    &machine->device_memory->mr);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Initialize PC system firmware */
 | 
					    /* Initialize PC system firmware */
 | 
				
			||||||
@ -1429,13 +1431,13 @@ void pc_memory_init(PCMachineState *pcms,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    rom_set_fw(fw_cfg);
 | 
					    rom_set_fw(fw_cfg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (pcmc->has_reserved_memory && pcms->hotplug_memory.base) {
 | 
					    if (pcmc->has_reserved_memory && machine->device_memory->base) {
 | 
				
			||||||
        uint64_t *val = g_malloc(sizeof(*val));
 | 
					        uint64_t *val = g_malloc(sizeof(*val));
 | 
				
			||||||
        PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
 | 
					        PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
 | 
				
			||||||
        uint64_t res_mem_end = pcms->hotplug_memory.base;
 | 
					        uint64_t res_mem_end = machine->device_memory->base;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!pcmc->broken_reserved_end) {
 | 
					        if (!pcmc->broken_reserved_end) {
 | 
				
			||||||
            res_mem_end += memory_region_size(&pcms->hotplug_memory.mr);
 | 
					            res_mem_end += memory_region_size(&machine->device_memory->mr);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        *val = cpu_to_le64(ROUND_UP(res_mem_end, 0x1ULL << 30));
 | 
					        *val = cpu_to_le64(ROUND_UP(res_mem_end, 0x1ULL << 30));
 | 
				
			||||||
        fw_cfg_add_file(fw_cfg, "etc/reserved-memory-end", val, sizeof(*val));
 | 
					        fw_cfg_add_file(fw_cfg, "etc/reserved-memory-end", val, sizeof(*val));
 | 
				
			||||||
@ -1462,12 +1464,13 @@ uint64_t pc_pci_hole64_start(void)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    PCMachineState *pcms = PC_MACHINE(qdev_get_machine());
 | 
					    PCMachineState *pcms = PC_MACHINE(qdev_get_machine());
 | 
				
			||||||
    PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
 | 
					    PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
 | 
				
			||||||
 | 
					    MachineState *ms = MACHINE(pcms);
 | 
				
			||||||
    uint64_t hole64_start = 0;
 | 
					    uint64_t hole64_start = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (pcmc->has_reserved_memory && pcms->hotplug_memory.base) {
 | 
					    if (pcmc->has_reserved_memory && ms->device_memory->base) {
 | 
				
			||||||
        hole64_start = pcms->hotplug_memory.base;
 | 
					        hole64_start = ms->device_memory->base;
 | 
				
			||||||
        if (!pcmc->broken_reserved_end) {
 | 
					        if (!pcmc->broken_reserved_end) {
 | 
				
			||||||
            hole64_start += memory_region_size(&pcms->hotplug_memory.mr);
 | 
					            hole64_start += memory_region_size(&ms->device_memory->mr);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        hole64_start = 0x100000000ULL + pcms->above_4g_mem_size;
 | 
					        hole64_start = 0x100000000ULL + pcms->above_4g_mem_size;
 | 
				
			||||||
@ -1711,7 +1714,7 @@ static void pc_dimm_plug(HotplugHandler *hotplug_dev,
 | 
				
			|||||||
        goto out;
 | 
					        goto out;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pc_dimm_memory_plug(dev, &pcms->hotplug_memory, mr, align, &local_err);
 | 
					    pc_dimm_memory_plug(dev, MACHINE(pcms), align, &local_err);
 | 
				
			||||||
    if (local_err) {
 | 
					    if (local_err) {
 | 
				
			||||||
        goto out;
 | 
					        goto out;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -1761,17 +1764,9 @@ static void pc_dimm_unplug(HotplugHandler *hotplug_dev,
 | 
				
			|||||||
                           DeviceState *dev, Error **errp)
 | 
					                           DeviceState *dev, Error **errp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    PCMachineState *pcms = PC_MACHINE(hotplug_dev);
 | 
					    PCMachineState *pcms = PC_MACHINE(hotplug_dev);
 | 
				
			||||||
    PCDIMMDevice *dimm = PC_DIMM(dev);
 | 
					 | 
				
			||||||
    PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);
 | 
					 | 
				
			||||||
    MemoryRegion *mr;
 | 
					 | 
				
			||||||
    HotplugHandlerClass *hhc;
 | 
					    HotplugHandlerClass *hhc;
 | 
				
			||||||
    Error *local_err = NULL;
 | 
					    Error *local_err = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    mr = ddc->get_memory_region(dimm, &local_err);
 | 
					 | 
				
			||||||
    if (local_err) {
 | 
					 | 
				
			||||||
        goto out;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    hhc = HOTPLUG_HANDLER_GET_CLASS(pcms->acpi_dev);
 | 
					    hhc = HOTPLUG_HANDLER_GET_CLASS(pcms->acpi_dev);
 | 
				
			||||||
    hhc->unplug(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &local_err);
 | 
					    hhc->unplug(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &local_err);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1779,7 +1774,7 @@ static void pc_dimm_unplug(HotplugHandler *hotplug_dev,
 | 
				
			|||||||
        goto out;
 | 
					        goto out;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pc_dimm_memory_unplug(dev, &pcms->hotplug_memory, mr);
 | 
					    pc_dimm_memory_unplug(dev, MACHINE(pcms));
 | 
				
			||||||
    object_unparent(OBJECT(dev));
 | 
					    object_unparent(OBJECT(dev));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 out:
 | 
					 out:
 | 
				
			||||||
@ -2068,12 +2063,12 @@ static HotplugHandler *pc_get_hotpug_handler(MachineState *machine,
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
pc_machine_get_hotplug_memory_region_size(Object *obj, Visitor *v,
 | 
					pc_machine_get_device_memory_region_size(Object *obj, Visitor *v,
 | 
				
			||||||
                                          const char *name, void *opaque,
 | 
					                                         const char *name, void *opaque,
 | 
				
			||||||
                                          Error **errp)
 | 
					                                         Error **errp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    PCMachineState *pcms = PC_MACHINE(obj);
 | 
					    MachineState *ms = MACHINE(obj);
 | 
				
			||||||
    int64_t value = memory_region_size(&pcms->hotplug_memory.mr);
 | 
					    int64_t value = memory_region_size(&ms->device_memory->mr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    visit_type_int(v, name, &value, errp);
 | 
					    visit_type_int(v, name, &value, errp);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -2377,8 +2372,8 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
 | 
				
			|||||||
    nc->nmi_monitor_handler = x86_nmi;
 | 
					    nc->nmi_monitor_handler = x86_nmi;
 | 
				
			||||||
    mc->default_cpu_type = TARGET_DEFAULT_CPU_TYPE;
 | 
					    mc->default_cpu_type = TARGET_DEFAULT_CPU_TYPE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    object_class_property_add(oc, PC_MACHINE_MEMHP_REGION_SIZE, "int",
 | 
					    object_class_property_add(oc, PC_MACHINE_DEVMEM_REGION_SIZE, "int",
 | 
				
			||||||
        pc_machine_get_hotplug_memory_region_size, NULL,
 | 
					        pc_machine_get_device_memory_region_size, NULL,
 | 
				
			||||||
        NULL, NULL, &error_abort);
 | 
					        NULL, NULL, &error_abort);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    object_class_property_add(oc, PC_MACHINE_MAX_RAM_BELOW_4G, "size",
 | 
					    object_class_property_add(oc, PC_MACHINE_MAX_RAM_BELOW_4G, "size",
 | 
				
			||||||
 | 
				
			|||||||
@ -1,2 +1,3 @@
 | 
				
			|||||||
common-obj-$(CONFIG_MEM_HOTPLUG) += pc-dimm.o
 | 
					common-obj-$(CONFIG_MEM_HOTPLUG) += pc-dimm.o
 | 
				
			||||||
 | 
					common-obj-$(CONFIG_MEM_HOTPLUG) += memory-device.o
 | 
				
			||||||
common-obj-$(CONFIG_NVDIMM) += nvdimm.o
 | 
					common-obj-$(CONFIG_NVDIMM) += nvdimm.o
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										275
									
								
								hw/mem/memory-device.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										275
									
								
								hw/mem/memory-device.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,275 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Memory Device Interface
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Copyright ProfitBricks GmbH 2012
 | 
				
			||||||
 | 
					 * Copyright (C) 2014 Red Hat Inc
 | 
				
			||||||
 | 
					 * Copyright (c) 2018 Red Hat Inc
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This work is licensed under the terms of the GNU GPL, version 2 or later.
 | 
				
			||||||
 | 
					 * See the COPYING file in the top-level directory.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "qemu/osdep.h"
 | 
				
			||||||
 | 
					#include "hw/mem/memory-device.h"
 | 
				
			||||||
 | 
					#include "hw/qdev.h"
 | 
				
			||||||
 | 
					#include "qapi/error.h"
 | 
				
			||||||
 | 
					#include "hw/boards.h"
 | 
				
			||||||
 | 
					#include "qemu/range.h"
 | 
				
			||||||
 | 
					#include "hw/virtio/vhost.h"
 | 
				
			||||||
 | 
					#include "sysemu/kvm.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static gint memory_device_addr_sort(gconstpointer a, gconstpointer b)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    const MemoryDeviceState *md_a = MEMORY_DEVICE(a);
 | 
				
			||||||
 | 
					    const MemoryDeviceState *md_b = MEMORY_DEVICE(b);
 | 
				
			||||||
 | 
					    const MemoryDeviceClass *mdc_a = MEMORY_DEVICE_GET_CLASS(a);
 | 
				
			||||||
 | 
					    const MemoryDeviceClass *mdc_b = MEMORY_DEVICE_GET_CLASS(b);
 | 
				
			||||||
 | 
					    const uint64_t addr_a = mdc_a->get_addr(md_a);
 | 
				
			||||||
 | 
					    const uint64_t addr_b = mdc_b->get_addr(md_b);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (addr_a > addr_b) {
 | 
				
			||||||
 | 
					        return 1;
 | 
				
			||||||
 | 
					    } else if (addr_a < addr_b) {
 | 
				
			||||||
 | 
					        return -1;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int memory_device_build_list(Object *obj, void *opaque)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    GSList **list = opaque;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (object_dynamic_cast(obj, TYPE_MEMORY_DEVICE)) {
 | 
				
			||||||
 | 
					        DeviceState *dev = DEVICE(obj);
 | 
				
			||||||
 | 
					        if (dev->realized) { /* only realized memory devices matter */
 | 
				
			||||||
 | 
					            *list = g_slist_insert_sorted(*list, dev, memory_device_addr_sort);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    object_child_foreach(obj, memory_device_build_list, opaque);
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int memory_device_used_region_size(Object *obj, void *opaque)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    uint64_t *size = opaque;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (object_dynamic_cast(obj, TYPE_MEMORY_DEVICE)) {
 | 
				
			||||||
 | 
					        const DeviceState *dev = DEVICE(obj);
 | 
				
			||||||
 | 
					        const MemoryDeviceState *md = MEMORY_DEVICE(obj);
 | 
				
			||||||
 | 
					        const MemoryDeviceClass *mdc = MEMORY_DEVICE_GET_CLASS(obj);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (dev->realized) {
 | 
				
			||||||
 | 
					            *size += mdc->get_region_size(md);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    object_child_foreach(obj, memory_device_used_region_size, opaque);
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void memory_device_check_addable(MachineState *ms, uint64_t size,
 | 
				
			||||||
 | 
					                                        Error **errp)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    uint64_t used_region_size = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* we will need a new memory slot for kvm and vhost */
 | 
				
			||||||
 | 
					    if (kvm_enabled() && !kvm_has_free_slot(ms)) {
 | 
				
			||||||
 | 
					        error_setg(errp, "hypervisor has no free memory slots left");
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if (!vhost_has_free_slot()) {
 | 
				
			||||||
 | 
					        error_setg(errp, "a used vhost backend has no free memory slots left");
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* will we exceed the total amount of memory specified */
 | 
				
			||||||
 | 
					    memory_device_used_region_size(OBJECT(ms), &used_region_size);
 | 
				
			||||||
 | 
					    if (used_region_size + size > ms->maxram_size - ms->ram_size) {
 | 
				
			||||||
 | 
					        error_setg(errp, "not enough space, currently 0x%" PRIx64
 | 
				
			||||||
 | 
					                   " in use of total hot pluggable 0x" RAM_ADDR_FMT,
 | 
				
			||||||
 | 
					                   used_region_size, ms->maxram_size - ms->ram_size);
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					uint64_t memory_device_get_free_addr(MachineState *ms, const uint64_t *hint,
 | 
				
			||||||
 | 
					                                     uint64_t align, uint64_t size,
 | 
				
			||||||
 | 
					                                     Error **errp)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    uint64_t address_space_start, address_space_end;
 | 
				
			||||||
 | 
					    GSList *list = NULL, *item;
 | 
				
			||||||
 | 
					    uint64_t new_addr = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (!ms->device_memory) {
 | 
				
			||||||
 | 
					        error_setg(errp, "memory devices (e.g. for memory hotplug) are not "
 | 
				
			||||||
 | 
					                         "supported by the machine");
 | 
				
			||||||
 | 
					        return 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (!memory_region_size(&ms->device_memory->mr)) {
 | 
				
			||||||
 | 
					        error_setg(errp, "memory devices (e.g. for memory hotplug) are not "
 | 
				
			||||||
 | 
					                         "enabled, please specify the maxmem option");
 | 
				
			||||||
 | 
					        return 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    address_space_start = ms->device_memory->base;
 | 
				
			||||||
 | 
					    address_space_end = address_space_start +
 | 
				
			||||||
 | 
					                        memory_region_size(&ms->device_memory->mr);
 | 
				
			||||||
 | 
					    g_assert(QEMU_ALIGN_UP(address_space_start, align) == address_space_start);
 | 
				
			||||||
 | 
					    g_assert(address_space_end >= address_space_start);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    memory_device_check_addable(ms, size, errp);
 | 
				
			||||||
 | 
					    if (*errp) {
 | 
				
			||||||
 | 
					        return 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (hint && QEMU_ALIGN_UP(*hint, align) != *hint) {
 | 
				
			||||||
 | 
					        error_setg(errp, "address must be aligned to 0x%" PRIx64 " bytes",
 | 
				
			||||||
 | 
					                   align);
 | 
				
			||||||
 | 
					        return 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (QEMU_ALIGN_UP(size, align) != size) {
 | 
				
			||||||
 | 
					        error_setg(errp, "backend memory size must be multiple of 0x%"
 | 
				
			||||||
 | 
					                   PRIx64, align);
 | 
				
			||||||
 | 
					        return 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (hint) {
 | 
				
			||||||
 | 
					        new_addr = *hint;
 | 
				
			||||||
 | 
					        if (new_addr < address_space_start) {
 | 
				
			||||||
 | 
					            error_setg(errp, "can't add memory [0x%" PRIx64 ":0x%" PRIx64
 | 
				
			||||||
 | 
					                       "] at 0x%" PRIx64, new_addr, size, address_space_start);
 | 
				
			||||||
 | 
					            return 0;
 | 
				
			||||||
 | 
					        } else if ((new_addr + size) > address_space_end) {
 | 
				
			||||||
 | 
					            error_setg(errp, "can't add memory [0x%" PRIx64 ":0x%" PRIx64
 | 
				
			||||||
 | 
					                       "] beyond 0x%" PRIx64, new_addr, size,
 | 
				
			||||||
 | 
					                       address_space_end);
 | 
				
			||||||
 | 
					            return 0;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					        new_addr = address_space_start;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* find address range that will fit new memory device */
 | 
				
			||||||
 | 
					    object_child_foreach(OBJECT(ms), memory_device_build_list, &list);
 | 
				
			||||||
 | 
					    for (item = list; item; item = g_slist_next(item)) {
 | 
				
			||||||
 | 
					        const MemoryDeviceState *md = item->data;
 | 
				
			||||||
 | 
					        const MemoryDeviceClass *mdc = MEMORY_DEVICE_GET_CLASS(OBJECT(md));
 | 
				
			||||||
 | 
					        uint64_t md_size, md_addr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        md_addr = mdc->get_addr(md);
 | 
				
			||||||
 | 
					        md_size = mdc->get_region_size(md);
 | 
				
			||||||
 | 
					        if (*errp) {
 | 
				
			||||||
 | 
					            goto out;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (ranges_overlap(md_addr, md_size, new_addr, size)) {
 | 
				
			||||||
 | 
					            if (hint) {
 | 
				
			||||||
 | 
					                const DeviceState *d = DEVICE(md);
 | 
				
			||||||
 | 
					                error_setg(errp, "address range conflicts with '%s'", d->id);
 | 
				
			||||||
 | 
					                goto out;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            new_addr = QEMU_ALIGN_UP(md_addr + md_size, align);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (new_addr + size > address_space_end) {
 | 
				
			||||||
 | 
					        error_setg(errp, "could not find position in guest address space for "
 | 
				
			||||||
 | 
					                   "memory device - memory fragmented due to alignments");
 | 
				
			||||||
 | 
					        goto out;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					out:
 | 
				
			||||||
 | 
					    g_slist_free(list);
 | 
				
			||||||
 | 
					    return new_addr;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					MemoryDeviceInfoList *qmp_memory_device_list(void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    GSList *devices = NULL, *item;
 | 
				
			||||||
 | 
					    MemoryDeviceInfoList *list = NULL, *prev = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    object_child_foreach(qdev_get_machine(), memory_device_build_list,
 | 
				
			||||||
 | 
					                         &devices);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (item = devices; item; item = g_slist_next(item)) {
 | 
				
			||||||
 | 
					        const MemoryDeviceState *md = MEMORY_DEVICE(item->data);
 | 
				
			||||||
 | 
					        const MemoryDeviceClass *mdc = MEMORY_DEVICE_GET_CLASS(item->data);
 | 
				
			||||||
 | 
					        MemoryDeviceInfoList *elem = g_new0(MemoryDeviceInfoList, 1);
 | 
				
			||||||
 | 
					        MemoryDeviceInfo *info = g_new0(MemoryDeviceInfo, 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        mdc->fill_device_info(md, info);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        elem->value = info;
 | 
				
			||||||
 | 
					        elem->next = NULL;
 | 
				
			||||||
 | 
					        if (prev) {
 | 
				
			||||||
 | 
					            prev->next = elem;
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            list = elem;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        prev = elem;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    g_slist_free(devices);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return list;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int memory_device_plugged_size(Object *obj, void *opaque)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    uint64_t *size = opaque;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (object_dynamic_cast(obj, TYPE_MEMORY_DEVICE)) {
 | 
				
			||||||
 | 
					        const DeviceState *dev = DEVICE(obj);
 | 
				
			||||||
 | 
					        const MemoryDeviceState *md = MEMORY_DEVICE(obj);
 | 
				
			||||||
 | 
					        const MemoryDeviceClass *mdc = MEMORY_DEVICE_GET_CLASS(obj);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (dev->realized) {
 | 
				
			||||||
 | 
					            *size += mdc->get_plugged_size(md);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    object_child_foreach(obj, memory_device_plugged_size, opaque);
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					uint64_t get_plugged_memory_size(void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    uint64_t size = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    memory_device_plugged_size(qdev_get_machine(), &size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return size;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void memory_device_plug_region(MachineState *ms, MemoryRegion *mr,
 | 
				
			||||||
 | 
					                               uint64_t addr)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /* we expect a previous call to memory_device_get_free_addr() */
 | 
				
			||||||
 | 
					    g_assert(ms->device_memory);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    memory_region_add_subregion(&ms->device_memory->mr,
 | 
				
			||||||
 | 
					                                addr - ms->device_memory->base, mr);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void memory_device_unplug_region(MachineState *ms, MemoryRegion *mr)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /* we expect a previous call to memory_device_get_free_addr() */
 | 
				
			||||||
 | 
					    g_assert(ms->device_memory);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    memory_region_del_subregion(&ms->device_memory->mr, mr);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static const TypeInfo memory_device_info = {
 | 
				
			||||||
 | 
					    .name          = TYPE_MEMORY_DEVICE,
 | 
				
			||||||
 | 
					    .parent        = TYPE_INTERFACE,
 | 
				
			||||||
 | 
					    .class_size = sizeof(MemoryDeviceClass),
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void memory_device_register_types(void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    type_register_static(&memory_device_info);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type_init(memory_device_register_types)
 | 
				
			||||||
							
								
								
									
										308
									
								
								hw/mem/pc-dimm.c
									
									
									
									
									
								
							
							
						
						
									
										308
									
								
								hw/mem/pc-dimm.c
									
									
									
									
									
								
							@ -21,60 +21,45 @@
 | 
				
			|||||||
#include "qemu/osdep.h"
 | 
					#include "qemu/osdep.h"
 | 
				
			||||||
#include "hw/mem/pc-dimm.h"
 | 
					#include "hw/mem/pc-dimm.h"
 | 
				
			||||||
#include "hw/mem/nvdimm.h"
 | 
					#include "hw/mem/nvdimm.h"
 | 
				
			||||||
 | 
					#include "hw/mem/memory-device.h"
 | 
				
			||||||
#include "qapi/error.h"
 | 
					#include "qapi/error.h"
 | 
				
			||||||
#include "qemu/config-file.h"
 | 
					 | 
				
			||||||
#include "qapi/visitor.h"
 | 
					#include "qapi/visitor.h"
 | 
				
			||||||
#include "qemu/range.h"
 | 
					 | 
				
			||||||
#include "sysemu/numa.h"
 | 
					#include "sysemu/numa.h"
 | 
				
			||||||
#include "sysemu/kvm.h"
 | 
					 | 
				
			||||||
#include "trace.h"
 | 
					#include "trace.h"
 | 
				
			||||||
#include "hw/virtio/vhost.h"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct pc_dimms_capacity {
 | 
					typedef struct pc_dimms_capacity {
 | 
				
			||||||
     uint64_t size;
 | 
					     uint64_t size;
 | 
				
			||||||
     Error    **errp;
 | 
					     Error    **errp;
 | 
				
			||||||
} pc_dimms_capacity;
 | 
					} pc_dimms_capacity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms,
 | 
					void pc_dimm_memory_plug(DeviceState *dev, MachineState *machine,
 | 
				
			||||||
                         MemoryRegion *mr, uint64_t align, Error **errp)
 | 
					                         uint64_t align, Error **errp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int slot;
 | 
					    int slot;
 | 
				
			||||||
    MachineState *machine = MACHINE(qdev_get_machine());
 | 
					 | 
				
			||||||
    PCDIMMDevice *dimm = PC_DIMM(dev);
 | 
					    PCDIMMDevice *dimm = PC_DIMM(dev);
 | 
				
			||||||
    PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);
 | 
					    PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);
 | 
				
			||||||
    MemoryRegion *vmstate_mr = ddc->get_vmstate_memory_region(dimm);
 | 
					    MemoryRegion *vmstate_mr = ddc->get_vmstate_memory_region(dimm);
 | 
				
			||||||
    Error *local_err = NULL;
 | 
					    Error *local_err = NULL;
 | 
				
			||||||
    uint64_t existing_dimms_capacity = 0;
 | 
					    MemoryRegion *mr;
 | 
				
			||||||
    uint64_t addr;
 | 
					    uint64_t addr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    mr = ddc->get_memory_region(dimm, &local_err);
 | 
				
			||||||
 | 
					    if (local_err) {
 | 
				
			||||||
 | 
					        goto out;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    addr = object_property_get_uint(OBJECT(dimm),
 | 
					    addr = object_property_get_uint(OBJECT(dimm),
 | 
				
			||||||
                                    PC_DIMM_ADDR_PROP, &local_err);
 | 
					                                    PC_DIMM_ADDR_PROP, &local_err);
 | 
				
			||||||
    if (local_err) {
 | 
					    if (local_err) {
 | 
				
			||||||
        goto out;
 | 
					        goto out;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    addr = pc_dimm_get_free_addr(hpms->base,
 | 
					    addr = memory_device_get_free_addr(machine, !addr ? NULL : &addr, align,
 | 
				
			||||||
                                 memory_region_size(&hpms->mr),
 | 
					                                       memory_region_size(mr), &local_err);
 | 
				
			||||||
                                 !addr ? NULL : &addr, align,
 | 
					 | 
				
			||||||
                                 memory_region_size(mr), &local_err);
 | 
					 | 
				
			||||||
    if (local_err) {
 | 
					    if (local_err) {
 | 
				
			||||||
        goto out;
 | 
					        goto out;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    existing_dimms_capacity = pc_existing_dimms_capacity(&local_err);
 | 
					 | 
				
			||||||
    if (local_err) {
 | 
					 | 
				
			||||||
        goto out;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (existing_dimms_capacity + memory_region_size(mr) >
 | 
					 | 
				
			||||||
        machine->maxram_size - machine->ram_size) {
 | 
					 | 
				
			||||||
        error_setg(&local_err, "not enough space, currently 0x%" PRIx64
 | 
					 | 
				
			||||||
                   " in use of total hot pluggable 0x" RAM_ADDR_FMT,
 | 
					 | 
				
			||||||
                   existing_dimms_capacity,
 | 
					 | 
				
			||||||
                   machine->maxram_size - machine->ram_size);
 | 
					 | 
				
			||||||
        goto out;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    object_property_set_uint(OBJECT(dev), addr, PC_DIMM_ADDR_PROP, &local_err);
 | 
					    object_property_set_uint(OBJECT(dev), addr, PC_DIMM_ADDR_PROP, &local_err);
 | 
				
			||||||
    if (local_err) {
 | 
					    if (local_err) {
 | 
				
			||||||
        goto out;
 | 
					        goto out;
 | 
				
			||||||
@ -97,72 +82,24 @@ void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms,
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    trace_mhp_pc_dimm_assigned_slot(slot);
 | 
					    trace_mhp_pc_dimm_assigned_slot(slot);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (kvm_enabled() && !kvm_has_free_slot(machine)) {
 | 
					    memory_device_plug_region(machine, mr, addr);
 | 
				
			||||||
        error_setg(&local_err, "hypervisor has no free memory slots left");
 | 
					 | 
				
			||||||
        goto out;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (!vhost_has_free_slot()) {
 | 
					 | 
				
			||||||
        error_setg(&local_err, "a used vhost backend has no free"
 | 
					 | 
				
			||||||
                               " memory slots left");
 | 
					 | 
				
			||||||
        goto out;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    memory_region_add_subregion(&hpms->mr, addr - hpms->base, mr);
 | 
					 | 
				
			||||||
    vmstate_register_ram(vmstate_mr, dev);
 | 
					    vmstate_register_ram(vmstate_mr, dev);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
out:
 | 
					out:
 | 
				
			||||||
    error_propagate(errp, local_err);
 | 
					    error_propagate(errp, local_err);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void pc_dimm_memory_unplug(DeviceState *dev, MemoryHotplugState *hpms,
 | 
					void pc_dimm_memory_unplug(DeviceState *dev, MachineState *machine)
 | 
				
			||||||
                           MemoryRegion *mr)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    PCDIMMDevice *dimm = PC_DIMM(dev);
 | 
					    PCDIMMDevice *dimm = PC_DIMM(dev);
 | 
				
			||||||
    PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);
 | 
					    PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);
 | 
				
			||||||
    MemoryRegion *vmstate_mr = ddc->get_vmstate_memory_region(dimm);
 | 
					    MemoryRegion *vmstate_mr = ddc->get_vmstate_memory_region(dimm);
 | 
				
			||||||
 | 
					    MemoryRegion *mr = ddc->get_memory_region(dimm, &error_abort);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    memory_region_del_subregion(&hpms->mr, mr);
 | 
					    memory_device_unplug_region(machine, mr);
 | 
				
			||||||
    vmstate_unregister_ram(vmstate_mr, dev);
 | 
					    vmstate_unregister_ram(vmstate_mr, dev);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int pc_existing_dimms_capacity_internal(Object *obj, void *opaque)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    pc_dimms_capacity *cap = opaque;
 | 
					 | 
				
			||||||
    uint64_t *size = &cap->size;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (object_dynamic_cast(obj, TYPE_PC_DIMM)) {
 | 
					 | 
				
			||||||
        DeviceState *dev = DEVICE(obj);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (dev->realized) {
 | 
					 | 
				
			||||||
            (*size) += object_property_get_uint(obj, PC_DIMM_SIZE_PROP,
 | 
					 | 
				
			||||||
                cap->errp);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (cap->errp && *cap->errp) {
 | 
					 | 
				
			||||||
            return 1;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    object_child_foreach(obj, pc_existing_dimms_capacity_internal, opaque);
 | 
					 | 
				
			||||||
    return 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
uint64_t pc_existing_dimms_capacity(Error **errp)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    pc_dimms_capacity cap;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    cap.size = 0;
 | 
					 | 
				
			||||||
    cap.errp = errp;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    pc_existing_dimms_capacity_internal(qdev_get_machine(), &cap);
 | 
					 | 
				
			||||||
    return cap.size;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
uint64_t get_plugged_memory_size(void)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    return pc_existing_dimms_capacity(&error_abort);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static int pc_dimm_slot2bitmap(Object *obj, void *opaque)
 | 
					static int pc_dimm_slot2bitmap(Object *obj, void *opaque)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    unsigned long *bitmap = opaque;
 | 
					    unsigned long *bitmap = opaque;
 | 
				
			||||||
@ -209,158 +146,6 @@ out:
 | 
				
			|||||||
    return slot;
 | 
					    return slot;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static gint pc_dimm_addr_sort(gconstpointer a, gconstpointer b)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    PCDIMMDevice *x = PC_DIMM(a);
 | 
					 | 
				
			||||||
    PCDIMMDevice *y = PC_DIMM(b);
 | 
					 | 
				
			||||||
    Int128 diff = int128_sub(int128_make64(x->addr), int128_make64(y->addr));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (int128_lt(diff, int128_zero())) {
 | 
					 | 
				
			||||||
        return -1;
 | 
					 | 
				
			||||||
    } else if (int128_gt(diff, int128_zero())) {
 | 
					 | 
				
			||||||
        return 1;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    return 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static int pc_dimm_built_list(Object *obj, void *opaque)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    GSList **list = opaque;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (object_dynamic_cast(obj, TYPE_PC_DIMM)) {
 | 
					 | 
				
			||||||
        DeviceState *dev = DEVICE(obj);
 | 
					 | 
				
			||||||
        if (dev->realized) { /* only realized DIMMs matter */
 | 
					 | 
				
			||||||
            *list = g_slist_insert_sorted(*list, dev, pc_dimm_addr_sort);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    object_child_foreach(obj, pc_dimm_built_list, opaque);
 | 
					 | 
				
			||||||
    return 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
MemoryDeviceInfoList *qmp_pc_dimm_device_list(void)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    GSList *dimms = NULL, *item;
 | 
					 | 
				
			||||||
    MemoryDeviceInfoList *list = NULL, *prev = NULL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    object_child_foreach(qdev_get_machine(), pc_dimm_built_list, &dimms);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    for (item = dimms; item; item = g_slist_next(item)) {
 | 
					 | 
				
			||||||
        PCDIMMDevice *dimm = PC_DIMM(item->data);
 | 
					 | 
				
			||||||
        Object *obj = OBJECT(dimm);
 | 
					 | 
				
			||||||
        MemoryDeviceInfoList *elem = g_new0(MemoryDeviceInfoList, 1);
 | 
					 | 
				
			||||||
        MemoryDeviceInfo *info = g_new0(MemoryDeviceInfo, 1);
 | 
					 | 
				
			||||||
        PCDIMMDeviceInfo *di = g_new0(PCDIMMDeviceInfo, 1);
 | 
					 | 
				
			||||||
        bool is_nvdimm = object_dynamic_cast(obj, TYPE_NVDIMM);
 | 
					 | 
				
			||||||
        DeviceClass *dc = DEVICE_GET_CLASS(obj);
 | 
					 | 
				
			||||||
        DeviceState *dev = DEVICE(obj);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (dev->id) {
 | 
					 | 
				
			||||||
            di->has_id = true;
 | 
					 | 
				
			||||||
            di->id = g_strdup(dev->id);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        di->hotplugged = dev->hotplugged;
 | 
					 | 
				
			||||||
        di->hotpluggable = dc->hotpluggable;
 | 
					 | 
				
			||||||
        di->addr = dimm->addr;
 | 
					 | 
				
			||||||
        di->slot = dimm->slot;
 | 
					 | 
				
			||||||
        di->node = dimm->node;
 | 
					 | 
				
			||||||
        di->size = object_property_get_uint(obj, PC_DIMM_SIZE_PROP, NULL);
 | 
					 | 
				
			||||||
        di->memdev = object_get_canonical_path(OBJECT(dimm->hostmem));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (!is_nvdimm) {
 | 
					 | 
				
			||||||
            info->u.dimm.data = di;
 | 
					 | 
				
			||||||
            info->type = MEMORY_DEVICE_INFO_KIND_DIMM;
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            info->u.nvdimm.data = di;
 | 
					 | 
				
			||||||
            info->type = MEMORY_DEVICE_INFO_KIND_NVDIMM;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        elem->value = info;
 | 
					 | 
				
			||||||
        elem->next = NULL;
 | 
					 | 
				
			||||||
        if (prev) {
 | 
					 | 
				
			||||||
            prev->next = elem;
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            list = elem;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        prev = elem;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    g_slist_free(dimms);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return list;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
uint64_t pc_dimm_get_free_addr(uint64_t address_space_start,
 | 
					 | 
				
			||||||
                               uint64_t address_space_size,
 | 
					 | 
				
			||||||
                               uint64_t *hint, uint64_t align, uint64_t size,
 | 
					 | 
				
			||||||
                               Error **errp)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    GSList *list = NULL, *item;
 | 
					 | 
				
			||||||
    uint64_t new_addr, ret = 0;
 | 
					 | 
				
			||||||
    uint64_t address_space_end = address_space_start + address_space_size;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    g_assert(QEMU_ALIGN_UP(address_space_start, align) == address_space_start);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (!address_space_size) {
 | 
					 | 
				
			||||||
        error_setg(errp, "memory hotplug is not enabled, "
 | 
					 | 
				
			||||||
                         "please add maxmem option");
 | 
					 | 
				
			||||||
        goto out;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (hint && QEMU_ALIGN_UP(*hint, align) != *hint) {
 | 
					 | 
				
			||||||
        error_setg(errp, "address must be aligned to 0x%" PRIx64 " bytes",
 | 
					 | 
				
			||||||
                   align);
 | 
					 | 
				
			||||||
        goto out;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (QEMU_ALIGN_UP(size, align) != size) {
 | 
					 | 
				
			||||||
        error_setg(errp, "backend memory size must be multiple of 0x%"
 | 
					 | 
				
			||||||
                   PRIx64, align);
 | 
					 | 
				
			||||||
        goto out;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    assert(address_space_end > address_space_start);
 | 
					 | 
				
			||||||
    object_child_foreach(qdev_get_machine(), pc_dimm_built_list, &list);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (hint) {
 | 
					 | 
				
			||||||
        new_addr = *hint;
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
        new_addr = address_space_start;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /* find address range that will fit new DIMM */
 | 
					 | 
				
			||||||
    for (item = list; item; item = g_slist_next(item)) {
 | 
					 | 
				
			||||||
        PCDIMMDevice *dimm = item->data;
 | 
					 | 
				
			||||||
        uint64_t dimm_size = object_property_get_uint(OBJECT(dimm),
 | 
					 | 
				
			||||||
                                                      PC_DIMM_SIZE_PROP,
 | 
					 | 
				
			||||||
                                                      errp);
 | 
					 | 
				
			||||||
        if (errp && *errp) {
 | 
					 | 
				
			||||||
            goto out;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (ranges_overlap(dimm->addr, dimm_size, new_addr, size)) {
 | 
					 | 
				
			||||||
            if (hint) {
 | 
					 | 
				
			||||||
                DeviceState *d = DEVICE(dimm);
 | 
					 | 
				
			||||||
                error_setg(errp, "address range conflicts with '%s'", d->id);
 | 
					 | 
				
			||||||
                goto out;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            new_addr = QEMU_ALIGN_UP(dimm->addr + dimm_size, align);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    ret = new_addr;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (new_addr < address_space_start) {
 | 
					 | 
				
			||||||
        error_setg(errp, "can't add memory [0x%" PRIx64 ":0x%" PRIx64
 | 
					 | 
				
			||||||
                   "] at 0x%" PRIx64, new_addr, size, address_space_start);
 | 
					 | 
				
			||||||
    } else if ((new_addr + size) > address_space_end) {
 | 
					 | 
				
			||||||
        error_setg(errp, "can't add memory [0x%" PRIx64 ":0x%" PRIx64
 | 
					 | 
				
			||||||
                   "] beyond 0x%" PRIx64, new_addr, size, address_space_end);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
out:
 | 
					 | 
				
			||||||
    g_slist_free(list);
 | 
					 | 
				
			||||||
    return ret;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static Property pc_dimm_properties[] = {
 | 
					static Property pc_dimm_properties[] = {
 | 
				
			||||||
    DEFINE_PROP_UINT64(PC_DIMM_ADDR_PROP, PCDIMMDevice, addr, 0),
 | 
					    DEFINE_PROP_UINT64(PC_DIMM_ADDR_PROP, PCDIMMDevice, addr, 0),
 | 
				
			||||||
    DEFINE_PROP_UINT32(PC_DIMM_NODE_PROP, PCDIMMDevice, node, 0),
 | 
					    DEFINE_PROP_UINT32(PC_DIMM_NODE_PROP, PCDIMMDevice, node, 0),
 | 
				
			||||||
@ -445,10 +230,63 @@ static MemoryRegion *pc_dimm_get_vmstate_memory_region(PCDIMMDevice *dimm)
 | 
				
			|||||||
    return host_memory_backend_get_memory(dimm->hostmem, &error_abort);
 | 
					    return host_memory_backend_get_memory(dimm->hostmem, &error_abort);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static uint64_t pc_dimm_md_get_addr(const MemoryDeviceState *md)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    const PCDIMMDevice *dimm = PC_DIMM(md);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return dimm->addr;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static uint64_t pc_dimm_md_get_region_size(const MemoryDeviceState *md)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /* dropping const here is fine as we don't touch the memory region */
 | 
				
			||||||
 | 
					    PCDIMMDevice *dimm = PC_DIMM(md);
 | 
				
			||||||
 | 
					    const PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(md);
 | 
				
			||||||
 | 
					    MemoryRegion *mr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    mr = ddc->get_memory_region(dimm, &error_abort);
 | 
				
			||||||
 | 
					    if (!mr) {
 | 
				
			||||||
 | 
					        return 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return memory_region_size(mr);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void pc_dimm_md_fill_device_info(const MemoryDeviceState *md,
 | 
				
			||||||
 | 
					                                        MemoryDeviceInfo *info)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    PCDIMMDeviceInfo *di = g_new0(PCDIMMDeviceInfo, 1);
 | 
				
			||||||
 | 
					    const DeviceClass *dc = DEVICE_GET_CLASS(md);
 | 
				
			||||||
 | 
					    const PCDIMMDevice *dimm = PC_DIMM(md);
 | 
				
			||||||
 | 
					    const DeviceState *dev = DEVICE(md);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (dev->id) {
 | 
				
			||||||
 | 
					        di->has_id = true;
 | 
				
			||||||
 | 
					        di->id = g_strdup(dev->id);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    di->hotplugged = dev->hotplugged;
 | 
				
			||||||
 | 
					    di->hotpluggable = dc->hotpluggable;
 | 
				
			||||||
 | 
					    di->addr = dimm->addr;
 | 
				
			||||||
 | 
					    di->slot = dimm->slot;
 | 
				
			||||||
 | 
					    di->node = dimm->node;
 | 
				
			||||||
 | 
					    di->size = object_property_get_uint(OBJECT(dimm), PC_DIMM_SIZE_PROP,
 | 
				
			||||||
 | 
					                                        NULL);
 | 
				
			||||||
 | 
					    di->memdev = object_get_canonical_path(OBJECT(dimm->hostmem));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM)) {
 | 
				
			||||||
 | 
					        info->u.nvdimm.data = di;
 | 
				
			||||||
 | 
					        info->type = MEMORY_DEVICE_INFO_KIND_NVDIMM;
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					        info->u.dimm.data = di;
 | 
				
			||||||
 | 
					        info->type = MEMORY_DEVICE_INFO_KIND_DIMM;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void pc_dimm_class_init(ObjectClass *oc, void *data)
 | 
					static void pc_dimm_class_init(ObjectClass *oc, void *data)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    DeviceClass *dc = DEVICE_CLASS(oc);
 | 
					    DeviceClass *dc = DEVICE_CLASS(oc);
 | 
				
			||||||
    PCDIMMDeviceClass *ddc = PC_DIMM_CLASS(oc);
 | 
					    PCDIMMDeviceClass *ddc = PC_DIMM_CLASS(oc);
 | 
				
			||||||
 | 
					    MemoryDeviceClass *mdc = MEMORY_DEVICE_CLASS(oc);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    dc->realize = pc_dimm_realize;
 | 
					    dc->realize = pc_dimm_realize;
 | 
				
			||||||
    dc->unrealize = pc_dimm_unrealize;
 | 
					    dc->unrealize = pc_dimm_unrealize;
 | 
				
			||||||
@ -457,6 +295,12 @@ static void pc_dimm_class_init(ObjectClass *oc, void *data)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    ddc->get_memory_region = pc_dimm_get_memory_region;
 | 
					    ddc->get_memory_region = pc_dimm_get_memory_region;
 | 
				
			||||||
    ddc->get_vmstate_memory_region = pc_dimm_get_vmstate_memory_region;
 | 
					    ddc->get_vmstate_memory_region = pc_dimm_get_vmstate_memory_region;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    mdc->get_addr = pc_dimm_md_get_addr;
 | 
				
			||||||
 | 
					    /* for a dimm plugged_size == region_size */
 | 
				
			||||||
 | 
					    mdc->get_plugged_size = pc_dimm_md_get_region_size;
 | 
				
			||||||
 | 
					    mdc->get_region_size = pc_dimm_md_get_region_size;
 | 
				
			||||||
 | 
					    mdc->fill_device_info = pc_dimm_md_fill_device_info;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static TypeInfo pc_dimm_info = {
 | 
					static TypeInfo pc_dimm_info = {
 | 
				
			||||||
@ -466,6 +310,10 @@ static TypeInfo pc_dimm_info = {
 | 
				
			|||||||
    .instance_init = pc_dimm_init,
 | 
					    .instance_init = pc_dimm_init,
 | 
				
			||||||
    .class_init    = pc_dimm_class_init,
 | 
					    .class_init    = pc_dimm_class_init,
 | 
				
			||||||
    .class_size    = sizeof(PCDIMMDeviceClass),
 | 
					    .class_size    = sizeof(PCDIMMDeviceClass),
 | 
				
			||||||
 | 
					    .interfaces = (InterfaceInfo[]) {
 | 
				
			||||||
 | 
					        { TYPE_MEMORY_DEVICE },
 | 
				
			||||||
 | 
					        { }
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void pc_dimm_register_types(void)
 | 
					static void pc_dimm_register_types(void)
 | 
				
			||||||
 | 
				
			|||||||
@ -74,6 +74,7 @@
 | 
				
			|||||||
#include "hw/compat.h"
 | 
					#include "hw/compat.h"
 | 
				
			||||||
#include "qemu/cutils.h"
 | 
					#include "qemu/cutils.h"
 | 
				
			||||||
#include "hw/ppc/spapr_cpu_core.h"
 | 
					#include "hw/ppc/spapr_cpu_core.h"
 | 
				
			||||||
 | 
					#include "hw/mem/memory-device.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <libfdt.h>
 | 
					#include <libfdt.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -702,13 +703,14 @@ spapr_get_drconf_cell(uint32_t seq_lmbs, uint64_t base_addr,
 | 
				
			|||||||
static int spapr_populate_drmem_v2(sPAPRMachineState *spapr, void *fdt,
 | 
					static int spapr_populate_drmem_v2(sPAPRMachineState *spapr, void *fdt,
 | 
				
			||||||
                                   int offset, MemoryDeviceInfoList *dimms)
 | 
					                                   int offset, MemoryDeviceInfoList *dimms)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    MachineState *machine = MACHINE(spapr);
 | 
				
			||||||
    uint8_t *int_buf, *cur_index, buf_len;
 | 
					    uint8_t *int_buf, *cur_index, buf_len;
 | 
				
			||||||
    int ret;
 | 
					    int ret;
 | 
				
			||||||
    uint64_t lmb_size = SPAPR_MEMORY_BLOCK_SIZE;
 | 
					    uint64_t lmb_size = SPAPR_MEMORY_BLOCK_SIZE;
 | 
				
			||||||
    uint64_t addr, cur_addr, size;
 | 
					    uint64_t addr, cur_addr, size;
 | 
				
			||||||
    uint32_t nr_boot_lmbs = (spapr->hotplug_memory.base / lmb_size);
 | 
					    uint32_t nr_boot_lmbs = (machine->device_memory->base / lmb_size);
 | 
				
			||||||
    uint64_t mem_end = spapr->hotplug_memory.base +
 | 
					    uint64_t mem_end = machine->device_memory->base +
 | 
				
			||||||
                       memory_region_size(&spapr->hotplug_memory.mr);
 | 
					                       memory_region_size(&machine->device_memory->mr);
 | 
				
			||||||
    uint32_t node, nr_entries = 0;
 | 
					    uint32_t node, nr_entries = 0;
 | 
				
			||||||
    sPAPRDRConnector *drc;
 | 
					    sPAPRDRConnector *drc;
 | 
				
			||||||
    DrconfCellQueue *elem, *next;
 | 
					    DrconfCellQueue *elem, *next;
 | 
				
			||||||
@ -723,7 +725,7 @@ static int spapr_populate_drmem_v2(sPAPRMachineState *spapr, void *fdt,
 | 
				
			|||||||
    QSIMPLEQ_INSERT_TAIL(&drconf_queue, elem, entry);
 | 
					    QSIMPLEQ_INSERT_TAIL(&drconf_queue, elem, entry);
 | 
				
			||||||
    nr_entries++;
 | 
					    nr_entries++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    cur_addr = spapr->hotplug_memory.base;
 | 
					    cur_addr = machine->device_memory->base;
 | 
				
			||||||
    for (info = dimms; info; info = info->next) {
 | 
					    for (info = dimms; info; info = info->next) {
 | 
				
			||||||
        PCDIMMDeviceInfo *di = info->value->u.dimm.data;
 | 
					        PCDIMMDeviceInfo *di = info->value->u.dimm.data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -786,11 +788,12 @@ static int spapr_populate_drmem_v2(sPAPRMachineState *spapr, void *fdt,
 | 
				
			|||||||
static int spapr_populate_drmem_v1(sPAPRMachineState *spapr, void *fdt,
 | 
					static int spapr_populate_drmem_v1(sPAPRMachineState *spapr, void *fdt,
 | 
				
			||||||
                                   int offset, MemoryDeviceInfoList *dimms)
 | 
					                                   int offset, MemoryDeviceInfoList *dimms)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    MachineState *machine = MACHINE(spapr);
 | 
				
			||||||
    int i, ret;
 | 
					    int i, ret;
 | 
				
			||||||
    uint64_t lmb_size = SPAPR_MEMORY_BLOCK_SIZE;
 | 
					    uint64_t lmb_size = SPAPR_MEMORY_BLOCK_SIZE;
 | 
				
			||||||
    uint32_t hotplug_lmb_start = spapr->hotplug_memory.base / lmb_size;
 | 
					    uint32_t device_lmb_start = machine->device_memory->base / lmb_size;
 | 
				
			||||||
    uint32_t nr_lmbs = (spapr->hotplug_memory.base +
 | 
					    uint32_t nr_lmbs = (machine->device_memory->base +
 | 
				
			||||||
                       memory_region_size(&spapr->hotplug_memory.mr)) /
 | 
					                       memory_region_size(&machine->device_memory->mr)) /
 | 
				
			||||||
                       lmb_size;
 | 
					                       lmb_size;
 | 
				
			||||||
    uint32_t *int_buf, *cur_index, buf_len;
 | 
					    uint32_t *int_buf, *cur_index, buf_len;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -805,7 +808,7 @@ static int spapr_populate_drmem_v1(sPAPRMachineState *spapr, void *fdt,
 | 
				
			|||||||
        uint64_t addr = i * lmb_size;
 | 
					        uint64_t addr = i * lmb_size;
 | 
				
			||||||
        uint32_t *dynamic_memory = cur_index;
 | 
					        uint32_t *dynamic_memory = cur_index;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (i >= hotplug_lmb_start) {
 | 
					        if (i >= device_lmb_start) {
 | 
				
			||||||
            sPAPRDRConnector *drc;
 | 
					            sPAPRDRConnector *drc;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            drc = spapr_drc_by_id(TYPE_SPAPR_DRC_LMB, i);
 | 
					            drc = spapr_drc_by_id(TYPE_SPAPR_DRC_LMB, i);
 | 
				
			||||||
@ -824,7 +827,7 @@ static int spapr_populate_drmem_v1(sPAPRMachineState *spapr, void *fdt,
 | 
				
			|||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            /*
 | 
					            /*
 | 
				
			||||||
             * LMB information for RMA, boot time RAM and gap b/n RAM and
 | 
					             * LMB information for RMA, boot time RAM and gap b/n RAM and
 | 
				
			||||||
             * hotplug memory region -- all these are marked as reserved
 | 
					             * device memory region -- all these are marked as reserved
 | 
				
			||||||
             * and as having no valid DRC.
 | 
					             * and as having no valid DRC.
 | 
				
			||||||
             */
 | 
					             */
 | 
				
			||||||
            dynamic_memory[0] = cpu_to_be32(addr >> 32);
 | 
					            dynamic_memory[0] = cpu_to_be32(addr >> 32);
 | 
				
			||||||
@ -862,7 +865,7 @@ static int spapr_populate_drconf_memory(sPAPRMachineState *spapr, void *fdt)
 | 
				
			|||||||
    MemoryDeviceInfoList *dimms = NULL;
 | 
					    MemoryDeviceInfoList *dimms = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /*
 | 
					    /*
 | 
				
			||||||
     * Don't create the node if there is no hotpluggable memory
 | 
					     * Don't create the node if there is no device memory
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    if (machine->ram_size == machine->maxram_size) {
 | 
					    if (machine->ram_size == machine->maxram_size) {
 | 
				
			||||||
        return 0;
 | 
					        return 0;
 | 
				
			||||||
@ -887,7 +890,7 @@ static int spapr_populate_drconf_memory(sPAPRMachineState *spapr, void *fdt)
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* ibm,dynamic-memory or ibm,dynamic-memory-v2 */
 | 
					    /* ibm,dynamic-memory or ibm,dynamic-memory-v2 */
 | 
				
			||||||
    dimms = qmp_pc_dimm_device_list();
 | 
					    dimms = qmp_memory_device_list();
 | 
				
			||||||
    if (spapr_ovec_test(spapr->ov5_cas, OV5_DRMEM_V2)) {
 | 
					    if (spapr_ovec_test(spapr->ov5_cas, OV5_DRMEM_V2)) {
 | 
				
			||||||
        ret = spapr_populate_drmem_v2(spapr, fdt, offset, dimms);
 | 
					        ret = spapr_populate_drmem_v2(spapr, fdt, offset, dimms);
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
@ -1033,11 +1036,11 @@ static void spapr_dt_rtas(sPAPRMachineState *spapr, void *fdt)
 | 
				
			|||||||
    GString *hypertas = g_string_sized_new(256);
 | 
					    GString *hypertas = g_string_sized_new(256);
 | 
				
			||||||
    GString *qemu_hypertas = g_string_sized_new(256);
 | 
					    GString *qemu_hypertas = g_string_sized_new(256);
 | 
				
			||||||
    uint32_t refpoints[] = { cpu_to_be32(0x4), cpu_to_be32(0x4) };
 | 
					    uint32_t refpoints[] = { cpu_to_be32(0x4), cpu_to_be32(0x4) };
 | 
				
			||||||
    uint64_t max_hotplug_addr = spapr->hotplug_memory.base +
 | 
					    uint64_t max_device_addr = MACHINE(spapr)->device_memory->base +
 | 
				
			||||||
        memory_region_size(&spapr->hotplug_memory.mr);
 | 
					        memory_region_size(&MACHINE(spapr)->device_memory->mr);
 | 
				
			||||||
    uint32_t lrdr_capacity[] = {
 | 
					    uint32_t lrdr_capacity[] = {
 | 
				
			||||||
        cpu_to_be32(max_hotplug_addr >> 32),
 | 
					        cpu_to_be32(max_device_addr >> 32),
 | 
				
			||||||
        cpu_to_be32(max_hotplug_addr & 0xffffffff),
 | 
					        cpu_to_be32(max_device_addr & 0xffffffff),
 | 
				
			||||||
        0, cpu_to_be32(SPAPR_MEMORY_BLOCK_SIZE),
 | 
					        0, cpu_to_be32(SPAPR_MEMORY_BLOCK_SIZE),
 | 
				
			||||||
        cpu_to_be32(max_cpus / smp_threads),
 | 
					        cpu_to_be32(max_cpus / smp_threads),
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
@ -2296,7 +2299,7 @@ static void spapr_create_lmb_dr_connectors(sPAPRMachineState *spapr)
 | 
				
			|||||||
    for (i = 0; i < nr_lmbs; i++) {
 | 
					    for (i = 0; i < nr_lmbs; i++) {
 | 
				
			||||||
        uint64_t addr;
 | 
					        uint64_t addr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        addr = i * lmb_size + spapr->hotplug_memory.base;
 | 
					        addr = i * lmb_size + machine->device_memory->base;
 | 
				
			||||||
        spapr_dr_connector_new(OBJECT(spapr), TYPE_SPAPR_DRC_LMB,
 | 
					        spapr_dr_connector_new(OBJECT(spapr), TYPE_SPAPR_DRC_LMB,
 | 
				
			||||||
                               addr / lmb_size);
 | 
					                               addr / lmb_size);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -2633,9 +2636,12 @@ static void spapr_machine_init(MachineState *machine)
 | 
				
			|||||||
                                         machine->ram_size);
 | 
					                                         machine->ram_size);
 | 
				
			||||||
    memory_region_add_subregion(sysmem, 0, ram);
 | 
					    memory_region_add_subregion(sysmem, 0, ram);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* always allocate the device memory information */
 | 
				
			||||||
 | 
					    machine->device_memory = g_malloc0(sizeof(*machine->device_memory));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* initialize hotplug memory address space */
 | 
					    /* initialize hotplug memory address space */
 | 
				
			||||||
    if (machine->ram_size < machine->maxram_size) {
 | 
					    if (machine->ram_size < machine->maxram_size) {
 | 
				
			||||||
        ram_addr_t hotplug_mem_size = machine->maxram_size - machine->ram_size;
 | 
					        ram_addr_t device_mem_size = machine->maxram_size - machine->ram_size;
 | 
				
			||||||
        /*
 | 
					        /*
 | 
				
			||||||
         * Limit the number of hotpluggable memory slots to half the number
 | 
					         * Limit the number of hotpluggable memory slots to half the number
 | 
				
			||||||
         * slots that KVM supports, leaving the other half for PCI and other
 | 
					         * slots that KVM supports, leaving the other half for PCI and other
 | 
				
			||||||
@ -2654,12 +2660,12 @@ static void spapr_machine_init(MachineState *machine)
 | 
				
			|||||||
            exit(1);
 | 
					            exit(1);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        spapr->hotplug_memory.base = ROUND_UP(machine->ram_size,
 | 
					        machine->device_memory->base = ROUND_UP(machine->ram_size,
 | 
				
			||||||
                                              SPAPR_HOTPLUG_MEM_ALIGN);
 | 
					                                                SPAPR_DEVICE_MEM_ALIGN);
 | 
				
			||||||
        memory_region_init(&spapr->hotplug_memory.mr, OBJECT(spapr),
 | 
					        memory_region_init(&machine->device_memory->mr, OBJECT(spapr),
 | 
				
			||||||
                           "hotplug-memory", hotplug_mem_size);
 | 
					                           "device-memory", device_mem_size);
 | 
				
			||||||
        memory_region_add_subregion(sysmem, spapr->hotplug_memory.base,
 | 
					        memory_region_add_subregion(sysmem, machine->device_memory->base,
 | 
				
			||||||
                                    &spapr->hotplug_memory.mr);
 | 
					                                    &machine->device_memory->mr);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (smc->dr_lmb_enabled) {
 | 
					    if (smc->dr_lmb_enabled) {
 | 
				
			||||||
@ -3147,7 +3153,7 @@ static void spapr_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
 | 
				
			|||||||
    align = memory_region_get_alignment(mr);
 | 
					    align = memory_region_get_alignment(mr);
 | 
				
			||||||
    size = memory_region_size(mr);
 | 
					    size = memory_region_size(mr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pc_dimm_memory_plug(dev, &ms->hotplug_memory, mr, align, &local_err);
 | 
					    pc_dimm_memory_plug(dev, MACHINE(ms), align, &local_err);
 | 
				
			||||||
    if (local_err) {
 | 
					    if (local_err) {
 | 
				
			||||||
        goto out;
 | 
					        goto out;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -3168,7 +3174,7 @@ static void spapr_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
 | 
				
			|||||||
    return;
 | 
					    return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
out_unplug:
 | 
					out_unplug:
 | 
				
			||||||
    pc_dimm_memory_unplug(dev, &ms->hotplug_memory, mr);
 | 
					    pc_dimm_memory_unplug(dev, MACHINE(ms));
 | 
				
			||||||
out:
 | 
					out:
 | 
				
			||||||
    error_propagate(errp, local_err);
 | 
					    error_propagate(errp, local_err);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -3286,9 +3292,6 @@ static sPAPRDIMMState *spapr_recover_pending_dimm_state(sPAPRMachineState *ms,
 | 
				
			|||||||
void spapr_lmb_release(DeviceState *dev)
 | 
					void spapr_lmb_release(DeviceState *dev)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_hotplug_handler(dev));
 | 
					    sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_hotplug_handler(dev));
 | 
				
			||||||
    PCDIMMDevice *dimm = PC_DIMM(dev);
 | 
					 | 
				
			||||||
    PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);
 | 
					 | 
				
			||||||
    MemoryRegion *mr = ddc->get_memory_region(dimm, &error_abort);
 | 
					 | 
				
			||||||
    sPAPRDIMMState *ds = spapr_pending_dimm_unplugs_find(spapr, PC_DIMM(dev));
 | 
					    sPAPRDIMMState *ds = spapr_pending_dimm_unplugs_find(spapr, PC_DIMM(dev));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* This information will get lost if a migration occurs
 | 
					    /* This information will get lost if a migration occurs
 | 
				
			||||||
@ -3308,7 +3311,7 @@ void spapr_lmb_release(DeviceState *dev)
 | 
				
			|||||||
     * Now that all the LMBs have been removed by the guest, call the
 | 
					     * Now that all the LMBs have been removed by the guest, call the
 | 
				
			||||||
     * pc-dimm unplug handler to cleanup up the pc-dimm device.
 | 
					     * pc-dimm unplug handler to cleanup up the pc-dimm device.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    pc_dimm_memory_unplug(dev, &spapr->hotplug_memory, mr);
 | 
					    pc_dimm_memory_unplug(dev, MACHINE(spapr));
 | 
				
			||||||
    object_unparent(OBJECT(dev));
 | 
					    object_unparent(OBJECT(dev));
 | 
				
			||||||
    spapr_pending_dimm_unplugs_remove(spapr, ds);
 | 
					    spapr_pending_dimm_unplugs_remove(spapr, ds);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -4259,13 +4262,13 @@ static void phb_placement_2_7(sPAPRMachineState *spapr, uint32_t index,
 | 
				
			|||||||
    hwaddr phb0_base, phb_base;
 | 
					    hwaddr phb0_base, phb_base;
 | 
				
			||||||
    int i;
 | 
					    int i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Do we have hotpluggable memory? */
 | 
					    /* Do we have device memory? */
 | 
				
			||||||
    if (MACHINE(spapr)->maxram_size > ram_top) {
 | 
					    if (MACHINE(spapr)->maxram_size > ram_top) {
 | 
				
			||||||
        /* Can't just use maxram_size, because there may be an
 | 
					        /* Can't just use maxram_size, because there may be an
 | 
				
			||||||
         * alignment gap between normal and hotpluggable memory
 | 
					         * alignment gap between normal and device memory regions
 | 
				
			||||||
         * regions */
 | 
					         */
 | 
				
			||||||
        ram_top = spapr->hotplug_memory.base +
 | 
					        ram_top = MACHINE(spapr)->device_memory->base +
 | 
				
			||||||
            memory_region_size(&spapr->hotplug_memory.mr);
 | 
					            memory_region_size(&MACHINE(spapr)->device_memory->mr);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    phb0_base = QEMU_ALIGN_UP(ram_top, phb0_alignment);
 | 
					    phb0_base = QEMU_ALIGN_UP(ram_top, phb0_alignment);
 | 
				
			||||||
 | 
				
			|||||||
@ -14,6 +14,7 @@
 | 
				
			|||||||
#include "kvm_ppc.h"
 | 
					#include "kvm_ppc.h"
 | 
				
			||||||
#include "hw/ppc/spapr_ovec.h"
 | 
					#include "hw/ppc/spapr_ovec.h"
 | 
				
			||||||
#include "mmu-book3s-v3.h"
 | 
					#include "mmu-book3s-v3.h"
 | 
				
			||||||
 | 
					#include "hw/mem/memory-device.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct LPCRSyncState {
 | 
					struct LPCRSyncState {
 | 
				
			||||||
    target_ulong value;
 | 
					    target_ulong value;
 | 
				
			||||||
@ -66,13 +67,13 @@ static inline bool valid_ptex(PowerPCCPU *cpu, target_ulong ptex)
 | 
				
			|||||||
static bool is_ram_address(sPAPRMachineState *spapr, hwaddr addr)
 | 
					static bool is_ram_address(sPAPRMachineState *spapr, hwaddr addr)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    MachineState *machine = MACHINE(spapr);
 | 
					    MachineState *machine = MACHINE(spapr);
 | 
				
			||||||
    MemoryHotplugState *hpms = &spapr->hotplug_memory;
 | 
					    DeviceMemoryState *dms = machine->device_memory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (addr < machine->ram_size) {
 | 
					    if (addr < machine->ram_size) {
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if ((addr >= hpms->base)
 | 
					    if ((addr >= dms->base)
 | 
				
			||||||
        && ((addr - hpms->base) < memory_region_size(&hpms->mr))) {
 | 
					        && ((addr - dms->base) < memory_region_size(&dms->mr))) {
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -122,9 +122,8 @@ static void rtas_ibm_query_pe_dma_window(PowerPCCPU *cpu,
 | 
				
			|||||||
    if (machine->ram_size == machine->maxram_size) {
 | 
					    if (machine->ram_size == machine->maxram_size) {
 | 
				
			||||||
        max_window_size = machine->ram_size;
 | 
					        max_window_size = machine->ram_size;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        MemoryHotplugState *hpms = &spapr->hotplug_memory;
 | 
					        max_window_size = machine->device_memory->base +
 | 
				
			||||||
 | 
					                          memory_region_size(&machine->device_memory->mr);
 | 
				
			||||||
        max_window_size = hpms->base + memory_region_size(&hpms->mr);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    avail = SPAPR_PCI_DMA_MAX_WINDOWS - spapr_phb_get_active_win_num(sphb);
 | 
					    avail = SPAPR_PCI_DMA_MAX_WINDOWS - spapr_phb_get_active_win_num(sphb);
 | 
				
			||||||
 | 
				
			|||||||
@ -213,6 +213,17 @@ struct MachineClass {
 | 
				
			|||||||
    int64_t (*get_default_cpu_node_id)(const MachineState *ms, int idx);
 | 
					    int64_t (*get_default_cpu_node_id)(const MachineState *ms, int idx);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * DeviceMemoryState:
 | 
				
			||||||
 | 
					 * @base: address in guest physical address space where the memory
 | 
				
			||||||
 | 
					 * address space for memory devices starts
 | 
				
			||||||
 | 
					 * @mr: address space container for memory devices
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					typedef struct DeviceMemoryState {
 | 
				
			||||||
 | 
					    hwaddr base;
 | 
				
			||||||
 | 
					    MemoryRegion mr;
 | 
				
			||||||
 | 
					} DeviceMemoryState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * MachineState:
 | 
					 * MachineState:
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@ -243,6 +254,7 @@ struct MachineState {
 | 
				
			|||||||
    bool enforce_config_section;
 | 
					    bool enforce_config_section;
 | 
				
			||||||
    bool enable_graphics;
 | 
					    bool enable_graphics;
 | 
				
			||||||
    char *memory_encryption;
 | 
					    char *memory_encryption;
 | 
				
			||||||
 | 
					    DeviceMemoryState *device_memory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ram_addr_t ram_size;
 | 
					    ram_addr_t ram_size;
 | 
				
			||||||
    ram_addr_t maxram_size;
 | 
					    ram_addr_t maxram_size;
 | 
				
			||||||
 | 
				
			|||||||
@ -32,7 +32,6 @@ struct PCMachineState {
 | 
				
			|||||||
    /* <public> */
 | 
					    /* <public> */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* State for other subsystems/APIs: */
 | 
					    /* State for other subsystems/APIs: */
 | 
				
			||||||
    MemoryHotplugState hotplug_memory;
 | 
					 | 
				
			||||||
    Notifier machine_done;
 | 
					    Notifier machine_done;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Pointers to devices and objects: */
 | 
					    /* Pointers to devices and objects: */
 | 
				
			||||||
@ -72,7 +71,7 @@ struct PCMachineState {
 | 
				
			|||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device"
 | 
					#define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device"
 | 
				
			||||||
#define PC_MACHINE_MEMHP_REGION_SIZE "hotplug-memory-region-size"
 | 
					#define PC_MACHINE_DEVMEM_REGION_SIZE "device-memory-region-size"
 | 
				
			||||||
#define PC_MACHINE_MAX_RAM_BELOW_4G "max-ram-below-4g"
 | 
					#define PC_MACHINE_MAX_RAM_BELOW_4G "max-ram-below-4g"
 | 
				
			||||||
#define PC_MACHINE_VMPORT           "vmport"
 | 
					#define PC_MACHINE_VMPORT           "vmport"
 | 
				
			||||||
#define PC_MACHINE_SMM              "smm"
 | 
					#define PC_MACHINE_SMM              "smm"
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										51
									
								
								include/hw/mem/memory-device.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								include/hw/mem/memory-device.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,51 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Memory Device Interface
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Copyright (c) 2018 Red Hat, Inc.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Authors:
 | 
				
			||||||
 | 
					 *  David Hildenbrand <david@redhat.com>
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This work is licensed under the terms of the GNU GPL, version 2 or later.
 | 
				
			||||||
 | 
					 * See the COPYING file in the top-level directory.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef MEMORY_DEVICE_H
 | 
				
			||||||
 | 
					#define MEMORY_DEVICE_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "qom/object.h"
 | 
				
			||||||
 | 
					#include "hw/qdev.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define TYPE_MEMORY_DEVICE "memory-device"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define MEMORY_DEVICE_CLASS(klass) \
 | 
				
			||||||
 | 
					     OBJECT_CLASS_CHECK(MemoryDeviceClass, (klass), TYPE_MEMORY_DEVICE)
 | 
				
			||||||
 | 
					#define MEMORY_DEVICE_GET_CLASS(obj) \
 | 
				
			||||||
 | 
					    OBJECT_GET_CLASS(MemoryDeviceClass, (obj), TYPE_MEMORY_DEVICE)
 | 
				
			||||||
 | 
					#define MEMORY_DEVICE(obj) \
 | 
				
			||||||
 | 
					     INTERFACE_CHECK(MemoryDeviceState, (obj), TYPE_MEMORY_DEVICE)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef struct MemoryDeviceState {
 | 
				
			||||||
 | 
					    Object parent_obj;
 | 
				
			||||||
 | 
					} MemoryDeviceState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef struct MemoryDeviceClass {
 | 
				
			||||||
 | 
					    InterfaceClass parent_class;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    uint64_t (*get_addr)(const MemoryDeviceState *md);
 | 
				
			||||||
 | 
					    uint64_t (*get_plugged_size)(const MemoryDeviceState *md);
 | 
				
			||||||
 | 
					    uint64_t (*get_region_size)(const MemoryDeviceState *md);
 | 
				
			||||||
 | 
					    void (*fill_device_info)(const MemoryDeviceState *md,
 | 
				
			||||||
 | 
					                             MemoryDeviceInfo *info);
 | 
				
			||||||
 | 
					} MemoryDeviceClass;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					MemoryDeviceInfoList *qmp_memory_device_list(void);
 | 
				
			||||||
 | 
					uint64_t get_plugged_memory_size(void);
 | 
				
			||||||
 | 
					uint64_t memory_device_get_free_addr(MachineState *ms, const uint64_t *hint,
 | 
				
			||||||
 | 
					                                     uint64_t align, uint64_t size,
 | 
				
			||||||
 | 
					                                     Error **errp);
 | 
				
			||||||
 | 
					void memory_device_plug_region(MachineState *ms, MemoryRegion *mr,
 | 
				
			||||||
 | 
					                               uint64_t addr);
 | 
				
			||||||
 | 
					void memory_device_unplug_region(MachineState *ms, MemoryRegion *mr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
@ -19,6 +19,7 @@
 | 
				
			|||||||
#include "exec/memory.h"
 | 
					#include "exec/memory.h"
 | 
				
			||||||
#include "sysemu/hostmem.h"
 | 
					#include "sysemu/hostmem.h"
 | 
				
			||||||
#include "hw/qdev.h"
 | 
					#include "hw/qdev.h"
 | 
				
			||||||
 | 
					#include "hw/boards.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define TYPE_PC_DIMM "pc-dimm"
 | 
					#define TYPE_PC_DIMM "pc-dimm"
 | 
				
			||||||
#define PC_DIMM(obj) \
 | 
					#define PC_DIMM(obj) \
 | 
				
			||||||
@ -75,29 +76,9 @@ typedef struct PCDIMMDeviceClass {
 | 
				
			|||||||
    MemoryRegion *(*get_vmstate_memory_region)(PCDIMMDevice *dimm);
 | 
					    MemoryRegion *(*get_vmstate_memory_region)(PCDIMMDevice *dimm);
 | 
				
			||||||
} PCDIMMDeviceClass;
 | 
					} PCDIMMDeviceClass;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * MemoryHotplugState:
 | 
					 | 
				
			||||||
 * @base: address in guest physical address space where hotplug memory
 | 
					 | 
				
			||||||
 * address space begins.
 | 
					 | 
				
			||||||
 * @mr: hotplug memory address space container
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
typedef struct MemoryHotplugState {
 | 
					 | 
				
			||||||
    hwaddr base;
 | 
					 | 
				
			||||||
    MemoryRegion mr;
 | 
					 | 
				
			||||||
} MemoryHotplugState;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
uint64_t pc_dimm_get_free_addr(uint64_t address_space_start,
 | 
					 | 
				
			||||||
                               uint64_t address_space_size,
 | 
					 | 
				
			||||||
                               uint64_t *hint, uint64_t align, uint64_t size,
 | 
					 | 
				
			||||||
                               Error **errp);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int pc_dimm_get_free_slot(const int *hint, int max_slots, Error **errp);
 | 
					int pc_dimm_get_free_slot(const int *hint, int max_slots, Error **errp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
MemoryDeviceInfoList *qmp_pc_dimm_device_list(void);
 | 
					void pc_dimm_memory_plug(DeviceState *dev, MachineState *machine,
 | 
				
			||||||
uint64_t pc_existing_dimms_capacity(Error **errp);
 | 
					                         uint64_t align, Error **errp);
 | 
				
			||||||
uint64_t get_plugged_memory_size(void);
 | 
					void pc_dimm_memory_unplug(DeviceState *dev, MachineState *machine);
 | 
				
			||||||
void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms,
 | 
					 | 
				
			||||||
                         MemoryRegion *mr, uint64_t align, Error **errp);
 | 
					 | 
				
			||||||
void pc_dimm_memory_unplug(DeviceState *dev, MemoryHotplugState *hpms,
 | 
					 | 
				
			||||||
                           MemoryRegion *mr);
 | 
					 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
@ -162,7 +162,6 @@ struct sPAPRMachineState {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    /*< public >*/
 | 
					    /*< public >*/
 | 
				
			||||||
    char *kvm_type;
 | 
					    char *kvm_type;
 | 
				
			||||||
    MemoryHotplugState hotplug_memory;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const char *icp_type;
 | 
					    const char *icp_type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -748,8 +747,8 @@ int spapr_rng_populate_dt(void *fdt);
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
#define SPAPR_MAX_RAM_SLOTS     32
 | 
					#define SPAPR_MAX_RAM_SLOTS     32
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* 1GB alignment for hotplug memory region */
 | 
					/* 1GB alignment for device memory region */
 | 
				
			||||||
#define SPAPR_HOTPLUG_MEM_ALIGN (1ULL << 30)
 | 
					#define SPAPR_DEVICE_MEM_ALIGN (1ULL << 30)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Number of 32 bit words in each LMB list entry in ibm,dynamic-memory
 | 
					 * Number of 32 bit words in each LMB list entry in ibm,dynamic-memory
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										3
									
								
								numa.c
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								numa.c
									
									
									
									
									
								
							@ -36,6 +36,7 @@
 | 
				
			|||||||
#include "hw/boards.h"
 | 
					#include "hw/boards.h"
 | 
				
			||||||
#include "sysemu/hostmem.h"
 | 
					#include "sysemu/hostmem.h"
 | 
				
			||||||
#include "hw/mem/pc-dimm.h"
 | 
					#include "hw/mem/pc-dimm.h"
 | 
				
			||||||
 | 
					#include "hw/mem/memory-device.h"
 | 
				
			||||||
#include "qemu/option.h"
 | 
					#include "qemu/option.h"
 | 
				
			||||||
#include "qemu/config-file.h"
 | 
					#include "qemu/config-file.h"
 | 
				
			||||||
#include "qemu/cutils.h"
 | 
					#include "qemu/cutils.h"
 | 
				
			||||||
@ -521,7 +522,7 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static void numa_stat_memory_devices(NumaNodeMem node_mem[])
 | 
					static void numa_stat_memory_devices(NumaNodeMem node_mem[])
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    MemoryDeviceInfoList *info_list = qmp_pc_dimm_device_list();
 | 
					    MemoryDeviceInfoList *info_list = qmp_memory_device_list();
 | 
				
			||||||
    MemoryDeviceInfoList *info;
 | 
					    MemoryDeviceInfoList *info;
 | 
				
			||||||
    PCDIMMDeviceInfo     *pcdimm_info;
 | 
					    PCDIMMDeviceInfo     *pcdimm_info;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										4
									
								
								qmp.c
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								qmp.c
									
									
									
									
									
								
							@ -39,7 +39,7 @@
 | 
				
			|||||||
#include "qapi/qobject-input-visitor.h"
 | 
					#include "qapi/qobject-input-visitor.h"
 | 
				
			||||||
#include "hw/boards.h"
 | 
					#include "hw/boards.h"
 | 
				
			||||||
#include "qom/object_interfaces.h"
 | 
					#include "qom/object_interfaces.h"
 | 
				
			||||||
#include "hw/mem/pc-dimm.h"
 | 
					#include "hw/mem/memory-device.h"
 | 
				
			||||||
#include "hw/acpi/acpi_dev_interface.h"
 | 
					#include "hw/acpi/acpi_dev_interface.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
NameInfo *qmp_query_name(Error **errp)
 | 
					NameInfo *qmp_query_name(Error **errp)
 | 
				
			||||||
@ -731,7 +731,7 @@ void qmp_object_del(const char *id, Error **errp)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
MemoryDeviceInfoList *qmp_query_memory_devices(Error **errp)
 | 
					MemoryDeviceInfoList *qmp_query_memory_devices(Error **errp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    return qmp_pc_dimm_device_list();
 | 
					    return qmp_memory_device_list();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ACPIOSTInfoList *qmp_query_acpi_ospm_status(Error **errp)
 | 
					ACPIOSTInfoList *qmp_query_acpi_ospm_status(Error **errp)
 | 
				
			||||||
 | 
				
			|||||||
@ -218,9 +218,6 @@ ERROR_WHITELIST = [
 | 
				
			|||||||
    {'exitcode':-6, 'log':r"Object .* is not an instance of type e500-ccsr", 'loglevel':logging.ERROR},
 | 
					    {'exitcode':-6, 'log':r"Object .* is not an instance of type e500-ccsr", 'loglevel':logging.ERROR},
 | 
				
			||||||
    {'exitcode':-6, 'log':r"vmstate_register_with_alias_id: Assertion `!se->compat \|\| se->instance_id == 0' failed", 'loglevel':logging.ERROR},
 | 
					    {'exitcode':-6, 'log':r"vmstate_register_with_alias_id: Assertion `!se->compat \|\| se->instance_id == 0' failed", 'loglevel':logging.ERROR},
 | 
				
			||||||
    {'exitcode':-11, 'device':'isa-serial', 'loglevel':logging.ERROR, 'expected':True},
 | 
					    {'exitcode':-11, 'device':'isa-serial', 'loglevel':logging.ERROR, 'expected':True},
 | 
				
			||||||
    {'exitcode':-11, 'device':'mioe3680_pci', 'loglevel':logging.ERROR, 'expected':True},
 | 
					 | 
				
			||||||
    {'exitcode':-11, 'device':'pcm3680_pci', 'loglevel':logging.ERROR, 'expected':True},
 | 
					 | 
				
			||||||
    {'exitcode':-11, 'device':'kvaser_pci', 'loglevel':logging.ERROR, 'expected':True},
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # everything else (including SIGABRT and SIGSEGV) will be a fatal error:
 | 
					    # everything else (including SIGABRT and SIGSEGV) will be a fatal error:
 | 
				
			||||||
    {'exitcode':None, 'fatal':True, 'loglevel':logging.FATAL},
 | 
					    {'exitcode':None, 'fatal':True, 'loglevel':logging.FATAL},
 | 
				
			||||||
 | 
				
			|||||||
@ -34,7 +34,7 @@ stub-obj-y += uuid.o
 | 
				
			|||||||
stub-obj-y += vm-stop.o
 | 
					stub-obj-y += vm-stop.o
 | 
				
			||||||
stub-obj-y += vmstate.o
 | 
					stub-obj-y += vmstate.o
 | 
				
			||||||
stub-obj-$(CONFIG_WIN32) += fd-register.o
 | 
					stub-obj-$(CONFIG_WIN32) += fd-register.o
 | 
				
			||||||
stub-obj-y += qmp_pc_dimm.o
 | 
					stub-obj-y += qmp_memory_device.o
 | 
				
			||||||
stub-obj-y += target-monitor-defs.o
 | 
					stub-obj-y += target-monitor-defs.o
 | 
				
			||||||
stub-obj-y += target-get-monitor-def.o
 | 
					stub-obj-y += target-get-monitor-def.o
 | 
				
			||||||
stub-obj-y += pc_madt_cpu_entry.o
 | 
					stub-obj-y += pc_madt_cpu_entry.o
 | 
				
			||||||
 | 
				
			|||||||
@ -1,8 +1,8 @@
 | 
				
			|||||||
#include "qemu/osdep.h"
 | 
					#include "qemu/osdep.h"
 | 
				
			||||||
#include "qom/object.h"
 | 
					#include "qom/object.h"
 | 
				
			||||||
#include "hw/mem/pc-dimm.h"
 | 
					#include "hw/mem/memory-device.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
MemoryDeviceInfoList *qmp_pc_dimm_device_list(void)
 | 
					MemoryDeviceInfoList *qmp_memory_device_list(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
   return NULL;
 | 
					   return NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
							
								
								
									
										19
									
								
								vl.c
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								vl.c
									
									
									
									
									
								
							@ -2868,7 +2868,6 @@ static void set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size,
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    uint64_t sz;
 | 
					    uint64_t sz;
 | 
				
			||||||
    const char *mem_str;
 | 
					    const char *mem_str;
 | 
				
			||||||
    const char *maxmem_str, *slots_str;
 | 
					 | 
				
			||||||
    const ram_addr_t default_ram_size = mc->default_ram_size;
 | 
					    const ram_addr_t default_ram_size = mc->default_ram_size;
 | 
				
			||||||
    QemuOpts *opts = qemu_find_opts_singleton("memory");
 | 
					    QemuOpts *opts = qemu_find_opts_singleton("memory");
 | 
				
			||||||
    Location loc;
 | 
					    Location loc;
 | 
				
			||||||
@ -2914,9 +2913,7 @@ static void set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size,
 | 
				
			|||||||
    qemu_opt_set_number(opts, "size", ram_size, &error_abort);
 | 
					    qemu_opt_set_number(opts, "size", ram_size, &error_abort);
 | 
				
			||||||
    *maxram_size = ram_size;
 | 
					    *maxram_size = ram_size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    maxmem_str = qemu_opt_get(opts, "maxmem");
 | 
					    if (qemu_opt_get(opts, "maxmem")) {
 | 
				
			||||||
    slots_str = qemu_opt_get(opts, "slots");
 | 
					 | 
				
			||||||
    if (maxmem_str && slots_str) {
 | 
					 | 
				
			||||||
        uint64_t slots;
 | 
					        uint64_t slots;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        sz = qemu_opt_get_size(opts, "maxmem", 0);
 | 
					        sz = qemu_opt_get_size(opts, "maxmem", 0);
 | 
				
			||||||
@ -2927,13 +2924,7 @@ static void set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size,
 | 
				
			|||||||
                         "the initial memory size (0x" RAM_ADDR_FMT ")",
 | 
					                         "the initial memory size (0x" RAM_ADDR_FMT ")",
 | 
				
			||||||
                         sz, ram_size);
 | 
					                         sz, ram_size);
 | 
				
			||||||
            exit(EXIT_FAILURE);
 | 
					            exit(EXIT_FAILURE);
 | 
				
			||||||
        } else if (sz > ram_size) {
 | 
					        } else if (slots && sz == ram_size) {
 | 
				
			||||||
            if (!slots) {
 | 
					 | 
				
			||||||
                error_report("invalid value of -m option: maxmem was "
 | 
					 | 
				
			||||||
                             "specified, but no hotplug slots were specified");
 | 
					 | 
				
			||||||
                exit(EXIT_FAILURE);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        } else if (slots) {
 | 
					 | 
				
			||||||
            error_report("invalid value of -m option maxmem: "
 | 
					            error_report("invalid value of -m option maxmem: "
 | 
				
			||||||
                         "memory slots were specified but maximum memory size "
 | 
					                         "memory slots were specified but maximum memory size "
 | 
				
			||||||
                         "(0x%" PRIx64 ") is equal to the initial memory size "
 | 
					                         "(0x%" PRIx64 ") is equal to the initial memory size "
 | 
				
			||||||
@ -2943,10 +2934,8 @@ static void set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        *maxram_size = sz;
 | 
					        *maxram_size = sz;
 | 
				
			||||||
        *ram_slots = slots;
 | 
					        *ram_slots = slots;
 | 
				
			||||||
    } else if ((!maxmem_str && slots_str) ||
 | 
					    } else if (qemu_opt_get(opts, "slots")) {
 | 
				
			||||||
            (maxmem_str && !slots_str)) {
 | 
					        error_report("invalid -m option value: missing 'maxmem' option");
 | 
				
			||||||
        error_report("invalid -m option value: missing "
 | 
					 | 
				
			||||||
                "'%s' option", slots_str ? "maxmem" : "slots");
 | 
					 | 
				
			||||||
        exit(EXIT_FAILURE);
 | 
					        exit(EXIT_FAILURE);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user