@@ -330,6 +330,21 @@ uint64_t memory_device_get_region_size(const MemoryDeviceState *md,
return memory_region_size(mr);
}
+void memory_device_set_region_size(const MemoryDeviceState *md,
+ uint64_t size, Error **errp)
+{
+ const MemoryDeviceClass *mdc = MEMORY_DEVICE_GET_CLASS(md);
+ MemoryRegion *mr;
+
+ /* dropping const here is fine as we don't touch the memory region */
+ mr = mdc->get_memory_region((MemoryDeviceState *)md, errp);
+ if (!mr) {
+ return;
+ }
+
+ memory_region_set_size(mr, size);
+}
+
static const TypeInfo memory_device_info = {
.name = TYPE_MEMORY_DEVICE,
.parent = TYPE_INTERFACE,
@@ -103,5 +103,7 @@ void memory_device_plug(MemoryDeviceState *md, MachineState *ms);
void memory_device_unplug(MemoryDeviceState *md, MachineState *ms);
uint64_t memory_device_get_region_size(const MemoryDeviceState *md,
Error **errp);
+void memory_device_set_region_size(const MemoryDeviceState *md,
+ uint64_t size, Error **errp);
#endif
Required for PAPR NVDIMM implementation. Need memory_device_set_region_size for aligning the size to the SCM block size. Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com> --- hw/mem/memory-device.c | 15 +++++++++++++++ include/hw/mem/memory-device.h | 2 ++ 2 files changed, 17 insertions(+)