diff mbox

[v7,20/35] dimm: get mapped memory region from DIMMDeviceClass->get_memory_region

Message ID 1446455617-129562-21-git-send-email-guangrong.xiao@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Xiao Guangrong Nov. 2, 2015, 9:13 a.m. UTC
Curretly, the memory region of backed memory is directly mapped to
guest's address space, however, it is not true for nvdimm device

This patch let dimm device realize this fact and use
DIMMDeviceClass->get_memory_region method to get the mapped memory
region

Current code did not check the return value of get_memory_region as it
assumed the backend memory of pc-dimm is always properly initialized,
we make get_memory_region internally catch the case if something is
wrong

Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
---
 hw/mem/dimm.c    |  3 ++-
 hw/mem/pc-dimm.c | 12 +++++++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)

Comments

Vladimir Sementsov-Ogievskiy Nov. 2, 2015, 12:19 p.m. UTC | #1
On 02.11.2015 12:13, Xiao Guangrong wrote:
> Curretly, the memory region of backed memory is directly mapped to
> guest's address space, however, it is not true for nvdimm device
>
> This patch let dimm device realize this fact and use
> DIMMDeviceClass->get_memory_region method to get the mapped memory
> region
>
> Current code did not check the return value of get_memory_region as it
> assumed the backend memory of pc-dimm is always properly initialized,
> we make get_memory_region internally catch the case if something is
> wrong
>
> Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
> ---
>   hw/mem/dimm.c    |  3 ++-
>   hw/mem/pc-dimm.c | 12 +++++++++++-
>   2 files changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/hw/mem/dimm.c b/hw/mem/dimm.c
> index 4a63409..498d380 100644
> --- a/hw/mem/dimm.c
> +++ b/hw/mem/dimm.c
> @@ -377,8 +377,9 @@ static void dimm_get_size(Object *obj, Visitor *v, void *opaque,
>       int64_t value;
>       MemoryRegion *mr;
>       DIMMDevice *dimm = DIMM(obj);
> +    DIMMDeviceClass *ddc = DIMM_GET_CLASS(obj);
>   
> -    mr = host_memory_backend_get_memory(dimm->hostmem, errp);
> +    mr = ddc->get_memory_region(dimm);
>       value = memory_region_size(mr);
>   
>       visit_type_int(v, &value, name, errp);
> diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
> index 38323e9..e6b6a9f 100644
> --- a/hw/mem/pc-dimm.c
> +++ b/hw/mem/pc-dimm.c
> @@ -22,7 +22,17 @@
>   
>   static MemoryRegion *pc_dimm_get_memory_region(DIMMDevice *dimm)
>   {
> -    return host_memory_backend_get_memory(dimm->hostmem, &error_abort);
> +    Error *local_err = NULL;
> +    MemoryRegion *mr;
> +
> +    mr = host_memory_backend_get_memory(dimm->hostmem, &local_err);
> +
> +    /*
> +     * plug a pc-dimm device whose backend memory was not properly
> +     * initialized?
> +     */
> +    assert(!local_err && mr);
> +    return mr;
>   }

this should squashed into previous patch, I think

>   
>   static void pc_dimm_class_init(ObjectClass *oc, void *data)

I've discovered suddenly, that

MemoryRegion *
host_memory_backend_get_memory(HostMemoryBackend *backend, Error **errp)
{
     return memory_region_size(&backend->mr) ? &backend->mr : NULL;
}

- it doesn't use errp at all. In my opinion, this should be fixed 
globally, by deleting useless parameter in separate patch. Or just 
squash your function into previous patch.
Xiao Guangrong Nov. 2, 2015, 1:08 p.m. UTC | #2
On 11/02/2015 08:19 PM, Vladimir Sementsov-Ogievskiy wrote:
> On 02.11.2015 12:13, Xiao Guangrong wrote:
>> Curretly, the memory region of backed memory is directly mapped to
>> guest's address space, however, it is not true for nvdimm device
>>
>> This patch let dimm device realize this fact and use
>> DIMMDeviceClass->get_memory_region method to get the mapped memory
>> region
>>
>> Current code did not check the return value of get_memory_region as it
>> assumed the backend memory of pc-dimm is always properly initialized,
>> we make get_memory_region internally catch the case if something is
>> wrong
>>
>> Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
>> ---
>>   hw/mem/dimm.c    |  3 ++-
>>   hw/mem/pc-dimm.c | 12 +++++++++++-
>>   2 files changed, 13 insertions(+), 2 deletions(-)
>>
>> diff --git a/hw/mem/dimm.c b/hw/mem/dimm.c
>> index 4a63409..498d380 100644
>> --- a/hw/mem/dimm.c
>> +++ b/hw/mem/dimm.c
>> @@ -377,8 +377,9 @@ static void dimm_get_size(Object *obj, Visitor *v, void *opaque,
>>       int64_t value;
>>       MemoryRegion *mr;
>>       DIMMDevice *dimm = DIMM(obj);
>> +    DIMMDeviceClass *ddc = DIMM_GET_CLASS(obj);
>> -    mr = host_memory_backend_get_memory(dimm->hostmem, errp);
>> +    mr = ddc->get_memory_region(dimm);
>>       value = memory_region_size(mr);
>>       visit_type_int(v, &value, name, errp);
>> diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
>> index 38323e9..e6b6a9f 100644
>> --- a/hw/mem/pc-dimm.c
>> +++ b/hw/mem/pc-dimm.c
>> @@ -22,7 +22,17 @@
>>   static MemoryRegion *pc_dimm_get_memory_region(DIMMDevice *dimm)
>>   {
>> -    return host_memory_backend_get_memory(dimm->hostmem, &error_abort);
>> +    Error *local_err = NULL;
>> +    MemoryRegion *mr;
>> +
>> +    mr = host_memory_backend_get_memory(dimm->hostmem, &local_err);
>> +
>> +    /*
>> +     * plug a pc-dimm device whose backend memory was not properly
>> +     * initialized?
>> +     */
>> +    assert(!local_err && mr);
>> +    return mr;
>>   }
>
> this should squashed into previous patch, I think

You mean merger this patch with 19/35 (dimm: abstract dimm device from pc-dimm)?
The 19/35 mostly ‘moves’ the things, this one changes the core logic, it is not
a big deal. :D

>
>>   static void pc_dimm_class_init(ObjectClass *oc, void *data)
>
> I've discovered suddenly, that
>
> MemoryRegion *
> host_memory_backend_get_memory(HostMemoryBackend *backend, Error **errp)
> {
>      return memory_region_size(&backend->mr) ? &backend->mr : NULL;
> }
>
> - it doesn't use errp at all. In my opinion, this should be fixed globally, by deleting useless
> parameter in separate patch. Or just squash your function into previous patch.
>

Yup, this is a globally interface so i prefer to make a separate patch to do the
cleanup after this patchset.


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Vladimir Sementsov-Ogievskiy Nov. 2, 2015, 2:26 p.m. UTC | #3
On 02.11.2015 16:08, Xiao Guangrong wrote:
>
>
> On 11/02/2015 08:19 PM, Vladimir Sementsov-Ogievskiy wrote:
>> On 02.11.2015 12:13, Xiao Guangrong wrote:
>>> Curretly, the memory region of backed memory is directly mapped to
>>> guest's address space, however, it is not true for nvdimm device
>>>
>>> This patch let dimm device realize this fact and use
>>> DIMMDeviceClass->get_memory_region method to get the mapped memory
>>> region
>>>
>>> Current code did not check the return value of get_memory_region as it
>>> assumed the backend memory of pc-dimm is always properly initialized,
>>> we make get_memory_region internally catch the case if something is
>>> wrong

but here you call not pc-dimm's get_memory_region, but common 
ddc->get_memory_region, which may be nvdimm or possibly other future 
dimm, so, why not check it here? And than pc_dimm_get_memory_region may 
be left untouched (error_abort is ok, because errp is unused).

>>>
>>> Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
>>> ---
>>>   hw/mem/dimm.c    |  3 ++-
>>>   hw/mem/pc-dimm.c | 12 +++++++++++-
>>>   2 files changed, 13 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/hw/mem/dimm.c b/hw/mem/dimm.c
>>> index 4a63409..498d380 100644
>>> --- a/hw/mem/dimm.c
>>> +++ b/hw/mem/dimm.c
>>> @@ -377,8 +377,9 @@ static void dimm_get_size(Object *obj, Visitor 
>>> *v, void *opaque,
>>>       int64_t value;
>>>       MemoryRegion *mr;
>>>       DIMMDevice *dimm = DIMM(obj);
>>> +    DIMMDeviceClass *ddc = DIMM_GET_CLASS(obj);
>>> -    mr = host_memory_backend_get_memory(dimm->hostmem, errp);
>>> +    mr = ddc->get_memory_region(dimm);
>>>       value = memory_region_size(mr);
>>>       visit_type_int(v, &value, name, errp);
>>> diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
>>> index 38323e9..e6b6a9f 100644
>>> --- a/hw/mem/pc-dimm.c
>>> +++ b/hw/mem/pc-dimm.c
>>> @@ -22,7 +22,17 @@
>>>   static MemoryRegion *pc_dimm_get_memory_region(DIMMDevice *dimm)
>>>   {
>>> -    return host_memory_backend_get_memory(dimm->hostmem, 
>>> &error_abort);
>>> +    Error *local_err = NULL;
>>> +    MemoryRegion *mr;
>>> +
>>> +    mr = host_memory_backend_get_memory(dimm->hostmem, &local_err);
>>> +
>>> +    /*
>>> +     * plug a pc-dimm device whose backend memory was not properly
>>> +     * initialized?
>>> +     */
>>> +    assert(!local_err && mr);
>>> +    return mr;
>>>   }
>>
>> this should squashed into previous patch, I think
>
> You mean merger this patch with 19/35 (dimm: abstract dimm device from 
> pc-dimm)?
> The 19/35 mostly ‘moves’ the things, this one changes the core logic, 
> it is not
> a big deal. :D

stupid me, you are right)

>
>>
>>>   static void pc_dimm_class_init(ObjectClass *oc, void *data)
>>
>> I've discovered suddenly, that
>>
>> MemoryRegion *
>> host_memory_backend_get_memory(HostMemoryBackend *backend, Error **errp)
>> {
>>      return memory_region_size(&backend->mr) ? &backend->mr : NULL;
>> }
>>
>> - it doesn't use errp at all. In my opinion, this should be fixed 
>> globally, by deleting useless
>> parameter in separate patch. Or just squash your function into 
>> previous patch.
>>
>
> Yup, this is a globally interface so i prefer to make a separate patch 
> to do the
> cleanup after this patchset.
>
>
Xiao Guangrong Nov. 2, 2015, 3:06 p.m. UTC | #4
On 11/02/2015 10:26 PM, Vladimir Sementsov-Ogievskiy wrote:
> On 02.11.2015 16:08, Xiao Guangrong wrote:
>>
>>
>> On 11/02/2015 08:19 PM, Vladimir Sementsov-Ogievskiy wrote:
>>> On 02.11.2015 12:13, Xiao Guangrong wrote:
>>>> Curretly, the memory region of backed memory is directly mapped to
>>>> guest's address space, however, it is not true for nvdimm device
>>>>
>>>> This patch let dimm device realize this fact and use
>>>> DIMMDeviceClass->get_memory_region method to get the mapped memory
>>>> region
>>>>
>>>> Current code did not check the return value of get_memory_region as it
>>>> assumed the backend memory of pc-dimm is always properly initialized,
>>>> we make get_memory_region internally catch the case if something is
>>>> wrong
>
> but here you call not pc-dimm's get_memory_region, but common ddc->get_memory_region, which may be
> nvdimm or possibly other future dimm, so, why not check it here? And than pc_dimm_get_memory_region
> may be left untouched (error_abort is ok, because errp is unused).

Hmm, because 'here' is not the only place calling ->get_memory_region, this method has
multiple callers:

$ git grep "\->get_memory_region"
hw/i386/pc.c:    MemoryRegion *mr = ddc->get_memory_region(dimm);
hw/i386/pc.c:    MemoryRegion *mr = ddc->get_memory_region(dimm);
hw/mem/dimm.c:    mr = ddc->get_memory_region(dimm);
hw/mem/nvdimm.c:    ddc->get_memory_region = nvdimm_get_memory_region;
hw/mem/pc-dimm.c:    ddc->get_memory_region = pc_dimm_get_memory_region;
hw/ppc/spapr.c:    MemoryRegion *mr = ddc->get_memory_region(dimm);

memory region validation is also done for NVDIMM in nvdimm device.

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Vladimir Sementsov-Ogievskiy Nov. 2, 2015, 4:16 p.m. UTC | #5
On 02.11.2015 18:06, Xiao Guangrong wrote:
>
>
> On 11/02/2015 10:26 PM, Vladimir Sementsov-Ogievskiy wrote:
>> On 02.11.2015 16:08, Xiao Guangrong wrote:
>>>
>>>
>>> On 11/02/2015 08:19 PM, Vladimir Sementsov-Ogievskiy wrote:
>>>> On 02.11.2015 12:13, Xiao Guangrong wrote:
>>>>> Curretly, the memory region of backed memory is directly mapped to
>>>>> guest's address space, however, it is not true for nvdimm device
>>>>>
>>>>> This patch let dimm device realize this fact and use
>>>>> DIMMDeviceClass->get_memory_region method to get the mapped memory
>>>>> region
>>>>>
>>>>> Current code did not check the return value of get_memory_region 
>>>>> as it
>>>>> assumed the backend memory of pc-dimm is always properly initialized,
>>>>> we make get_memory_region internally catch the case if something is
>>>>> wrong
>>
>> but here you call not pc-dimm's get_memory_region, but common 
>> ddc->get_memory_region, which may be
>> nvdimm or possibly other future dimm, so, why not check it here? And 
>> than pc_dimm_get_memory_region
>> may be left untouched (error_abort is ok, because errp is unused).
>
> Hmm, because 'here' is not the only place calling ->get_memory_region, 
> this method has
> multiple callers:
>
> $ git grep "\->get_memory_region"
> hw/i386/pc.c:    MemoryRegion *mr = ddc->get_memory_region(dimm);
> hw/i386/pc.c:    MemoryRegion *mr = ddc->get_memory_region(dimm);
> hw/mem/dimm.c:    mr = ddc->get_memory_region(dimm);
> hw/mem/nvdimm.c:    ddc->get_memory_region = nvdimm_get_memory_region;
> hw/mem/pc-dimm.c:    ddc->get_memory_region = pc_dimm_get_memory_region;
> hw/ppc/spapr.c:    MemoryRegion *mr = ddc->get_memory_region(dimm);
>
> memory region validation is also done for NVDIMM in nvdimm device.
>
Ok, then it should be documented by a comment in dimm.h, where 
DIMMDeviceClass is defined, that this function should not fail
Xiao Guangrong Nov. 3, 2015, 2:47 p.m. UTC | #6
On 11/03/2015 12:16 AM, Vladimir Sementsov-Ogievskiy wrote:
> On 02.11.2015 18:06, Xiao Guangrong wrote:
>>
>>
>> On 11/02/2015 10:26 PM, Vladimir Sementsov-Ogievskiy wrote:
>>> On 02.11.2015 16:08, Xiao Guangrong wrote:
>>>>
>>>>
>>>> On 11/02/2015 08:19 PM, Vladimir Sementsov-Ogievskiy wrote:
>>>>> On 02.11.2015 12:13, Xiao Guangrong wrote:
>>>>>> Curretly, the memory region of backed memory is directly mapped to
>>>>>> guest's address space, however, it is not true for nvdimm device
>>>>>>
>>>>>> This patch let dimm device realize this fact and use
>>>>>> DIMMDeviceClass->get_memory_region method to get the mapped memory
>>>>>> region
>>>>>>
>>>>>> Current code did not check the return value of get_memory_region as it
>>>>>> assumed the backend memory of pc-dimm is always properly initialized,
>>>>>> we make get_memory_region internally catch the case if something is
>>>>>> wrong
>>>
>>> but here you call not pc-dimm's get_memory_region, but common ddc->get_memory_region, which may be
>>> nvdimm or possibly other future dimm, so, why not check it here? And than pc_dimm_get_memory_region
>>> may be left untouched (error_abort is ok, because errp is unused).
>>
>> Hmm, because 'here' is not the only place calling ->get_memory_region, this method has
>> multiple callers:
>>
>> $ git grep "\->get_memory_region"
>> hw/i386/pc.c:    MemoryRegion *mr = ddc->get_memory_region(dimm);
>> hw/i386/pc.c:    MemoryRegion *mr = ddc->get_memory_region(dimm);
>> hw/mem/dimm.c:    mr = ddc->get_memory_region(dimm);
>> hw/mem/nvdimm.c:    ddc->get_memory_region = nvdimm_get_memory_region;
>> hw/mem/pc-dimm.c:    ddc->get_memory_region = pc_dimm_get_memory_region;
>> hw/ppc/spapr.c:    MemoryRegion *mr = ddc->get_memory_region(dimm);
>>
>> memory region validation is also done for NVDIMM in nvdimm device.
>>
> Ok, then it should be documented by a comment in dimm.h, where DIMMDeviceClass is defined, that this
> function should not fail
>

Okay, how about this comment:

     /*
      * get the memory region which will be mapped into guest's address
      * space. It is called after dimm device realized so it is never
      * failed.
      */
     MemoryRegion *(*get_memory_region)(DIMMDevice *dimm);
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Vladimir Sementsov-Ogievskiy Nov. 5, 2015, 8:53 a.m. UTC | #7
On 03.11.2015 17:47, Xiao Guangrong wrote:
>
>
> On 11/03/2015 12:16 AM, Vladimir Sementsov-Ogievskiy wrote:
>> On 02.11.2015 18:06, Xiao Guangrong wrote:
>>>
>>>
>>> On 11/02/2015 10:26 PM, Vladimir Sementsov-Ogievskiy wrote:
>>>> On 02.11.2015 16:08, Xiao Guangrong wrote:
>>>>>
>>>>>
>>>>> On 11/02/2015 08:19 PM, Vladimir Sementsov-Ogievskiy wrote:
>>>>>> On 02.11.2015 12:13, Xiao Guangrong wrote:
>>>>>>> Curretly, the memory region of backed memory is directly mapped to
>>>>>>> guest's address space, however, it is not true for nvdimm device
>>>>>>>
>>>>>>> This patch let dimm device realize this fact and use
>>>>>>> DIMMDeviceClass->get_memory_region method to get the mapped memory
>>>>>>> region
>>>>>>>
>>>>>>> Current code did not check the return value of get_memory_region 
>>>>>>> as it
>>>>>>> assumed the backend memory of pc-dimm is always properly 
>>>>>>> initialized,
>>>>>>> we make get_memory_region internally catch the case if something is
>>>>>>> wrong
>>>>
>>>> but here you call not pc-dimm's get_memory_region, but common 
>>>> ddc->get_memory_region, which may be
>>>> nvdimm or possibly other future dimm, so, why not check it here? 
>>>> And than pc_dimm_get_memory_region
>>>> may be left untouched (error_abort is ok, because errp is unused).
>>>
>>> Hmm, because 'here' is not the only place calling 
>>> ->get_memory_region, this method has
>>> multiple callers:
>>>
>>> $ git grep "\->get_memory_region"
>>> hw/i386/pc.c:    MemoryRegion *mr = ddc->get_memory_region(dimm);
>>> hw/i386/pc.c:    MemoryRegion *mr = ddc->get_memory_region(dimm);
>>> hw/mem/dimm.c:    mr = ddc->get_memory_region(dimm);
>>> hw/mem/nvdimm.c:    ddc->get_memory_region = nvdimm_get_memory_region;
>>> hw/mem/pc-dimm.c:    ddc->get_memory_region = 
>>> pc_dimm_get_memory_region;
>>> hw/ppc/spapr.c:    MemoryRegion *mr = ddc->get_memory_region(dimm);
>>>
>>> memory region validation is also done for NVDIMM in nvdimm device.
>>>
>> Ok, then it should be documented by a comment in dimm.h, where 
>> DIMMDeviceClass is defined, that this
>> function should not fail
>>
>
> Okay, how about this comment:
>
>     /*
>      * get the memory region which will be mapped into guest's address
>      * space. It is called after dimm device realized so it is never
>      * failed.
>      */
>     MemoryRegion *(*get_memory_region)(DIMMDevice *dimm);

if you don't mind:
s/it is never failed/it should never fail and assumed to return valid 
not-NULL address

I'll ok with this if others don't mind, but personally I prefer explicit 
error handling for such functions.
Eduardo Habkost Nov. 5, 2015, 5:29 p.m. UTC | #8
On Mon, Nov 02, 2015 at 05:13:22PM +0800, Xiao Guangrong wrote:
[...]
>  static MemoryRegion *pc_dimm_get_memory_region(DIMMDevice *dimm)
>  {
> -    return host_memory_backend_get_memory(dimm->hostmem, &error_abort);
> +    Error *local_err = NULL;
> +    MemoryRegion *mr;
> +
> +    mr = host_memory_backend_get_memory(dimm->hostmem, &local_err);
> +
> +    /*
> +     * plug a pc-dimm device whose backend memory was not properly
> +     * initialized?
> +     */
> +    assert(!local_err && mr);

I don't know if you are going to remove the errp parameter in the next
version, but if you want to simply abort in case an error is reported by
a function, you can use &error_abort.
Xiao Guangrong Nov. 6, 2015, 2:50 a.m. UTC | #9
On 11/06/2015 01:29 AM, Eduardo Habkost wrote:
> On Mon, Nov 02, 2015 at 05:13:22PM +0800, Xiao Guangrong wrote:
> [...]
>>   static MemoryRegion *pc_dimm_get_memory_region(DIMMDevice *dimm)
>>   {
>> -    return host_memory_backend_get_memory(dimm->hostmem, &error_abort);
>> +    Error *local_err = NULL;
>> +    MemoryRegion *mr;
>> +
>> +    mr = host_memory_backend_get_memory(dimm->hostmem, &local_err);
>> +
>> +    /*
>> +     * plug a pc-dimm device whose backend memory was not properly
>> +     * initialized?
>> +     */
>> +    assert(!local_err && mr);
>
> I don't know if you are going to remove the errp parameter in the next
> version, but if you want to simply abort in case an error is reported by
> a function, you can use &error_abort.
>

Thank you, Eduardo! let's happily drop the unused errp parameter in
host_memory_backend_get_memory in the next version. :)
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/hw/mem/dimm.c b/hw/mem/dimm.c
index 4a63409..498d380 100644
--- a/hw/mem/dimm.c
+++ b/hw/mem/dimm.c
@@ -377,8 +377,9 @@  static void dimm_get_size(Object *obj, Visitor *v, void *opaque,
     int64_t value;
     MemoryRegion *mr;
     DIMMDevice *dimm = DIMM(obj);
+    DIMMDeviceClass *ddc = DIMM_GET_CLASS(obj);
 
-    mr = host_memory_backend_get_memory(dimm->hostmem, errp);
+    mr = ddc->get_memory_region(dimm);
     value = memory_region_size(mr);
 
     visit_type_int(v, &value, name, errp);
diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
index 38323e9..e6b6a9f 100644
--- a/hw/mem/pc-dimm.c
+++ b/hw/mem/pc-dimm.c
@@ -22,7 +22,17 @@ 
 
 static MemoryRegion *pc_dimm_get_memory_region(DIMMDevice *dimm)
 {
-    return host_memory_backend_get_memory(dimm->hostmem, &error_abort);
+    Error *local_err = NULL;
+    MemoryRegion *mr;
+
+    mr = host_memory_backend_get_memory(dimm->hostmem, &local_err);
+
+    /*
+     * plug a pc-dimm device whose backend memory was not properly
+     * initialized?
+     */
+    assert(!local_err && mr);
+    return mr;
 }
 
 static void pc_dimm_class_init(ObjectClass *oc, void *data)