Skip to contentSkip to conversation

hw: fix to display correct memory size

PATCH In review Yongbok Kim 4 participants 6 messages Aug 23, 2013 – Aug 28, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw: fix to display correct memory size

A parenthesis placed inappropriately caused displaying wrong memory size bigger than 4GB.

---
 hw/mips/mips_malta.c  |    2 +-
 hw/mips/mips_r4k.c    |    2 +-
 hw/ppc/mac_oldworld.c |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
hw/mips/mips_malta.c +1 -1
index f8d064c..23ac1ca 100644
@@ -954,7 +954,7 @@ void mips_malta_init(QEMUMachineInitArgs *args)
     if (ram_size > (256 << 20)) {
         fprintf(stderr,
                 "qemu: Too much memory for this machine: %d MB, maximum 256 MB\n",
-                ((unsigned int)ram_size / (1 << 20)));
+                (unsigned int)(ram_size / (1 << 20)));
         exit(1);
     }
     memory_region_init_ram(ram, NULL, "mips_malta.ram", ram_size);
hw/mips/mips_r4k.c +1 -1
index 044f232..e8108ac 100644
@@ -201,7 +201,7 @@ void mips_r4k_init(QEMUMachineInitArgs *args)
     if (ram_size > (256 << 20)) {
         fprintf(stderr,
                 "qemu: Too much memory for this machine: %d MB, maximum 256 MB\n",
-                ((unsigned int)ram_size / (1 << 20)));
+                (unsigned int)(ram_size / (1 << 20)));
         exit(1);
     }
     memory_region_init_ram(ram, NULL, "mips_r4k.ram", ram_size);
hw/ppc/mac_oldworld.c +1 -1
index 42bb9d5..d7d1758 100644
@@ -124,7 +124,7 @@ static void ppc_heathrow_init(QEMUMachineInitArgs *args)
     if (ram_size > (2047 << 20)) {
         fprintf(stderr,
                 "qemu: Too much memory for this machine: %d MB, maximum 2047 MB\n",
-                ((unsigned int)ram_size / (1 << 20)));
+                (unsigned int)(ram_size / (1 << 20)));
         exit(1);
     }
 
Signature · 1 line
1.7.4
Reviewed-by on v1 1/1
#1 lore raw

Am 23.08.2013 16:57, schrieb Yongbok Kim:

Quoted 9 lines

A parenthesis placed inappropriately caused displaying wrong memory size bigger than 4GB.

---
 hw/mips/mips_malta.c  |    2 +-
 hw/mips/mips_r4k.c    |    2 +-
 hw/ppc/mac_oldworld.c |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

Thanks for fixing this even beyond MIPS machines!

In theory I would've preferred a patch using the correct format string and dropping the unsigned int cast completely, but our RAM_ADDR_FMT uses hexadecimal format, so:

hw/mips/mips_malta.c void mips_malta_init(QEMUMachineInitArgs *args) · line 957

Quoted 10 lines
hw/mips/mips_malta.c +1 -1
index f8d064c..23ac1ca 100644
@@ -954,7 +954,7 @@ void mips_malta_init(QEMUMachineInitArgs *args)
     if (ram_size > (256 << 20)) {
         fprintf(stderr,
                 "qemu: Too much memory for this machine: %d MB, maximum 256 MB\n",
-                ((unsigned int)ram_size / (1 << 20)));
+                (unsigned int)(ram_size / (1 << 20)));

Seeing that in the Malta case your other patch will trivially conflict with this bugfix, would you have time to turn it into a series of three patches, this being the first and adding "Cc: [email protected]" to its commit message for inclusion in 1.6.1, then an additional patch replacing fprintf(stderr, "qemu: ...\n", ...) with error_report("...", ...) (note no trailing \n and it will also automatically prefix the right qemu-system-mips* executable name) and finally your 2 GiB patch?

Regards,
Andreas

Quoted 30 lines
hw/mips/mips_malta.c +0 -0
         exit(1);
     }
     memory_region_init_ram(ram, NULL, "mips_malta.ram", ram_size);
hw/mips/mips_r4k.c +1 -1
index 044f232..e8108ac 100644
@@ -201,7 +201,7 @@ void mips_r4k_init(QEMUMachineInitArgs *args)
     if (ram_size > (256 << 20)) {
         fprintf(stderr,
                 "qemu: Too much memory for this machine: %d MB, maximum 256 MB\n",
-                ((unsigned int)ram_size / (1 << 20)));
+                (unsigned int)(ram_size / (1 << 20)));
         exit(1);
     }
     memory_region_init_ram(ram, NULL, "mips_r4k.ram", ram_size);
hw/ppc/mac_oldworld.c +1 -1
index 42bb9d5..d7d1758 100644
@@ -124,7 +124,7 @@ static void ppc_heathrow_init(QEMUMachineInitArgs *args)
     if (ram_size > (2047 << 20)) {
         fprintf(stderr,
                 "qemu: Too much memory for this machine: %d MB, maximum 2047 MB\n",
-                ((unsigned int)ram_size / (1 << 20)));
+                (unsigned int)(ram_size / (1 << 20)));
         exit(1);
     }
 
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#2 lore raw
Quoted 30 lines · Andreas Färber

Am 23.08.2013 16:57, schrieb Yongbok Kim:

Quoted 9 lines

A parenthesis placed inappropriately caused displaying wrong memory size bigger than 4GB.

---

hw/mips/mips_malta.c  |    2 +-
hw/mips/mips_r4k.c    |    2 +-
hw/ppc/mac_oldworld.c |    2 +-
3 files changed, 3 insertions(+), 3 deletions(-)

Thanks for fixing this even beyond MIPS machines!

In theory I would've preferred a patch using the correct format string and dropping the unsigned int cast completely, but our RAM_ADDR_FMT uses hexadecimal format, so:

hw/mips/mips_malta.c void mips_malta_init(QEMUMachineInitArgs *args) · line 957

Quoted 10 lines
hw/mips/mips_malta.c +1 -1
index f8d064c..23ac1ca 100644
@@ -954,7 +954,7 @@ void mips_malta_init(QEMUMachineInitArgs *args)
    if (ram_size > (256 << 20)) {
        fprintf(stderr,
                "qemu: Too much memory for this machine: %d MB, maximum 256 MB\n",
-                ((unsigned int)ram_size / (1 << 20)));
+                (unsigned int)(ram_size / (1 << 20)));
Quoted 7 lines

Seeing that in the Malta case your other patch will trivially conflict with this bugfix, would you have time to turn it into a series of three patches, this being the first and adding "Cc: [email protected]" to its commit message for inclusion in 1.6.1, then an additional patch replacing fprintf(stderr, "qemu: ...\n", ...) with error_report("...", ...) (note no trailing \n and it will also automatically prefix the right qemu-system-mips* executable name) and finally your 2 GiB patch?

Ah, saw this comment too late. Andreas' suggestions is obviously even better :).

Alex

#3 lore raw

Because this patch is not the critical, probably I can re-send this and the additional patches (Andreas' suggestion) as trivial patches when the 2GiB patch applied.

Regards,
Yongbok

-----Original Message-----
From: Alexander Graf [mailto:[email protected]]
Sent: 25 August 2013 17:12
To: Andreas Färber
Cc: Yongbok Kim; [email protected]; Leon Alrae; [email protected]; [email protected]
Subject: Re: [Qemu-devel] [PATCH] hw: fix to display correct memory size

Quoted 30 lines · Andreas Färber

Am 23.08.2013 16:57, schrieb Yongbok Kim:

Quoted 9 lines

A parenthesis placed inappropriately caused displaying wrong memory size bigger than 4GB.

---

hw/mips/mips_malta.c  |    2 +-
hw/mips/mips_r4k.c    |    2 +-
hw/ppc/mac_oldworld.c |    2 +-
3 files changed, 3 insertions(+), 3 deletions(-)

Thanks for fixing this even beyond MIPS machines!

In theory I would've preferred a patch using the correct format string and dropping the unsigned int cast completely, but our RAM_ADDR_FMT uses hexadecimal format, so:

hw/mips/mips_malta.c void mips_malta_init(QEMUMachineInitArgs *args) · line 957

Quoted 10 lines
hw/mips/mips_malta.c index renamed from hw/mips/mips_malta.c +0 -0

f8d064c..23ac1ca 100644

hw/mips/mips_malta.c +1 -1
@@ -954,7 +954,7 @@ void mips_malta_init(QEMUMachineInitArgs *args)
    if (ram_size > (256 << 20)) {
        fprintf(stderr,
                "qemu: Too much memory for this machine: %d MB, maximum 256 MB\n",
-                ((unsigned int)ram_size / (1 << 20)));
+                (unsigned int)(ram_size / (1 << 20)));
Quoted 8 lines

Seeing that in the Malta case your other patch will trivially conflict with this bugfix, would you have time to turn it into a series of three patches, this being the first and adding "Cc:
[email protected]" to its commit message for inclusion in 1.6.1, then an additional patch replacing fprintf(stderr, "qemu: ...\n", ...) with error_report("...",
...) (note no trailing \n and it will also automatically prefix the right qemu-system-mips* executable name) and finally your 2 GiB patch?

Ah, saw this comment too late. Andreas' suggestions is obviously even better :).

Alex

Acked-by on v1 1/1
#4 lore raw
In reply to Yongbok Kim
Quoted 4 lines · Yongbok Kim

A parenthesis placed inappropriately caused displaying wrong memory size bigger than 4GB.

I think this should easily go in through the qemu-trivial queue.

Alex

Quoted 49 lines

---

hw/mips/mips_malta.c  |    2 +-
hw/mips/mips_r4k.c    |    2 +-
hw/ppc/mac_oldworld.c |    2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
hw/mips/mips_malta.c +1 -1
index f8d064c..23ac1ca 100644
@@ -954,7 +954,7 @@ void mips_malta_init(QEMUMachineInitArgs *args)
    if (ram_size > (256 << 20)) {
        fprintf(stderr,
                "qemu: Too much memory for this machine: %d MB, maximum 256 MB\n",
-                ((unsigned int)ram_size / (1 << 20)));
+                (unsigned int)(ram_size / (1 << 20)));
        exit(1);
    }
    memory_region_init_ram(ram, NULL, "mips_malta.ram", ram_size);
hw/mips/mips_r4k.c +1 -1
index 044f232..e8108ac 100644
@@ -201,7 +201,7 @@ void mips_r4k_init(QEMUMachineInitArgs *args)
    if (ram_size > (256 << 20)) {
        fprintf(stderr,
                "qemu: Too much memory for this machine: %d MB, maximum 256 MB\n",
-                ((unsigned int)ram_size / (1 << 20)));
+                (unsigned int)(ram_size / (1 << 20)));
        exit(1);
    }
    memory_region_init_ram(ram, NULL, "mips_r4k.ram", ram_size);
hw/ppc/mac_oldworld.c +1 -1
index 42bb9d5..d7d1758 100644
@@ -124,7 +124,7 @@ static void ppc_heathrow_init(QEMUMachineInitArgs *args)
    if (ram_size > (2047 << 20)) {
        fprintf(stderr,
                "qemu: Too much memory for this machine: %d MB, maximum 2047 MB\n",
-                ((unsigned int)ram_size / (1 << 20)));
+                (unsigned int)(ram_size / (1 << 20)));
        exit(1);
    }
 
Signature · 1 line
1.7.4
Acked-by on v1 1/1
#5 lore raw
In reply to Yongbok Kim
Quoted 41 lines · Yongbok Kim

A parenthesis placed inappropriately caused displaying wrong memory size bigger than 4GB.

---
 hw/mips/mips_malta.c  |    2 +-
 hw/mips/mips_r4k.c    |    2 +-
 hw/ppc/mac_oldworld.c |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
hw/mips/mips_malta.c +1 -1
index f8d064c..23ac1ca 100644
@@ -954,7 +954,7 @@ void mips_malta_init(QEMUMachineInitArgs *args)
     if (ram_size > (256 << 20)) {
         fprintf(stderr,
                 "qemu: Too much memory for this machine: %d MB, maximum 256 MB\n",
-                ((unsigned int)ram_size / (1 << 20)));
+                (unsigned int)(ram_size / (1 << 20)));
         exit(1);
     }
     memory_region_init_ram(ram, NULL, "mips_malta.ram", ram_size);
hw/mips/mips_r4k.c +1 -1
index 044f232..e8108ac 100644
@@ -201,7 +201,7 @@ void mips_r4k_init(QEMUMachineInitArgs *args)
     if (ram_size > (256 << 20)) {
         fprintf(stderr,
                 "qemu: Too much memory for this machine: %d MB, maximum 256 MB\n",
-                ((unsigned int)ram_size / (1 << 20)));
+                (unsigned int)(ram_size / (1 << 20)));
         exit(1);
     }
     memory_region_init_ram(ram, NULL, "mips_r4k.ram", ram_size);
hw/ppc/mac_oldworld.c +0 -0
index 42bb9d5..d7d1758 100644

hw/ppc/mac_oldworld.c static void ppc_heathrow_init(QEMUMachineInitArgs *args) · line 129

Quoted 7 lines
hw/ppc/mac_oldworld.c +1 -1
@@ -124,7 +124,7 @@ static void ppc_heathrow_init(QEMUMachineInitArgs *args)
     if (ram_size > (2047 << 20)) {
         fprintf(stderr,
                 "qemu: Too much memory for this machine: %d MB, maximum 2047 MB\n",
-                ((unsigned int)ram_size / (1 << 20)));
+                (unsigned int)(ram_size / (1 << 20)));
         exit(1);
     }

For the MIPS part:

But as already said, it's probably better to wait for the Malta 2GB patch to be merged first and send it to the trivial patches queue.

Signature · 2 lines
Aurelien Jarno                          GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net