aboutsummaryrefslogtreecommitdiff
path: root/hw/mem
AgeCommit message (Collapse)AuthorFilesLines
2019-12-18memory-device: Fix memory pre-plug error API violationsMarkus Armbruster1-2/+4
memory_device_get_free_addr() dereferences @errp when memory_device_check_addable() fails. That's wrong; see the big comment in error.h. Introduced in commit 1b6d6af21b "pc-dimm: factor out capacity and slot checks into MemoryDevice". No caller actually passes null. Fix anyway: splice in a local Error *err, and error_propagate(). Cc: David Hildenbrand <david@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: David Hildenbrand <david@redhat.com> Message-Id: <20191204093625.14836-11-armbru@redhat.com>
2019-10-22memory-device: simplify Makefile.objs conditionsPaolo Bonzini1-1/+1
hw/mem/ is only included if CONFIG_MEM_DEVICE is true, so we need not specify the condition again in hw/mem/Makefile.objs. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-10-15memory-device: break the loop if tmp exceed the hinted rangeWei Yang1-0/+2
The memory-device list built by memory_device_build_list is ordered by its address, this means if the tmp range exceed the hinted range, all the following range will not overlap with it. And this won't change default pc-dimm mapping and address assignment stay the same as before this change. Signed-off-by: Wei Yang <richardw.yang@linux.intel.com> Message-Id: <20190730003740.20694-3-richardw.yang@linux.intel.com> Reviewed-by: David Hildenbrand <david@redhat.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2019-10-15memory-device: not necessary to use goto for the last checkWei Yang1-1/+0
We are already at the last condition check. Signed-off-by: Wei Yang <richardw.yang@linux.intel.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: David Hildenbrand <david@redhat.com> Message-Id: <20190730003740.20694-2-richardw.yang@linux.intel.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2019-09-03numa: move numa global variable nb_numa_nodes into MachineStateTao Xu1-0/+2
Add struct NumaState in MachineState and move existing numa global nb_numa_nodes(renamed as "num_nodes") into NumaState. And add variable numa_support into MachineClass to decide which submachines support NUMA. Reviewed-by: Igor Mammedov <imammedo@redhat.com> Suggested-by: Igor Mammedov <imammedo@redhat.com> Suggested-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Tao Xu <tao3.xu@intel.com> Message-Id: <20190809065731.9097-3-tao3.xu@intel.com> [ehabkost: include hw/boards.h again to fix build failures] Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2019-08-16numa: Move remaining NUMA declarations from sysemu.h to numa.hMarkus Armbruster1-0/+1
Commit e35704ba9c "numa: Move NUMA declarations from sysemu.h to numa.h" left a few NUMA-related macros behind. Move them now. Cc: Eduardo Habkost <ehabkost@redhat.com> Cc: Marcel Apfelbaum <marcel.apfelbaum@gmail.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20190812052359.30071-26-armbru@redhat.com>
2019-08-16Include sysemu/hostmem.h lessMarkus Armbruster1-0/+1
Move the HostMemoryBackend typedef from sysemu/hostmem.h to qemu/typedefs.h. This renders a few inclusions of sysemu/hostmem.h superfluous; drop them. Cc: Eduardo Habkost <ehabkost@redhat.com> Cc: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20190812052359.30071-25-armbru@redhat.com>
2019-08-16numa: Don't include hw/boards.h into sysemu/numa.hMarkus Armbruster1-0/+1
sysemu/numa.h includes hw/boards.h just for the CPUArchId typedef, at the cost of pulling in more than two dozen extra headers indirectly. I could move the typedef from hw/boards.h to qemu/typedefs.h. But it's used in just two headers: boards.h and numa.h. I could move it to another header both its users include. exec/cpu-common.h seems to be the least bad fit. But I'm keeping this simple & stupid: declare the struct tag in numa.h. Cc: Eduardo Habkost <ehabkost@redhat.com> Cc: Marcel Apfelbaum <marcel.apfelbaum@gmail.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20190812052359.30071-24-armbru@redhat.com>
2019-08-16Include hw/qdev-properties.h lessMarkus Armbruster3-1/+2
In my "build everything" tree, changing hw/qdev-properties.h triggers a recompile of some 2700 out of 6600 objects (not counting tests and objects that don't depend on qemu/osdep.h). Many places including hw/qdev-properties.h (directly or via hw/qdev.h) actually need only hw/qdev-core.h. Include hw/qdev-core.h there instead. hw/qdev.h is actually pointless: all it does is include hw/qdev-core.h and hw/qdev-properties.h, which in turn includes hw/qdev-core.h. Replace the remaining uses of hw/qdev.h by hw/qdev-properties.h. While there, delete a few superfluous inclusions of hw/qdev-core.h. Touching hw/qdev-properties.h now recompiles some 1200 objects. Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: "Daniel P. Berrangé" <berrange@redhat.com> Cc: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20190812052359.30071-22-armbru@redhat.com>
2019-08-16Include migration/vmstate.h lessMarkus Armbruster1-0/+1
In my "build everything" tree, changing migration/vmstate.h triggers a recompile of some 2700 out of 6600 objects (not counting tests and objects that don't depend on qemu/osdep.h). hw/hw.h supposedly includes it for convenience. Several other headers include it just to get VMStateDescription. The previous commit made that unnecessary. Include migration/vmstate.h only where it's still needed. Touching it now recompiles only some 1600 objects. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-Id: <20190812052359.30071-16-armbru@redhat.com> Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
2019-07-29pc-dimm: fix crash when invalid slot number is usedIgor Mammedov1-0/+7
QEMU will crash with: Segmentation fault (core dumped) when negative slot number is used, ex: qemu-system-x86_64 -m 1G,maxmem=20G,slots=256 \ -object memory-backend-ram,id=mem1,size=1G \ -device pc-dimm,id=dimm1,memdev=mem1,slot=-2 fix it by checking that slot number is within valid range. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Message-Id: <20190723160859.27250-1-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Li Qiang <liq3ea@gmail.com> Signed-off-by: Igor Mammedov &lt;<a href="mailto:imammedo@redhat.com" target="_blank">imammedo@redhat.com</a>&gt;<br></blockquote><div><br></div><div>Reviewed-by: Li Qiang &lt;<a href="mailto:liq3ea@gmail.com">liq3ea@gmail.com</a>&gt;<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> Reviewed-by: Pankaj Gupta <pagupta@redhat.com>
2019-06-12Include qemu/module.h where needed, drop it from qemu-common.hMarkus Armbruster2-0/+2
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20190523143508.25387-4-armbru@redhat.com> [Rebased with conflicts resolved automatically, except for hw/usb/dev-hub.c hw/misc/exynos4210_rng.c hw/misc/bcm2835_rng.c hw/misc/aspeed_scu.c hw/display/virtio-vga.c hw/arm/stm32f205_soc.c; ui/cocoa.m fixed up]
2019-03-22trace-events: Shorten file names in commentsMarkus Armbruster1-2/+2
We spell out sub/dir/ in sub/dir/trace-events' comments pointing to source files. That's because when trace-events got split up, the comments were moved verbatim. Delete the sub/dir/ part from these comments. Gets rid of several misspellings. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-id: 20190314180929.27722-3-armbru@redhat.com Message-Id: <20190314180929.27722-3-armbru@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2019-03-07ppc64: Express dependencies of 'pseries' and 'powernv' machines with kconfigThomas Huth1-0/+1
The POWERNV switch should always select ISA_IPMI_BT, then the other IPMI options are turned on automatically now. CONFIG_DIMM should always be selected by the pseries machine, which in turn depends on CONFIG_MEM_DEVICE since DIMM implements this interface. CONFIG_VIRTIO_VGA can be dropped from default-configs/ppc64-softmmu.mak completely since this device is already automatically enabled via hw/display/Kconfig now. Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07i386-softmmu.mak: remove all CONFIG_* except boards definitionsYang Zhong1-0/+2
%-softmmu.mak only keep boards definitions in Kconfig mode. Signed-off-by: Yang Zhong <yang.zhong@intel.com> Message-Id: <20190123065618.3520-43-yang.zhong@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07kconfig: introduce kconfig filesPaolo Bonzini1-0/+8
The Kconfig files were generated mostly with this script: for i in `grep -ho CONFIG_[A-Z0-9_]* default-configs/* | sort -u`; do set fnord `git grep -lw $i -- 'hw/*/Makefile.objs' ` shift if test $# = 1; then cat >> $(dirname $1)/Kconfig << EOF config ${i#CONFIG_} bool EOF git add $(dirname $1)/Kconfig else echo $i $* fi done sed -i '$d' hw/*/Kconfig for i in hw/*; do if test -d $i && ! test -f $i/Kconfig; then touch $i/Kconfig git add $i/Kconfig fi done Whenever a symbol is referenced from multiple subdirectories, the script prints the list of directories that reference the symbol. These symbols have to be added manually to the Kconfig files. Kconfig.host and hw/Kconfig were created manually. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Yang Zhong <yang.zhong@intel.com> Message-Id: <20190123065618.3520-27-yang.zhong@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-02-21pc-dimm: use same mechanism for [get|set]_addrWei Yang1-3/+1
[get|set]_addr are two counterpart to access PCDIMMDevice.addr. Since we have already set up a property PC_DIMM_ADDR_PROP for this field and use this mechanism in set_addr, it would be more proper to use the same mechanism in get_addr. This patch uses object_property_get_uint() to replace the direct memory access to make [get|set]_addr with the same mechanism. Signed-off-by: Wei Yang <richardw.yang@linux.intel.com> Message-Id: <20190211064629.20186-1-richardw.yang@linux.intel.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2019-01-09memory-device: rewrite address assignment using rangesDavid Hildenbrand1-25/+26
Let's rewrite it properly using ranges. This fixes certain overflows that are right now possible. E.g. qemu-system-x86_64 -m 4G,slots=20,maxmem=40G -M pc \ -object memory-backend-file,id=mem1,share,mem-path=/dev/zero,size=2G -device pc-dimm,memdev=mem1,id=dimm1,addr=-0x40000000 Now properly errors out instead of succeeding. (Note that qapi parsing of huge uint64_t values is broken and fixes are on the way) "can't add memory device [0xffffffffa0000000:0x80000000], usable range for memory devices [0x140000000:0xe00000000]" Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20181214131043.25071-3-david@redhat.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2018-12-11memory-device: avoid overflows on very huge devicesDavid Hildenbrand1-1/+2
Should not be a problem right now, but it could theoretically happen in the future. Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20181023152306.3123-7-david@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2018-12-11memory-device: use QEMU_IS_ALIGNEDDavid Hildenbrand1-3/+3
Shorter and easier to read. Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20181023152306.3123-6-david@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2018-11-06nvdimm: set non-volatile on the memory regionMarc-André Lureau1-0/+1
qemu-system-x86_64 -machine pc,nvdimm -m 2G,slots=4,maxmem=16G -enable-kvm -monitor stdio -object memory-backend-file,id=mem1,share=on,mem-path=/tmp/foo,size=1G -device nvdimm,id=nvdimm1,memdev=mem1 HMP info mtree command reflects the flag with "nv-" prefix on memory type: (qemu) info mtree 0000000100000000-000000013fffffff (prio 0, nv-i/o): alias nvdimm-memory @/objects/mem1 0000000000000000-000000003fffffff (qemu) info mtree -f 0000000100000000-000000013fffffff (prio 0, nv-ram): /objects/mem1 Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20181003114454.5662-3-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2018-10-24memory-device: trace when pre_plugging/plugging/unpluggingDavid Hildenbrand3-9/+12
Let's trace the address and the id of a memory device when pre_plugging/plugging/unplugging succeeded. Trace it when pre_plugging as well as when plugging, so we really know when a specific address is actually used. Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20181005092024.14344-17-david@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2018-10-24memory-device: complete factoring out unplug handlingDavid Hildenbrand2-6/+10
With the new memory device functions in place, we can factor out unplugging of memory devices completely. Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Eric Auger <eric.auger@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20181005092024.14344-16-david@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2018-10-24memory-device: complete factoring out plug handlingDavid Hildenbrand2-11/+11
With the new memory device functions in place, we can factor out plugging of memory devices completely. Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Eric Auger <eric.auger@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20181005092024.14344-15-david@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2018-10-24memory-device: complete factoring out pre_plug handlingDavid Hildenbrand2-15/+32
With all required memory device class functions in place, we can factor out pre_plug handling of memory devices. Take proper care of errors. We still have to carry along legacy_align required for pc compatibility handling. We will factor out tracing of the address separately in a follow-up patch. Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20181005092024.14344-14-david@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2018-10-24memory-device: add device class function set_addr()David Hildenbrand1-0/+7
To be able to factor out address assignment of memory devices, we will have to read (get_addr()) and write (set_addr()) the address. We can't use properties for this purpose, as properties are device specific. E.g. while the address property for a DIMM is called "addr", it might be called differently (e.g. "memaddr") for other devices. Especially virtio based memory devices cannot use "addr" as that is already reserved and used for the address on the bus (for the proxy device). Also, it might be possible to have memory devices without address properties (e.g. internal DIMM-like thingies). In contrast to get_addr(), we expect that set_addr() can fail. Keep it simple for now for pc-dimm and simply set the static property, that will fail once realized. Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Eric Auger <eric.auger@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20181005092024.14344-13-david@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2018-10-24memory-device: drop get_region_size()David Hildenbrand2-19/+10
There are no remaining users of get_region_size() except memory_device_get_region_size() itself. We can make memory_device_get_region_size() work directly on get_memory_region() instead and drop get_region_size(). In addition, we can now use memory_device_get_region_size() in pc-dimm code to implement get_plugged_size()" Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20181005092024.14344-12-david@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2018-10-24memory-device: factor out get_memory_region() from pc-dimmDavid Hildenbrand2-12/+24
The memory region is necessary for plugging/unplugging a memory device. The region size (via get_region_size()) is no longer sufficient, as besides the alignment, also the region itself is required in order to add it to the device memory region of the machine via - memory_region_add_subregion - memory_region_del_subregion So, to factor out plugging/unplugging of memory devices from pc-dimm code, we have to factor out access to the memory region first. Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20181005092024.14344-11-david@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2018-10-24memory-device: add and use memory_device_get_region_size()David Hildenbrand2-9/+14
We will factor out get_memory_region() from pc-dimm to memory device code soon. Once that is done, get_region_size() can be implemented generically and essentially be replaced by memory_device_get_region_size (and work only on get_memory_region()). We have some users of get_memory_region() (spapr and pc-dimm code) that are only interested in the size. So let's rework them to use memory_device_get_region_size() first, then we can factor out get_memory_region() and eventually remove get_region_size() without touching the same code multiple times. Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20181005092024.14344-10-david@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2018-10-24memory-device: forward errors in get_region_size()/get_plugged_size()David Hildenbrand2-8/+6
Let's properly forward the errors, so errors from get_region_size() / get_plugged_size() can be handled. Users right now call both functions after the device has been realized, which is will never fail, so it is fine to continue using error_abort. While at it, remove a leftover error check (suggested by Igor). Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Eric Auger <eric.auger@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20181005092024.14344-8-david@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2018-10-24memory-device: introduce separate config optionDavid Hildenbrand1-2/+2
Some architectures might support memory devices, while they don't support DIMM/NVDIMM. So let's - Rename CONFIG_MEM_HOTPLUG to CONFIG_MEM_DEVICE - Introduce CONFIG_DIMM and use it similarly to CONFIG NVDIMM CONFIG_DIMM and CONFIG_NVDIMM require CONFIG_MEM_DEVICE. Reviewed-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Acked-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20181005092024.14344-7-david@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2018-10-24memory-device: use memory device terminology in error messagesDavid Hildenbrand1-3/+3
While we rephrased most error messages, we missed these. Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20181005092024.14344-6-david@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2018-10-24pc-dimm: pass PCDIMMDevice to pc_dimm_.*plugDavid Hildenbrand1-13/+11
We're plugging/unplugging a PCDIMMDevice, so directly pass this type instead of a more generic DeviceState. Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Acked-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Eric Auger <eric.auger@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20181005092024.14344-5-david@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2018-10-24memory-device: improve "range conflicts" error messageDavid Hildenbrand1-1/+2
Handle id==NULL better and indicate that we are dealing with memory devices. Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20181005092024.14344-4-david@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2018-10-24memory-device: fix error message when hinted address is too smallDavid Hildenbrand1-1/+2
The "at" should actually be a "before". if (new_addr < address_space_start) -> "can't add memory ... before... $address_space_start" So it looks similar to the other check } else if ((new_addr + size) > address_space_end) -> "can't add memory ... beyond..." Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20181005092024.14344-3-david@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2018-10-24memory-device: fix alignment error messageDavid Hildenbrand1-1/+1
We're missing "x" after the leading 0. Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20181005092024.14344-2-david@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2018-08-23pc-dimm: assign and verify the "addr" property during pre_plugDavid Hildenbrand1-24/+26
We can assign and verify the address before realizing and trying to plug. reading/writing the address property should never fail for DIMMs, so let's reduce error handling a bit by using &error_abort. Getting access to the memory region now might however fail. So forward errors from get_memory_region() properly. As all memory devices should use the alignment of the underlying memory region for guest physical address asignment, do detection of the alignment in pc_dimm_pre_plug(), but allow pc.c to overwrite the alignment for compatibility handling. Reviewed-by: Eric Auger <eric.auger@redhat.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Acked-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20180801133444.11269-5-david@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2018-08-23pc-dimm: assign and verify the "slot" property during pre_plugDavid Hildenbrand1-17/+18
We can assign and verify the slot before realizing and trying to plug. reading/writing the slot property should never fail, so let's reduce error handling a bit by using &error_abort. To do this during pre_plug, add and use (x86, ppc) pc_dimm_pre_plug(). Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Eric Auger <eric.auger@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20180801133444.11269-2-david@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2018-08-10mem/nvdimm: ensure write persistence to PMEM in label emulationJunyan He1-1/+8
Guest writes to vNVDIMM labels are intercepted and performed on the backend by QEMU. When the backend is a real persistent memort, QEMU needs to take proper operations to ensure its write persistence on the persistent memory. Otherwise, a host power failure may result in the loss of guest label configurations. Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
2018-06-28pc-dimm: get_memory_region() will not fail after realizeDavid Hildenbrand1-6/+1
Let's try to reduce error handling a bit. In the plug/unplug case, the device was realized and therefore we can assume that getting access to the memory region will not fail. For get_vmstate_memory_region() this is already handled that way. Document both cases. Reviewed-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20180619134141.29478-13-david@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2018-06-28nvdimm: make get_memory_region() perform checks and initializationDavid Hildenbrand1-9/+35
We might get a call to get_memory_region() before the device has been realized. We should return a consistent value, as the return value will e.g. later on be used in the pre_plug handler. To avoid duplicating too much code, factor the initialization and checks out into a helper function. Reviewed-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20180619134141.29478-12-david@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2018-06-28nvdimm: convert nvdimm_mr into a pointerDavid Hildenbrand1-4/+13
This way we can easily check if the region has already been inititalized without having to rely on the size of an uninitialized region being 0. Free the region in nvdimm_finalize() and not in unrealize() as we will allow to create the region before realization in following patches. Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20180619134141.29478-11-david@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2018-06-28nvdimm: convert "unarmed" into a static propertyDavid Hildenbrand1-25/+7
We don't allow to modify it after realization. So we can simply turn it into a static property. Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20180619134141.29478-10-david@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2018-06-28pc-dimm: merge get_(vmstate_)memory_region()David Hildenbrand1-8/+5
Importantly, get_vmstate_memory_region() should also fail with a proper error if called before the device is realized. For a PCDIMM, both functions are to return the same thing, so share the implementation. All current users are called after the device has been realized, so we can expect the calls to succeed. Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20180619134141.29478-9-david@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2018-06-28hostmem: drop error variable from host_memory_backend_get_memory()David Hildenbrand2-4/+4
Unused, so let's remove it. Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20180619134141.29478-8-david@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2018-06-28nvdimm: no need to overwrite get_vmstate_memory_region()David Hildenbrand1-6/+0
Our parent class (PC_DIMM) provides exactly the same function. Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20180619134141.29478-7-david@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2018-06-28pc-dimm: remove pc_dimm_get_free_slot() from headerDavid Hildenbrand1-1/+3
Not used outside of pc-dimm.c and there shouldn't be other users. If other devices (e.g. memory devices) ever have to also use slots, then we will have to factor this out. Reviewed-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20180619134141.29478-5-david@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2018-06-28pc-dimm: rename pc_dimm_memory_* to pc_dimm_*David Hildenbrand1-3/+3
Let's rename it to make it look more consistent. Reviewed-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20180619134141.29478-4-david@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2018-06-28pc-dimm: remove leftover "struct pc_dimms_capacity"David Hildenbrand1-5/+0
Not needed anymore, let's drop it. Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20180619134141.29478-2-david@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2018-06-28memory-device: turn alignment assert into checkDavid Hildenbrand1-1/+7
The start of the address space indicates which maximum alignment is supported by our machine (e.g. ppc, x86 1GB). This is helpful to catch fragmenting guest physical memory in strange fashions. Right now we can crash QEMU by e.g. (there might be easier examples) qemu-system-x86_64 -m 256M,maxmem=20G,slots=2 \ -object memory-backend-file,id=mem0,size=8192M,mem-path=/dev/zero,align=8192M \ -device pc-dimm,id=dimm1,memdev=mem0 Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20180607154705.6316-2-david@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>