Skip to contentSkip to conversation

PPC: e500: correct params->ram_size with ram_size

PATCH Superseded Tiejun Chen 4 participants 11 messages Apr 28, 2013 – May 1, 2013

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PPC: e500: correct params->ram_size with ram_size

We should sync params->ram_size after we fixup memory size on a alignment boundary. Otherwise Guest would exceed the actual memory region.

---
 hw/ppc/e500.c |    2 ++
 1 file changed, 2 insertions(+)
hw/ppc/e500.c +2 -0
index c1bdb6b..145da0e 100644
@@ -523,6 +523,8 @@ void ppce500_init(PPCE500Params *params)
 
     /* Fixup Memory size on a alignment boundary */
     ram_size &= ~(RAM_SIZES_ALIGN - 1);
+    /* Sync this for the system. */
+    params->ram_size = ram_size;
 
     /* Register Memory */
     memory_region_init_ram(ram, "mpc8544ds.ram", ram_size);
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 14 lines · Tiejun Chen

We should sync params->ram_size after we fixup memory size on a alignment boundary. Otherwise Guest would exceed the actual memory region.

---
 hw/ppc/e500.c |    2 ++
 1 file changed, 2 insertions(+)
hw/ppc/e500.c +0 -0
index c1bdb6b..145da0e 100644

hw/ppc/e500.c void ppce500_init(PPCE500Params *params) · line 527

Quoted 5 lines
hw/ppc/e500.c +2 -0
@@ -523,6 +523,8 @@ void ppce500_init(PPCE500Params *params)
 
     /* Fixup Memory size on a alignment boundary */
     ram_size &= ~(RAM_SIZES_ALIGN - 1);
+    /* Sync this for the system. */
+    params->ram_size = ram_size;

Could you explain this further? When does params->ram_size ever get used after this point?

-Scott

#2 lore raw
Quoted 11 lines · Scott Wood
Quoted 10 lines · Tiejun Chen

We should sync params->ram_size after we fixup memory size on a alignment boundary. Otherwise Guest would exceed the actual memory region.

---
hw/ppc/e500.c | 2 ++

1 file changed, 2 insertions(+)
hw/ppc/e500.c +0 -1
index c1bdb6b..145da0e 100644
--- a/hw/ppc/e500.c
Quoted 8 lines

hw/ppc/e500.c void ppce500_init(PPCE500Params *params) · line 526

Quoted 6 lines

+++ b/hw/ppc/e500.c

hw/ppc/e500.c +2 -0
@@ -523,6 +523,8 @@ void ppce500_init(PPCE500Params *params)
    /* Fixup Memory size on a alignment boundary */
    ram_size &= ~(RAM_SIZES_ALIGN - 1);
+    /* Sync this for the system. */
+    params->ram_size = ram_size;

Could you explain this further? When does params->ram_size ever get used after this point?

This is the respective code in vl.c:

Quoted 9 lines

QEMUMachineInitArgs args = { .ram_size = ram_size,
.boot_device = (boot_devices[0] == '\0') ?
machine->boot_order :
boot_devices,
.kernel_filename = kernel_filename, .kernel_cmdline = kernel_cmdline, .initrd_filename = initrd_filename, .cpu_model = cpu_model };
machine->init(&args);

After this, args in unused. So as you can see, params->ram_size never gets used after it's read once.

What bug are you trying to fix? Maybe there really is something broken here, that this patch doesn't fix either.

Alex

#3 lore raw

Am 30.04.2013 11:53, schrieb Alexander Graf:

Quoted 36 lines · Scott Wood
Quoted 12 lines · Tiejun Chen
Quoted 10 lines

We should sync params->ram_size after we fixup memory size on a alignment boundary. Otherwise Guest would exceed the actual memory region.

---
hw/ppc/e500.c | 2 ++

1 file changed, 2 insertions(+)
hw/ppc/e500.c +0 -1
index c1bdb6b..145da0e 100644
--- a/hw/ppc/e500.c
Quoted 8 lines

hw/ppc/e500.c void ppce500_init(PPCE500Params *params) · line 526

Quoted 6 lines

+++ b/hw/ppc/e500.c

hw/ppc/e500.c +2 -0
@@ -523,6 +523,8 @@ void ppce500_init(PPCE500Params *params)
    /* Fixup Memory size on a alignment boundary */
    ram_size &= ~(RAM_SIZES_ALIGN - 1);
+    /* Sync this for the system. */
+    params->ram_size = ram_size;

Could you explain this further? When does params->ram_size ever get used after this point?

This is the respective code in vl.c:

Quoted 9 lines

QEMUMachineInitArgs args = { .ram_size = ram_size,
.boot_device = (boot_devices[0] == '\0') ?
machine->boot_order :
boot_devices,
.kernel_filename = kernel_filename, .kernel_cmdline = kernel_cmdline, .initrd_filename = initrd_filename, .cpu_model = cpu_model };
machine->init(&args);

Quoted 1 line

After this, args in unused. So as you can see, params->ram_size never gets used after it's read once.

While that is true, it was being discussed to update cpu_model inside QEMUMachineInitArgs FWIW. That's independent of PPCE500Params though.

Andreas

Quoted 4 lines

What bug are you trying to fix? Maybe there really is something broken here, that this patch doesn't fix either.

Alex

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
#4 lore raw
In reply to Alexander Graf
Quoted 47 lines

-----Original Message-----
From: Alexander Graf [mailto:[email protected]]
Sent: Tuesday, April 30, 2013 5:53 PM
To: Scott Wood
Cc: Chen, Tiejun; [email protected]; [email protected]
Subject: Re: [Qemu-ppc] [v1][PATCH 1/1] PPC: e500: correct params->ram_size with ram_size

Quoted 11 lines · Scott Wood
Quoted 10 lines · Tiejun Chen

We should sync params->ram_size after we fixup memory size on a alignment boundary. Otherwise Guest would exceed the actual memory region.

---
hw/ppc/e500.c | 2 ++

1 file changed, 2 insertions(+)
hw/ppc/e500.c index c1bdb6b..145da0e renamed from hw/ppc/e500.c +0 -0

100644
--- a/hw/ppc/e500.c

Quoted 8 lines

hw/ppc/e500.c index c1bdb6b..145da0e void ppce500_init(PPCE500Params *params) · line 526

Quoted 6 lines

+++ b/hw/ppc/e500.c

hw/ppc/e500.c index c1bdb6b..145da0e renamed from hw/ppc/e500.c +2 -0
@@ -523,6 +523,8 @@ void ppce500_init(PPCE500Params *params)
    /* Fixup Memory size on a alignment boundary */
    ram_size &= ~(RAM_SIZES_ALIGN - 1);
+    /* Sync this for the system. */
+    params->ram_size = ram_size;

Could you explain this further? When does params->ram_size

ever get used after this point?

This is the respective code in vl.c:

Quoted 2 lines

QEMUMachineInitArgs args = { .ram_size = ram_size,
.boot_device =

(boot_devices[0] == '\0') ?

Quoted 1 line

machine->boot_order :

Quoted 6 lines

boot_devices,
.kernel_filename = kernel_filename, .kernel_cmdline = kernel_cmdline, .initrd_filename = initrd_filename, .cpu_model = cpu_model };
machine->init(&args);

Quoted 4 lines

After this, args in unused. So as you can see, params->ram_size never gets used after it's read once.

What bug are you trying to fix? Maybe there really is

I had an explanation when I reply to Scott, could you take a look at that?

If you have no further objection, I'd like to send next version with withdrawing that comment as Scott suggest.

Tiejun

#5 lore raw
Quoted 47 lines · Tiejun
Quoted 47 lines

-----Original Message-----
From: Alexander Graf [mailto:[email protected]]
Sent: Tuesday, April 30, 2013 5:53 PM
To: Scott Wood
Cc: Chen, Tiejun; [email protected]; [email protected]
Subject: Re: [Qemu-ppc] [v1][PATCH 1/1] PPC: e500: correct params->ram_size with ram_size

Quoted 11 lines · Scott Wood
Quoted 10 lines · Tiejun Chen

We should sync params->ram_size after we fixup memory size on a alignment boundary. Otherwise Guest would exceed the actual memory region.

---
hw/ppc/e500.c | 2 ++

1 file changed, 2 insertions(+)
hw/ppc/e500.c index c1bdb6b..145da0e renamed from hw/ppc/e500.c +0 -0

100644
--- a/hw/ppc/e500.c

Quoted 8 lines

hw/ppc/e500.c index c1bdb6b..145da0e void ppce500_init(PPCE500Params *params) · line 526

Quoted 6 lines

+++ b/hw/ppc/e500.c

hw/ppc/e500.c index c1bdb6b..145da0e renamed from hw/ppc/e500.c +2 -0
@@ -523,6 +523,8 @@ void ppce500_init(PPCE500Params *params)
   /* Fixup Memory size on a alignment boundary */
   ram_size &= ~(RAM_SIZES_ALIGN - 1);
+    /* Sync this for the system. */
+    params->ram_size = ram_size;

Could you explain this further? When does params->ram_size

ever get used after this point?

This is the respective code in vl.c:

Quoted 2 lines

QEMUMachineInitArgs args = { .ram_size = ram_size,
.boot_device =

(boot_devices[0] == '\0') ?

Quoted 1 line

machine->boot_order :

Quoted 6 lines

boot_devices,
.kernel_filename = kernel_filename, .kernel_cmdline = kernel_cmdline, .initrd_filename = initrd_filename, .cpu_model = cpu_model };
machine->init(&args);

Quoted 6 lines
Quoted 4 lines

After this, args in unused. So as you can see, params->ram_size never gets used after it's read once.

What bug are you trying to fix? Maybe there really is

I had an explanation when I reply to Scott, could you take a look at that?

I think it makes sense.

Quoted 1 line

If you have no further objection, I'd like to send next version with withdrawing that comment as Scott suggest.

Yes, please :)

Alex

#6 lore raw
In reply to Scott Wood
Quoted 24 lines

-----Original Message-----
From: Scott Wood [mailto:[email protected]]
Sent: Tuesday, April 30, 2013 3:19 AM
To: Chen, Tiejun
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [Qemu-ppc] [v1][PATCH 1/1] PPC: e500: correct params->ram_size with ram_size

Quoted 15 lines · Tiejun Chen

We should sync params->ram_size after we fixup memory size on a alignment boundary. Otherwise Guest would exceed the actual memory region.

---
 hw/ppc/e500.c |    2 ++
 1 file changed, 2 insertions(+)
hw/ppc/e500.c index c1bdb6b..145da0e renamed from hw/ppc/e500.c +0 -0

100644

hw/ppc/e500.c +0 -0
@@ -523,6 +523,8 @@ void ppce500_init(PPCE500Params *params)
 
Quoted 7 lines

hw/ppc/e500.c void ppce500_init(PPCE500Params *params) · line 527

Quoted 4 lines
hw/ppc/e500.c +2 -0
     /* Fixup Memory size on a alignment boundary */
     ram_size &= ~(RAM_SIZES_ALIGN - 1);
+    /* Sync this for the system. */
+    params->ram_size = ram_size;

Could you explain this further? When does params->ram_size ever get used after this point?

In that case we have to create a dtb without passing an extra dtb, we always use params->ram_size inside ppce500_load_device_tree(),

ppce500_load_device_tree()
{
...
uint64_t mem_reg_property[] = { 0, cpu_to_be64(params->ram_size) };
...
qemu_devtree_setprop(fdt, "/memory", "reg", mem_reg_property, sizeof(mem_reg_property));

So occasionally if we don't pass a aligned memory size with "-m" like "-m 500", then Guest still think it owns 500M but we register memory with ram_size actually,

ppce500_init()
{
...
/* Fixup Memory size on a alignment boundary */
ram_size &= ~(RAM_SIZES_ALIGN - 1); ==> 448M

/* Register Memory */ memory_region_init_ram(ram, "mpc8544ds.ram", ram_size);

Guest would trigger TLB error when Guest allocate to access somewhere between 448M and 500M, its always failed since KVM hasn't that memory slot at all.

So we need to sync params->ram_size with ram_size.

Tiejun

#7 lore raw
Quoted 32 lines · Tiejun
Quoted 24 lines

-----Original Message-----
From: Scott Wood [mailto:[email protected]]
Sent: Tuesday, April 30, 2013 3:19 AM
To: Chen, Tiejun
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [Qemu-ppc] [v1][PATCH 1/1] PPC: e500: correct params->ram_size with ram_size

Quoted 15 lines · Tiejun Chen

We should sync params->ram_size after we fixup memory size on a alignment boundary. Otherwise Guest would exceed the actual memory region.

---
 hw/ppc/e500.c |    2 ++
 1 file changed, 2 insertions(+)
hw/ppc/e500.c index c1bdb6b..145da0e renamed from hw/ppc/e500.c +0 -0

100644

hw/ppc/e500.c +0 -0
@@ -523,6 +523,8 @@ void ppce500_init(PPCE500Params *params)
 
Quoted 7 lines

hw/ppc/e500.c void ppce500_init(PPCE500Params *params) · line 527

Quoted 4 lines
hw/ppc/e500.c +2 -0
     /* Fixup Memory size on a alignment boundary */
     ram_size &= ~(RAM_SIZES_ALIGN - 1);
+    /* Sync this for the system. */
+    params->ram_size = ram_size;

Could you explain this further? When does params->ram_size ever get used after this point?

Quoted 6 lines

In that case we have to create a dtb without passing an extra dtb, we always use params->ram_size inside ppce500_load_device_tree(),

ppce500_load_device_tree()
{
...
uint64_t mem_reg_property[] = { 0, cpu_to_be64(params->ram_size) };

OK, from reading the patch it looked like this was happening before you modify params->ram_size, but it's a separate function that gets called later. The comment doesn't make much sense to me -- it's not passing any information back to "the system" (which I'd interpret as generic QEMU code, if anything, which is why I thought you were trying to do this for the benefit of the caller), just making sure later e500 platform code does the right thing when generating the device tree.

-Scott

#8 lore raw
Quoted 48 lines

-----Original Message-----
From: Scott Wood [mailto:[email protected]]
Sent: Wednesday, May 01, 2013 7:09 AM
To: Chen, Tiejun
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [Qemu-ppc] [v1][PATCH 1/1] PPC: e500: correct params->ram_size with ram_size

Quoted 11 lines · Tiejun
Quoted 11 lines

-----Original Message-----
From: Scott Wood [mailto:[email protected]]
Sent: Tuesday, April 30, 2013 3:19 AM
To: Chen, Tiejun
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [Qemu-ppc] [v1][PATCH 1/1] PPC: e500: correct params->ram_size with ram_size

Quoted 2 lines · Tiejun Chen

We should sync params->ram_size after we fixup memory size on a alignment boundary. Otherwise Guest would exceed the

actual memory

Quoted 8 lines
Quoted 8 lines

hw/ppc/e500.c index

Quoted 8 lines

region.

---
 hw/ppc/e500.c |    2 ++
 1 file changed, 2 insertions(+)
hw/ppc/e500.c index renamed from hw/ppc/e500.c +0 -0

c1bdb6b..145da0e

Quoted 11 lines
Quoted 11 lines

hw/ppc/e500.c void ppce500_init(PPCE500Params *params) · line 527

Quoted 9 lines

100644

hw/ppc/e500.c +2 -0
@@ -523,6 +523,8 @@ void ppce500_init(PPCE500Params *params)
 
     /* Fixup Memory size on a alignment boundary */
     ram_size &= ~(RAM_SIZES_ALIGN - 1);
+    /* Sync this for the system. */
+    params->ram_size = ram_size;

Could you explain this further? When does

params->ram_size ever get

Quoted 3 lines
Quoted 1 line

used after this point?

In that case we have to create a dtb without passing an

extra dtb, we

Quoted 2 lines

always use params->ram_size inside ppce500_load_device_tree(),

Quoted 7 lines
Quoted 4 lines

ppce500_load_device_tree()
{
...
uint64_t mem_reg_property[] = { 0, cpu_to_be64(params->ram_size) };

OK, from reading the patch it looked like this was happening before you modify params->ram_size, but it's a separate

Yes.

Quoted 1 line

function that gets called later. The comment doesn't make

Are you saying I should replace cpu_to_be64(params->ram_size) with cpu_to_be64(ram_size) directly in ppce500_load_device_tree()?

But as I understand we should sync this global argument after we fixup something associated to that since params->ram_size may impact on something else in the future.

Tiejun

Quoted 8 lines

much sense to me -- it's not passing any information back to "the system" (which I'd interpret as generic QEMU code, if anything, which is why I thought you were trying to do this for the benefit of the caller), just making sure later e500 platform code does the right thing when generating the device tree.

-Scott

#9 lore raw
Quoted 3 lines · Tiejun
Quoted 1 line

function that gets called later. The comment doesn't make

Are you saying I should replace cpu_to_be64(params->ram_size) with cpu_to_be64(ram_size) directly in ppce500_load_device_tree()?

No, I'm saying to reword (or eliminate) the confusing comment.

Quoted 1 line

But as I understand we should sync this global argument after we fixup something associated to that since params->ram_size may impact on something else in the future.

...and we just hope that nothing uses it for anything important before the fixup. :-P

-Scott

#10 lore raw
Quoted 8 lines

-----Original Message-----
From: Scott Wood [mailto:[email protected]]
Sent: Wednesday, May 01, 2013 7:36 AM
To: Chen, Tiejun
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [Qemu-ppc] [v1][PATCH 1/1] PPC: e500: correct params->ram_size with ram_size

Quoted 7 lines
Quoted 4 lines · Tiejun
Quoted 1 line

function that gets called later. The comment doesn't make

Are you saying I should replace cpu_to_be64(params->ram_size) with cpu_to_be64(ram_size) directly in ppce500_load_device_tree()?

No, I'm saying to reword (or eliminate) the confusing comment.

Okay, I prefer to eliminate that comment since the code itself is clear enough.

Thanks,

Tiejun

Quoted 11 lines
Quoted 2 lines

But as I understand we should sync this global argument

after we fixup

Quoted 2 lines

something associated to that since params->ram_size may impact on something else in the future.

...and we just hope that nothing uses it for anything important before the fixup. :-P

-Scott