qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ppc/spapr: init lrdr-capapcity phys with ram size if maxmem not provided
@ 2025-05-06  4:29 Harsh Prateek Bora
  2025-09-11 10:19 ` Shivaprasad G Bhat
  0 siblings, 1 reply; 2+ messages in thread
From: Harsh Prateek Bora @ 2025-05-06  4:29 UTC (permalink / raw)
  To: qemu-ppc, npiggin; +Cc: danielhb413, qemu-devel

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 <gbatra@us.ibm.com>
Tested-by: David Christensen <drc@linux.ibm.com>
Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
---
 hw/ppc/spapr.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 702f774cda..9f18642734 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -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 */
-- 
2.49.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ppc/spapr: init lrdr-capapcity phys with ram size if maxmem not provided
  2025-05-06  4:29 [PATCH] ppc/spapr: init lrdr-capapcity phys with ram size if maxmem not provided Harsh Prateek Bora
@ 2025-09-11 10:19 ` Shivaprasad G Bhat
  0 siblings, 0 replies; 2+ messages in thread
From: Shivaprasad G Bhat @ 2025-09-11 10:19 UTC (permalink / raw)
  To: Harsh Prateek Bora, qemu-ppc, npiggin; +Cc: danielhb413, qemu-devel

On 5/6/25 9:59 AM, Harsh Prateek Bora wrote:
> 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 <gbatra@us.ibm.com>
> Tested-by: David Christensen <drc@linux.ibm.com>
> Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
> ---
>   hw/ppc/spapr.c | 11 +++++++----
>   1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 702f774cda..9f18642734 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -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);
> +

Since maxmem accounts for pcdimm and/or nvdimm cases, this would work

fine for all probable scenarios in this code path.


Reviewed-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>


Thanks,

Shivaprasad



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-09-11 10:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-06  4:29 [PATCH] ppc/spapr: init lrdr-capapcity phys with ram size if maxmem not provided Harsh Prateek Bora
2025-09-11 10:19 ` Shivaprasad G Bhat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).