@@ -87,7 +87,15 @@ static void nvdimm_realize(PCDIMMDevice *dimm, Error **errp)
align = memory_region_get_alignment(mr);
pmem_size = size - nvdimm->label_size;
- nvdimm->label_data = memory_region_get_ram_ptr(mr) + pmem_size;
+ /*
+ * The memory region of vNVDIMM on Xen is not a RAM memory region,
+ * so memory_region_get_ram_ptr() below will abort QEMU. In
+ * addition that Xen currently does not support vNVDIMM labels
+ * (i.e. label_size is zero here), let's not initialize of the
+ * pointer to label data if the label size is zero.
+ */
+ if (nvdimm->label_size)
+ nvdimm->label_data = memory_region_get_ram_ptr(mr) + pmem_size;
pmem_size = QEMU_ALIGN_DOWN(pmem_size, align);
if (size <= nvdimm->label_size || !pmem_size) {
The memory region of vNVDIMM on Xen is a RAM memory region, so memory_region_get_ram_ptr() cannot be used in nvdimm_realize() to get a pointer to the label data area in that region. To be worse, it may abort QEMU. As Xen currently does not support labels (i.e. label size is 0) and every access in QEMU to labels is led by a label size check, let's not intiailize nvdimm->label_data if the label size is 0. Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com> --- Cc: Xiao Guangrong <xiaoguangrong.eric@gmail.com> Cc: "Michael S. Tsirkin" <mst@redhat.com> Cc: Igor Mammedov <imammedo@redhat.com> --- hw/mem/nvdimm.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)