ppc/spapr: init lrdr-capapcity phys with ram size if maxmem not provided
PATCH 1/1 ppc/spapr: init lrdr-capapcity phys with ram size if maxmem not provided
lrdr-capacity contains phys field which communicates the maximum address in bytes and therefore, the most memory that can be allocated to this partition. This is usually populated when maxmem is provided alongwith memory size on qemu command line. However since maxmem is an optional param, this leads to bits being set to 0 in absence of maxmem param. Fix this by initializing the respective bits as per total mem size in such case.
--- hw/ppc/spapr.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
hw/ppc/spapr.c +7 -4
@@ -907,6 +907,7 @@ static void spapr_dt_rtas(SpaprMachineState *spapr, void *fdt)int rtas;GString *hypertas =g_string_sized_new (256 );GString *qemu_hypertas =g_string_sized_new (256 ); +uint64_t max_device_addr =0 ;uint32_t lrdr_capacity[] = {0 ,0 ,
@@ -917,13 +918,15 @@ static void spapr_dt_rtas(SpaprMachineState *spapr, void *fdt)/* Do we have device memory? */ if (MACHINE (spapr)->device_memory) { -uint64_t max_device_addr =MACHINE (spapr)->device_memory->base + + max_device_addr =MACHINE (spapr)->device_memory->base +memory_region_size (&MACHINE (spapr)->device_memory->mr); - - lrdr_capacity[0 ] =cpu_to_be32 (max_device_addr >>32 ); - lrdr_capacity[1 ] =cpu_to_be32 (max_device_addr &0xffffffff ); + }else if (ms->ram_size == ms->maxram_size) { + max_device_addr = ms->ram_size; } + lrdr_capacity[0 ] =cpu_to_be32 (max_device_addr >>32 ); + lrdr_capacity[1 ] =cpu_to_be32 (max_device_addr &0xffffffff ); +_FDT (rtas =fdt_add_subnode (fdt,0 ,"rtas" ));/* hypertas */
Signature · 1 line
2.49.0
Quoted 34 lines · Harsh Prateek Bora
lrdr-capacity contains phys field which communicates the maximum address in bytes and therefore, the most memory that can be allocated to this partition. This is usually populated when maxmem is provided alongwith memory size on qemu command line. However since maxmem is an optional param, this leads to bits being set to 0 in absence of maxmem param. Fix this by initializing the respective bits as per total mem size in such case.
Reported-by Gaurav Batra <[email protected]>Tested-by David Christensen <[email protected]>Signed-off-by Harsh Prateek Bora <[email protected]>--- hw/ppc/spapr.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)hw/ppc/spapr.c +2
-1@@ -907,6 +907,7 @@ static void spapr_dt_rtas(SpaprMachineState *spapr, void *fdt)int rtas;GString *hypertas =g_string_sized_new (256 );GString *qemu_hypertas =g_string_sized_new (256 ); +uint64_t max_device_addr =0 ;uint32_t lrdr_capacity[] = {0 ,0 ,@@ -917,13 +918,15 @@ static void spapr_dt_rtas(SpaprMachineState *spapr, void *fdt)/* Do we have device memory? */ if (MACHINE (spapr)->device_memory) { -uint64_t max_device_addr =MACHINE (spapr)->device_memory->base + + max_device_addr =MACHINE (spapr)->device_memory->base +memory_region_size (&MACHINE (spapr)->device_memory->mr);
hw/ppc/spapr.c static void spapr_dt_rtas(SpaprMachineState *spapr, void *fdt) · line 929
Quoted 10 lines
hw/ppc/spapr.c +5
-3- - lrdr_capacity[0 ] =cpu_to_be32 (max_device_addr >>32 ); - lrdr_capacity[1 ] =cpu_to_be32 (max_device_addr &0xffffffff ); + }else if (ms->ram_size == ms->maxram_size) { + max_device_addr = ms->ram_size; } + lrdr_capacity[0 ] =cpu_to_be32 (max_device_addr >>32 ); + lrdr_capacity[1 ] =cpu_to_be32 (max_device_addr &0xffffffff ); +
Since maxmem accounts for pcdimm and/or nvdimm cases, this would work
fine for all probable scenarios in this code path.
Thanks,
Shivaprasad