diff mbox series

mips/mips_malta: Allow more than 2G RAM

Message ID 20200228032613.1049955-1-jiaxun.yang@flygoat.com (mailing list archive)
State New, archived
Headers show
Series mips/mips_malta: Allow more than 2G RAM | expand

Commit Message

Jiaxun Yang Feb. 28, 2020, 3:26 a.m. UTC
When malta is coupled with MIPS64 cpu which have 64bit
address space, it is possible to have more than 2G RAM.

So we removed ram_size check and overwrite memory
layout for these targets.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Suggested-by: Yunqiang Su <ysu@wavecomp.com>
---
 hw/mips/mips_malta.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

Comments

Aleksandar Markovic March 2, 2020, 9:22 p.m. UTC | #1
Forwarding this to Igor. Can you please give us your opinion, Igor, on this proposal?
Philippe Mathieu-Daudé March 2, 2020, 11:59 p.m. UTC | #2
On 3/2/20 10:22 PM, Aleksandar Markovic wrote:
> Forwarding this to Igor. Can you please give us your opinion, Igor, on this proposal?

I'm not sure it is Igor area.

What need to be reviewed here is the GT64120 north bridge, which works 
very well with the default config, but is fragile when modifying it.

I'd be more confident with an acceptance test running memtester.

> ________________________________________
> From: Jiaxun Yang <jiaxun.yang@flygoat.com>
> Sent: Friday, February 28, 2020 4:26 AM
> To: qemu-devel@nongnu.org
> Cc: philmd@redhat.com; Aleksandar Markovic; Jiaxun Yang; Yunqiang Su
> Subject: [EXTERNAL][PATCH] mips/mips_malta: Allow more than 2G RAM
> 
> When malta is coupled with MIPS64 cpu which have 64bit
> address space, it is possible to have more than 2G RAM.
> 
> So we removed ram_size check and overwrite memory
> layout for these targets.
> 
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> Suggested-by: Yunqiang Su <ysu@wavecomp.com>
> ---
>   hw/mips/mips_malta.c | 24 ++++++++++++++++++------
>   1 file changed, 18 insertions(+), 6 deletions(-)
> 
> diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c
> index 6e7ba9235d..de89cdcfc1 100644
> --- a/hw/mips/mips_malta.c
> +++ b/hw/mips/mips_malta.c
> @@ -98,7 +98,8 @@ typedef struct {
>   } MaltaState;
> 
>   static struct _loaderparams {
> -    int ram_size, ram_low_size;
> +    unsigned int ram_low_size;
> +    ram_addr_t ram_size;
>       const char *kernel_filename;
>       const char *kernel_cmdline;
>       const char *initrd_filename;
> @@ -1023,6 +1024,7 @@ static int64_t load_kernel(void)
>   {
>       int64_t kernel_entry, kernel_high, initrd_size;
>       long kernel_size;
> +    char mem_cmdline[128];
>       ram_addr_t initrd_offset;
>       int big_endian;
>       uint32_t *prom_buf;
> @@ -1099,20 +1101,28 @@ static int64_t load_kernel(void)
>       prom_buf = g_malloc(prom_size);
> 
>       prom_set(prom_buf, prom_index++, "%s", loaderparams.kernel_filename);
> +
> +    /*
> +     * Always use cmdline to overwrite mem layout
> +     * as kernel may reject large emesize.
> +     */
> +    sprintf(&mem_cmdline[0],
> +        "mem=0x10000000@0x00000000 mem=0x%" PRIx64 "@0x90000000",
> +        loaderparams.ram_size - 0x10000000);
>       if (initrd_size > 0) {
>           prom_set(prom_buf, prom_index++,
> -                 "rd_start=0x%" PRIx64 " rd_size=%" PRId64 " %s",
> -                 xlate_to_kseg0(NULL, initrd_offset),
> +                 "%s rd_start=0x%" PRIx64 " rd_size=%" PRId64 " %s",
> +                 &mem_cmdline[0], xlate_to_kseg0(NULL, initrd_offset),
>                    initrd_size, loaderparams.kernel_cmdline);
>       } else {
> -        prom_set(prom_buf, prom_index++, "%s", loaderparams.kernel_cmdline);
> +        prom_set(prom_buf, prom_index++, "%s %s",&mem_cmdline[0] ,loaderparams.kernel_cmdline);
>       }
> 
>       prom_set(prom_buf, prom_index++, "memsize");
>       prom_set(prom_buf, prom_index++, "%u", loaderparams.ram_low_size);
> 
>       prom_set(prom_buf, prom_index++, "ememsize");
> -    prom_set(prom_buf, prom_index++, "%u", loaderparams.ram_size);
> +    prom_set(prom_buf, prom_index++, "%lu", loaderparams.ram_size);
> 
>       prom_set(prom_buf, prom_index++, "modetty0");
>       prom_set(prom_buf, prom_index++, "38400n8r");
> @@ -1253,12 +1263,14 @@ void mips_malta_init(MachineState *machine)
>       /* create CPU */
>       mips_create_cpu(machine, s, &cbus_irq, &i8259_irq);
> 
> -    /* allocate RAM */
> +#ifdef TARGET_MIPS32
> +    /* MIPS32 won't accept more than 2GiB RAM due to limited address space */
>       if (ram_size > 2 * GiB) {
>           error_report("Too much memory for this machine: %" PRId64 "MB,"
>                        " maximum 2048MB", ram_size / MiB);
>           exit(1);
>       }
> +#endif
> 
>       /* register RAM at high address where it is undisturbed by IO */
>       memory_region_add_subregion(system_memory, 0x80000000, machine->ram);
> --
> 2.25.1
> 
> 
> 
>
Igor Mammedov March 3, 2020, 7:57 a.m. UTC | #3
On Tue, 3 Mar 2020 00:59:26 +0100
Philippe Mathieu-Daudé <philmd@redhat.com> wrote:

> On 3/2/20 10:22 PM, Aleksandar Markovic wrote:
> > Forwarding this to Igor. Can you please give us your opinion, Igor, on this proposal?  
> 
> I'm not sure it is Igor area.
true,

as far as board consumes all machine->ram and works fine when
user specifies insane -m value there, it would be fine with me.
 
> What need to be reviewed here is the GT64120 north bridge, which works 
> very well with the default config, but is fragile when modifying it.
> 
> I'd be more confident with an acceptance test running memtester.
> 
> > ________________________________________
> > From: Jiaxun Yang <jiaxun.yang@flygoat.com>
> > Sent: Friday, February 28, 2020 4:26 AM
> > To: qemu-devel@nongnu.org
> > Cc: philmd@redhat.com; Aleksandar Markovic; Jiaxun Yang; Yunqiang Su
> > Subject: [EXTERNAL][PATCH] mips/mips_malta: Allow more than 2G RAM
> > 
> > When malta is coupled with MIPS64 cpu which have 64bit
> > address space, it is possible to have more than 2G RAM.
> > 
> > So we removed ram_size check and overwrite memory
> > layout for these targets.
> > 
> > Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> > Suggested-by: Yunqiang Su <ysu@wavecomp.com>
> > ---
> >   hw/mips/mips_malta.c | 24 ++++++++++++++++++------
> >   1 file changed, 18 insertions(+), 6 deletions(-)
> > 
> > diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c
> > index 6e7ba9235d..de89cdcfc1 100644
> > --- a/hw/mips/mips_malta.c
> > +++ b/hw/mips/mips_malta.c
> > @@ -98,7 +98,8 @@ typedef struct {
> >   } MaltaState;
> > 
> >   static struct _loaderparams {
> > -    int ram_size, ram_low_size;
> > +    unsigned int ram_low_size;
> > +    ram_addr_t ram_size;
> >       const char *kernel_filename;
> >       const char *kernel_cmdline;
> >       const char *initrd_filename;
> > @@ -1023,6 +1024,7 @@ static int64_t load_kernel(void)
> >   {
> >       int64_t kernel_entry, kernel_high, initrd_size;
> >       long kernel_size;
> > +    char mem_cmdline[128];
> >       ram_addr_t initrd_offset;
> >       int big_endian;
> >       uint32_t *prom_buf;
> > @@ -1099,20 +1101,28 @@ static int64_t load_kernel(void)
> >       prom_buf = g_malloc(prom_size);
> > 
> >       prom_set(prom_buf, prom_index++, "%s", loaderparams.kernel_filename);
> > +
> > +    /*
> > +     * Always use cmdline to overwrite mem layout
> > +     * as kernel may reject large emesize.
> > +     */
> > +    sprintf(&mem_cmdline[0],
> > +        "mem=0x10000000@0x00000000 mem=0x%" PRIx64 "@0x90000000",
> > +        loaderparams.ram_size - 0x10000000);
> >       if (initrd_size > 0) {
> >           prom_set(prom_buf, prom_index++,
> > -                 "rd_start=0x%" PRIx64 " rd_size=%" PRId64 " %s",
> > -                 xlate_to_kseg0(NULL, initrd_offset),
> > +                 "%s rd_start=0x%" PRIx64 " rd_size=%" PRId64 " %s",
> > +                 &mem_cmdline[0], xlate_to_kseg0(NULL, initrd_offset),
> >                    initrd_size, loaderparams.kernel_cmdline);
> >       } else {
> > -        prom_set(prom_buf, prom_index++, "%s", loaderparams.kernel_cmdline);
> > +        prom_set(prom_buf, prom_index++, "%s %s",&mem_cmdline[0] ,loaderparams.kernel_cmdline);
> >       }
> > 
> >       prom_set(prom_buf, prom_index++, "memsize");
> >       prom_set(prom_buf, prom_index++, "%u", loaderparams.ram_low_size);
> > 
> >       prom_set(prom_buf, prom_index++, "ememsize");
> > -    prom_set(prom_buf, prom_index++, "%u", loaderparams.ram_size);
> > +    prom_set(prom_buf, prom_index++, "%lu", loaderparams.ram_size);
> > 
> >       prom_set(prom_buf, prom_index++, "modetty0");
> >       prom_set(prom_buf, prom_index++, "38400n8r");
> > @@ -1253,12 +1263,14 @@ void mips_malta_init(MachineState *machine)
> >       /* create CPU */
> >       mips_create_cpu(machine, s, &cbus_irq, &i8259_irq);
> > 
> > -    /* allocate RAM */
> > +#ifdef TARGET_MIPS32
> > +    /* MIPS32 won't accept more than 2GiB RAM due to limited address space */
> >       if (ram_size > 2 * GiB) {
> >           error_report("Too much memory for this machine: %" PRId64 "MB,"
> >                        " maximum 2048MB", ram_size / MiB);
> >           exit(1);
> >       }
> > +#endif
> > 
> >       /* register RAM at high address where it is undisturbed by IO */
> >       memory_region_add_subregion(system_memory, 0x80000000, machine->ram);
> > --
> > 2.25.1
> > 
> > 
> > 
> >   
>
diff mbox series

Patch

diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c
index 6e7ba9235d..de89cdcfc1 100644
--- a/hw/mips/mips_malta.c
+++ b/hw/mips/mips_malta.c
@@ -98,7 +98,8 @@  typedef struct {
 } MaltaState;
 
 static struct _loaderparams {
-    int ram_size, ram_low_size;
+    unsigned int ram_low_size;
+    ram_addr_t ram_size;
     const char *kernel_filename;
     const char *kernel_cmdline;
     const char *initrd_filename;
@@ -1023,6 +1024,7 @@  static int64_t load_kernel(void)
 {
     int64_t kernel_entry, kernel_high, initrd_size;
     long kernel_size;
+    char mem_cmdline[128];
     ram_addr_t initrd_offset;
     int big_endian;
     uint32_t *prom_buf;
@@ -1099,20 +1101,28 @@  static int64_t load_kernel(void)
     prom_buf = g_malloc(prom_size);
 
     prom_set(prom_buf, prom_index++, "%s", loaderparams.kernel_filename);
+
+    /*
+     * Always use cmdline to overwrite mem layout
+     * as kernel may reject large emesize.
+     */
+    sprintf(&mem_cmdline[0],
+        "mem=0x10000000@0x00000000 mem=0x%" PRIx64 "@0x90000000",
+        loaderparams.ram_size - 0x10000000);
     if (initrd_size > 0) {
         prom_set(prom_buf, prom_index++,
-                 "rd_start=0x%" PRIx64 " rd_size=%" PRId64 " %s",
-                 xlate_to_kseg0(NULL, initrd_offset),
+                 "%s rd_start=0x%" PRIx64 " rd_size=%" PRId64 " %s",
+                 &mem_cmdline[0], xlate_to_kseg0(NULL, initrd_offset),
                  initrd_size, loaderparams.kernel_cmdline);
     } else {
-        prom_set(prom_buf, prom_index++, "%s", loaderparams.kernel_cmdline);
+        prom_set(prom_buf, prom_index++, "%s %s",&mem_cmdline[0] ,loaderparams.kernel_cmdline);
     }
 
     prom_set(prom_buf, prom_index++, "memsize");
     prom_set(prom_buf, prom_index++, "%u", loaderparams.ram_low_size);
 
     prom_set(prom_buf, prom_index++, "ememsize");
-    prom_set(prom_buf, prom_index++, "%u", loaderparams.ram_size);
+    prom_set(prom_buf, prom_index++, "%lu", loaderparams.ram_size);
 
     prom_set(prom_buf, prom_index++, "modetty0");
     prom_set(prom_buf, prom_index++, "38400n8r");
@@ -1253,12 +1263,14 @@  void mips_malta_init(MachineState *machine)
     /* create CPU */
     mips_create_cpu(machine, s, &cbus_irq, &i8259_irq);
 
-    /* allocate RAM */
+#ifdef TARGET_MIPS32
+    /* MIPS32 won't accept more than 2GiB RAM due to limited address space */
     if (ram_size > 2 * GiB) {
         error_report("Too much memory for this machine: %" PRId64 "MB,"
                      " maximum 2048MB", ram_size / MiB);
         exit(1);
     }
+#endif
 
     /* register RAM at high address where it is undisturbed by IO */
     memory_region_add_subregion(system_memory, 0x80000000, machine->ram);