Skip to contentSkip to conversation

dimm: Correct type of MemoryHotplugState->base

PATCH In review David Gibson 4 participants 8 messages Jan 21, 2016 – Feb 3, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dimm: Correct type of MemoryHotplugState->base

The 'base' field of MemoryHotplugState is ram_addr_t, which indicates that it exists in the abstract address space of RAM regions.

However, the actual usage of this field indicates that it is a concrete physical address (it's passed as an offset to memory_region_add_subgregion for example).

So, correct its type to 'hwaddr'.

---
 include/hw/mem/pc-dimm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/hw/mem/pc-dimm.h +1 -1
index d83bf30..218dfb0 100644
@@ -77,7 +77,7 @@ typedef struct PCDIMMDeviceClass {
  * @mr: hotplug memory address space container
  */
 typedef struct MemoryHotplugState {
-    ram_addr_t base;
+    hwaddr base;
     MemoryRegion mr;
 } MemoryHotplugState;
 
Signature · 1 line
2.5.0
#1 lore raw
Quoted 19 lines · On Thu, 21 Jan 2016 12:37:51 +1100 David Gibson <[email protected]>…

The 'base' field of MemoryHotplugState is ram_addr_t, which indicates that it exists in the abstract address space of RAM regions.

However, the actual usage of this field indicates that it is a concrete physical address (it's passed as an offset to memory_region_add_subgregion for example).

So, correct its type to 'hwaddr'.

---
 include/hw/mem/pc-dimm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/hw/mem/pc-dimm.h +0 -0
index d83bf30..218dfb0 100644

include/hw/mem/pc-dimm.h typedef struct PCDIMMDeviceClass { · line 83

Quoted 8 lines
include/hw/mem/pc-dimm.h +1 -1
@@ -77,7 +77,7 @@ typedef struct PCDIMMDeviceClass {
  * @mr: hotplug memory address space container
  */
 typedef struct MemoryHotplugState {
-    ram_addr_t base;
+    hwaddr base;
     MemoryRegion mr;
 } MemoryHotplugState;
 

I agree with this fix but that's not the only place where ram_addr_t needs to be replaced with hwaddr.
For example type of MachineState.[max]ram_size fields needs to be changed as well. Because QEMU builds without CONFIG_XEN_BACKEND on 32-bit hosts are broken since ram_addr_t is 32-bits there while some targets assume and use it as 64-bit one.

#2 lore raw
Quoted 29 lines · Igor Mammedov
Quoted 26 lines · On Thu, 21 Jan 2016 12:37:51 +1100 David Gibson <[email protected]>…

The 'base' field of MemoryHotplugState is ram_addr_t, which indicates that it exists in the abstract address space of RAM regions.

However, the actual usage of this field indicates that it is a concrete physical address (it's passed as an offset to memory_region_add_subgregion for example).

So, correct its type to 'hwaddr'.

---
 include/hw/mem/pc-dimm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/hw/mem/pc-dimm.h +1 -1
index d83bf30..218dfb0 100644
@@ -77,7 +77,7 @@ typedef struct PCDIMMDeviceClass {
  * @mr: hotplug memory address space container
  */
 typedef struct MemoryHotplugState {
-    ram_addr_t base;
+    hwaddr base;
     MemoryRegion mr;
 } MemoryHotplugState;
Quoted 8 lines
Quoted 1 line

I agree with this fix but that's not the only place where ram_addr_t needs to be replaced with hwaddr.
For example type of MachineState.[max]ram_size fields needs to be changed as well. Because QEMU builds without CONFIG_XEN_BACKEND on 32-bit hosts are broken since ram_addr_t is 32-bits there while some targets assume and use it as 64-bit one.

But on a 32-bit system without CONFIG_XEN_BACKEND you cannot allocate more than 4G anyway, so the choice of ram_addr_t is understandable in that case.

On the other hand, on a 32-bit system without CONFIG_XEN_BACKEND you definitely can place 128M of hot plugged memory between say 4096MB and 4224MB.

Paolo

Reviewed-by
#3 lore raw
Quoted 39 lines · On Fri, 22 Jan 2016 15:21:05 +0100 Paolo Bonzini <[email protected]> wrote:
Quoted 29 lines · Igor Mammedov
Quoted 26 lines · On Thu, 21 Jan 2016 12:37:51 +1100 David Gibson <[email protected]>…

The 'base' field of MemoryHotplugState is ram_addr_t, which indicates that it exists in the abstract address space of RAM regions.

However, the actual usage of this field indicates that it is a concrete physical address (it's passed as an offset to memory_region_add_subgregion for example).

So, correct its type to 'hwaddr'.

---
 include/hw/mem/pc-dimm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/hw/mem/pc-dimm.h +1 -1
index d83bf30..218dfb0 100644
@@ -77,7 +77,7 @@ typedef struct PCDIMMDeviceClass {
  * @mr: hotplug memory address space container
  */
 typedef struct MemoryHotplugState {
-    ram_addr_t base;
+    hwaddr base;
     MemoryRegion mr;
 } MemoryHotplugState;
Quoted 8 lines
Quoted 1 line

I agree with this fix but that's not the only place where ram_addr_t needs to be replaced with hwaddr.
For example type of MachineState.[max]ram_size fields needs to be changed as well. Because QEMU builds without CONFIG_XEN_BACKEND on 32-bit hosts are broken since ram_addr_t is 32-bits there while some targets assume and use it as 64-bit one.

Quoted 3 lines

But on a 32-bit system without CONFIG_XEN_BACKEND you cannot allocate more than 4G anyway, so the choice of ram_addr_t is understandable in that case.

QEMU build will probably fail with above config but if it succeeds then maxmem will be silently truncated.

Quoted 4 lines

On the other hand, on a 32-bit system without CONFIG_XEN_BACKEND you definitely can place 128M of hot plugged memory between say 4096MB and 4224MB.

True.

Anyway for this patch

Quoted 3 lines

Paolo

#4 lore raw
Quoted 49 lines · Igor Mammedov
Quoted 39 lines · On Fri, 22 Jan 2016 15:21:05 +0100 Paolo Bonzini <[email protected]> wrote:
Quoted 29 lines · Igor Mammedov
Quoted 26 lines · On Thu, 21 Jan 2016 12:37:51 +1100 David Gibson <[email protected]>…

The 'base' field of MemoryHotplugState is ram_addr_t, which indicates that it exists in the abstract address space of RAM regions.

However, the actual usage of this field indicates that it is a concrete physical address (it's passed as an offset to memory_region_add_subgregion for example).

So, correct its type to 'hwaddr'.

---
 include/hw/mem/pc-dimm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/hw/mem/pc-dimm.h +1 -1
index d83bf30..218dfb0 100644
@@ -77,7 +77,7 @@ typedef struct PCDIMMDeviceClass {
  * @mr: hotplug memory address space container
  */
 typedef struct MemoryHotplugState {
-    ram_addr_t base;
+    hwaddr base;
     MemoryRegion mr;
 } MemoryHotplugState;
Quoted 8 lines
Quoted 1 line

I agree with this fix but that's not the only place where ram_addr_t needs to be replaced with hwaddr.
For example type of MachineState.[max]ram_size fields needs to be changed as well. Because QEMU builds without CONFIG_XEN_BACKEND on 32-bit hosts are broken since ram_addr_t is 32-bits there while some targets assume and use it as 64-bit one.

Quoted 3 lines

But on a 32-bit system without CONFIG_XEN_BACKEND you cannot allocate more than 4G anyway, so the choice of ram_addr_t is understandable in that case.

QEMU build will probably fail with above config but if it succeeds then maxmem will be silently truncated.

Quoted 1 line
Quoted 7 lines
Quoted 3 lines

On the other hand, on a 32-bit system without CONFIG_XEN_BACKEND you definitely can place 128M of hot plugged memory between say 4096MB and 4224MB.

True.

Anyway for this patch

Who needs to take this patch? I'm not sure if I need to do anything further to push it forwards.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#5 lore raw
Quoted 53 lines · David Gibson
Quoted 52 lines · Igor Mammedov
Quoted 39 lines · On Fri, 22 Jan 2016 15:21:05 +0100 Paolo Bonzini <[email protected]> wrote:
Quoted 29 lines · Igor Mammedov
Quoted 26 lines · On Thu, 21 Jan 2016 12:37:51 +1100 David Gibson <[email protected]>…

The 'base' field of MemoryHotplugState is ram_addr_t, which indicates that it exists in the abstract address space of RAM regions.

However, the actual usage of this field indicates that it is a concrete physical address (it's passed as an offset to memory_region_add_subgregion for example).

So, correct its type to 'hwaddr'.

---
 include/hw/mem/pc-dimm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/hw/mem/pc-dimm.h +1 -1
index d83bf30..218dfb0 100644
@@ -77,7 +77,7 @@ typedef struct PCDIMMDeviceClass {
  * @mr: hotplug memory address space container
  */
 typedef struct MemoryHotplugState {
-    ram_addr_t base;
+    hwaddr base;
     MemoryRegion mr;
 } MemoryHotplugState;
Quoted 8 lines
Quoted 1 line

I agree with this fix but that's not the only place where ram_addr_t needs to be replaced with hwaddr.
For example type of MachineState.[max]ram_size fields needs to be changed as well. Because QEMU builds without CONFIG_XEN_BACKEND on 32-bit hosts are broken since ram_addr_t is 32-bits there while some targets assume and use it as 64-bit one.

Quoted 3 lines

But on a 32-bit system without CONFIG_XEN_BACKEND you cannot allocate more than 4G anyway, so the choice of ram_addr_t is understandable in that case.

QEMU build will probably fail with above config but if it succeeds then maxmem will be silently truncated.

Quoted 4 lines

On the other hand, on a 32-bit system without CONFIG_XEN_BACKEND you definitely can place 128M of hot plugged memory between say 4096MB and 4224MB.

Quoted 7 lines
Quoted 4 lines

True.

Anyway for this patch

Who needs to take this patch? I'm not sure if I need to do anything further to push it forwards.

Most pc-dimm changes were merged either by me or Michael. I can merge it if I get an Acked-by from Michael.

Otherwise, Michael has my Acked-by if he wants to merge it through his tree.

Signature · 1 line
Eduardo
#6 lore raw
Quoted 62 lines · Eduardo Habkost
Quoted 53 lines · David Gibson
Quoted 52 lines · Igor Mammedov
Quoted 39 lines · On Fri, 22 Jan 2016 15:21:05 +0100 Paolo Bonzini <[email protected]> wrote:
Quoted 29 lines · Igor Mammedov
Quoted 26 lines · On Thu, 21 Jan 2016 12:37:51 +1100 David Gibson <[email protected]>…

The 'base' field of MemoryHotplugState is ram_addr_t, which indicates that it exists in the abstract address space of RAM regions.

However, the actual usage of this field indicates that it is a concrete physical address (it's passed as an offset to memory_region_add_subgregion for example).

So, correct its type to 'hwaddr'.

---
 include/hw/mem/pc-dimm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/hw/mem/pc-dimm.h +1 -1
index d83bf30..218dfb0 100644
@@ -77,7 +77,7 @@ typedef struct PCDIMMDeviceClass {
  * @mr: hotplug memory address space container
  */
 typedef struct MemoryHotplugState {
-    ram_addr_t base;
+    hwaddr base;
     MemoryRegion mr;
 } MemoryHotplugState;
Quoted 8 lines
Quoted 1 line

I agree with this fix but that's not the only place where ram_addr_t needs to be replaced with hwaddr.
For example type of MachineState.[max]ram_size fields needs to be changed as well. Because QEMU builds without CONFIG_XEN_BACKEND on 32-bit hosts are broken since ram_addr_t is 32-bits there while some targets assume and use it as 64-bit one.

Quoted 3 lines

But on a 32-bit system without CONFIG_XEN_BACKEND you cannot allocate more than 4G anyway, so the choice of ram_addr_t is understandable in that case.

QEMU build will probably fail with above config but if it succeeds then maxmem will be silently truncated.

Quoted 4 lines

On the other hand, on a 32-bit system without CONFIG_XEN_BACKEND you definitely can place 128M of hot plugged memory between say 4096MB and 4224MB.

Quoted 7 lines
Quoted 4 lines

True.

Anyway for this patch

Who needs to take this patch? I'm not sure if I need to do anything further to push it forwards.

Quoted 7 lines

Most pc-dimm changes were merged either by me or Michael. I can merge it if I get an Acked-by from Michael.

Otherwise, Michael has my Acked-by if he wants to merge it through his tree.

Ah, I didn't realise Michael worked in this area. Adding him to CC..

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#7 lore raw
Quoted 66 lines · David Gibson
Quoted 65 lines · Eduardo Habkost
Quoted 53 lines · David Gibson
Quoted 52 lines · Igor Mammedov
Quoted 39 lines · On Fri, 22 Jan 2016 15:21:05 +0100 Paolo Bonzini <[email protected]> wrote:
Quoted 29 lines · Igor Mammedov
Quoted 26 lines · On Thu, 21 Jan 2016 12:37:51 +1100 David Gibson <[email protected]>…

The 'base' field of MemoryHotplugState is ram_addr_t, which indicates that it exists in the abstract address space of RAM regions.

However, the actual usage of this field indicates that it is a concrete physical address (it's passed as an offset to memory_region_add_subgregion for example).

So, correct its type to 'hwaddr'.

---
 include/hw/mem/pc-dimm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/hw/mem/pc-dimm.h +1 -1
index d83bf30..218dfb0 100644
@@ -77,7 +77,7 @@ typedef struct PCDIMMDeviceClass {
  * @mr: hotplug memory address space container
  */
 typedef struct MemoryHotplugState {
-    ram_addr_t base;
+    hwaddr base;
     MemoryRegion mr;
 } MemoryHotplugState;
Quoted 8 lines
Quoted 1 line

I agree with this fix but that's not the only place where ram_addr_t needs to be replaced with hwaddr.
For example type of MachineState.[max]ram_size fields needs to be changed as well. Because QEMU builds without CONFIG_XEN_BACKEND on 32-bit hosts are broken since ram_addr_t is 32-bits there while some targets assume and use it as 64-bit one.

Quoted 3 lines

But on a 32-bit system without CONFIG_XEN_BACKEND you cannot allocate more than 4G anyway, so the choice of ram_addr_t is understandable in that case.

QEMU build will probably fail with above config but if it succeeds then maxmem will be silently truncated.

Quoted 4 lines

On the other hand, on a 32-bit system without CONFIG_XEN_BACKEND you definitely can place 128M of hot plugged memory between say 4096MB and 4224MB.

Quoted 7 lines
Quoted 4 lines

True.

Anyway for this patch

Who needs to take this patch? I'm not sure if I need to do anything further to push it forwards.

Most pc-dimm changes were merged either by me or Michael. I can merge it if I get an Acked-by from Michael.

Quoted 6 lines
Quoted 4 lines

Otherwise, Michael has my Acked-by if he wants to merge it through his tree.

Ah, I didn't realise Michael worked in this area. Adding him to CC..

Ooops, I thought Michael was already on CC. He is the PC and PCI maintainer, but he has been merging machine.c and other generic hw/ patches recently.

I sent another message to qemu-devel today, asking people where could be the default destination for hw/core and other generic hw/ code that has no maintainer in MAINTAINERS.

Signature · 1 line
Eduardo