Skip to contentSkip to conversation

pc: Fix initialization of the ram_memory variable.

PATCH In review Anthony PERARD 5 participants 15 messages Aug 16, 2013 – Aug 29, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pc: Fix initialization of the ram_memory variable.

In some cases (Xen), it will not be initialized before to be used. This leads to segv.

---

It works with this simple initialization to NULL, but would it be necessary (or better) to assign a proper value to this variables ?

---
 hw/i386/pc_piix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/pc_piix.c +1 -1
index 6e1e654..596d433 100644
@@ -86,7 +86,7 @@ static void pc_init1(MemoryRegion *system_memory,
     BusState *idebus[MAX_IDE_BUS];
     ISADevice *rtc_state;
     ISADevice *floppy;
-    MemoryRegion *ram_memory;
+    MemoryRegion *ram_memory = NULL;
     MemoryRegion *pci_memory;
     MemoryRegion *rom_memory;
     DeviceState *icc_bridge;
Signature · 1 line
Anthony PERARD
Tested-by on v1 1/1
#1 lore raw

Il 16/08/2013 16:46, Anthony PERARD ha scritto:

Quoted 4 lines

In some cases (Xen), it will not be initialized before to be used. This leads to segv.

This patch have solved the critical regression of all hvm domUs that prevented domUs starting with qemu 1.6.

Quoted 22 lines

---

It works with this simple initialization to NULL, but would it be necessary (or better) to assign a proper value to this variables ?

---
  hw/i386/pc_piix.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/pc_piix.c +1 -1
index 6e1e654..596d433 100644
@@ -86,7 +86,7 @@ static void pc_init1(MemoryRegion *system_memory,
      BusState *idebus[MAX_IDE_BUS];
      ISADevice *rtc_state;
      ISADevice *floppy;
-    MemoryRegion *ram_memory;
+    MemoryRegion *ram_memory = NULL;
      MemoryRegion *pci_memory;
      MemoryRegion *rom_memory;
      DeviceState *icc_bridge;
Tested-by on v1 1/1
#2 lore raw
In reply to Anthony PERARD

Il 16/08/2013 16:46, Anthony PERARD ha scritto:

Quoted 4 lines

In some cases (Xen), it will not be initialized before to be used. This leads to segv.

This patch have solved the critical regression of all hvm domUs that prevented domUs starting with qemu 1.6.

Quoted 22 lines

---

It works with this simple initialization to NULL, but would it be necessary (or better) to assign a proper value to this variables ?

---
  hw/i386/pc_piix.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/pc_piix.c +1 -1
index 6e1e654..596d433 100644
@@ -86,7 +86,7 @@ static void pc_init1(MemoryRegion *system_memory,
      BusState *idebus[MAX_IDE_BUS];
      ISADevice *rtc_state;
      ISADevice *floppy;
-    MemoryRegion *ram_memory;
+    MemoryRegion *ram_memory = NULL;
      MemoryRegion *pci_memory;
      MemoryRegion *rom_memory;
      DeviceState *icc_bridge;
#3 lore raw

Il 26/08/2013 17:00, Fabio Fantoni ha scritto:

Quoted 9 lines

Il 16/08/2013 16:46, Anthony PERARD ha scritto:

Quoted 4 lines

In some cases (Xen), it will not be initialized before to be used. This leads to segv.

This patch have solved the critical regression of all hvm domUs that prevented domUs starting with qemu 1.6.

I not see this patch on git for now, I think is urgent apply this patch or solve the problem in other way because qemu 1.6 is unusable at all for hvm domUs on xen and 1.5.x doesn't works with hvm domUs with ram > 2gb, with qemu 1.6 the regression of > 2 gb ram is solved but without this patch doesn't works at all. Thanks for any reply and sorry for my bad english.

Quoted 23 lines
Quoted 22 lines

---

It works with this simple initialization to NULL, but would it be necessary (or better) to assign a proper value to this variables ?

---
  hw/i386/pc_piix.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/pc_piix.c +1 -1
index 6e1e654..596d433 100644
@@ -86,7 +86,7 @@ static void pc_init1(MemoryRegion *system_memory,
      BusState *idebus[MAX_IDE_BUS];
      ISADevice *rtc_state;
      ISADevice *floppy;
-    MemoryRegion *ram_memory;
+    MemoryRegion *ram_memory = NULL;
      MemoryRegion *pci_memory;
      MemoryRegion *rom_memory;
      DeviceState *icc_bridge;
#4 lore raw
In reply to Fabio Fantoni

Il 26/08/2013 17:00, Fabio Fantoni ha scritto:

Quoted 9 lines

Il 16/08/2013 16:46, Anthony PERARD ha scritto:

Quoted 4 lines

In some cases (Xen), it will not be initialized before to be used. This leads to segv.

This patch have solved the critical regression of all hvm domUs that prevented domUs starting with qemu 1.6.

I not see this patch on git for now, I think is urgent apply this patch or solve the problem in other way because qemu 1.6 is unusable at all for hvm domUs on xen and 1.5.x doesn't works with hvm domUs with ram > 2gb, with qemu 1.6 the regression of > 2 gb ram is solved but without this patch doesn't works at all. Thanks for any reply and sorry for my bad english.

Quoted 23 lines
Quoted 22 lines

---

It works with this simple initialization to NULL, but would it be necessary (or better) to assign a proper value to this variables ?

---
  hw/i386/pc_piix.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/pc_piix.c +1 -1
index 6e1e654..596d433 100644
@@ -86,7 +86,7 @@ static void pc_init1(MemoryRegion *system_memory,
      BusState *idebus[MAX_IDE_BUS];
      ISADevice *rtc_state;
      ISADevice *floppy;
-    MemoryRegion *ram_memory;
+    MemoryRegion *ram_memory = NULL;
      MemoryRegion *pci_memory;
      MemoryRegion *rom_memory;
      DeviceState *icc_bridge;
#5 lore raw
Quoted 12 lines · Fabio Fantoni

Il 26/08/2013 17:00, Fabio Fantoni ha scritto:

Quoted 10 lines

Il 16/08/2013 16:46, Anthony PERARD ha scritto:

Quoted 4 lines

In some cases (Xen), it will not be initialized before to be used. This leads to segv.

This patch have solved the critical regression of all hvm domUs that prevented domUs starting with qemu 1.6.

Quoted 6 lines

I not see this patch on git for now, I think is urgent apply this patch or solve the problem in other way because qemu 1.6 is unusable at all for hvm domUs on xen and 1.5.x doesn't works with hvm domUs with ram > 2gb, with qemu 1.6 the regression of > 2 gb ram is solved but without this patch doesn't works at all.
Thanks for any reply and sorry for my bad english.

Sorry, you are right. I know about this patch, it's in my queue. I haven't had the time to send it upstream yet.

#6 lore raw
In reply to Fabio Fantoni
Quoted 12 lines · Fabio Fantoni

Il 26/08/2013 17:00, Fabio Fantoni ha scritto:

Quoted 10 lines

Il 16/08/2013 16:46, Anthony PERARD ha scritto:

Quoted 4 lines

In some cases (Xen), it will not be initialized before to be used. This leads to segv.

This patch have solved the critical regression of all hvm domUs that prevented domUs starting with qemu 1.6.

Quoted 6 lines

I not see this patch on git for now, I think is urgent apply this patch or solve the problem in other way because qemu 1.6 is unusable at all for hvm domUs on xen and 1.5.x doesn't works with hvm domUs with ram > 2gb, with qemu 1.6 the regression of > 2 gb ram is solved but without this patch doesn't works at all.
Thanks for any reply and sorry for my bad english.

Sorry, you are right. I know about this patch, it's in my queue. I haven't had the time to send it upstream yet.

#7 lore raw
Quoted 20 lines · Stefano Stabellini
Quoted 12 lines · Fabio Fantoni

Il 26/08/2013 17:00, Fabio Fantoni ha scritto:

Quoted 10 lines

Il 16/08/2013 16:46, Anthony PERARD ha scritto:

Quoted 4 lines

In some cases (Xen), it will not be initialized before to be used. This leads to segv.

This patch have solved the critical regression of all hvm domUs that prevented domUs starting with qemu 1.6.

Quoted 6 lines

I not see this patch on git for now, I think is urgent apply this patch or solve the problem in other way because qemu 1.6 is unusable at all for hvm domUs on xen and 1.5.x doesn't works with hvm domUs with ram > 2gb, with qemu 1.6 the regression of > 2 gb ram is solved but without this patch doesn't works at all.
Thanks for any reply and sorry for my bad english.

Quoted 2 lines

Sorry, you are right. I know about this patch, it's in my queue. I haven't had the time to send it upstream yet.

And by that, I mean I haven't looked at it yet, even though I know it solves an outstanding issue. It might not be the right fix, as Peter suggested.

#8 lore raw
In reply to Stefano Stabellini
Quoted 20 lines · Stefano Stabellini
Quoted 12 lines · Fabio Fantoni

Il 26/08/2013 17:00, Fabio Fantoni ha scritto:

Quoted 10 lines

Il 16/08/2013 16:46, Anthony PERARD ha scritto:

Quoted 4 lines

In some cases (Xen), it will not be initialized before to be used. This leads to segv.

This patch have solved the critical regression of all hvm domUs that prevented domUs starting with qemu 1.6.

Quoted 6 lines

I not see this patch on git for now, I think is urgent apply this patch or solve the problem in other way because qemu 1.6 is unusable at all for hvm domUs on xen and 1.5.x doesn't works with hvm domUs with ram > 2gb, with qemu 1.6 the regression of > 2 gb ram is solved but without this patch doesn't works at all.
Thanks for any reply and sorry for my bad english.

Quoted 2 lines

Sorry, you are right. I know about this patch, it's in my queue. I haven't had the time to send it upstream yet.

And by that, I mean I haven't looked at it yet, even though I know it solves an outstanding issue. It might not be the right fix, as Peter suggested.

#9 lore raw
In reply to Anthony PERARD
Quoted 9 lines · Anthony PERARD

In some cases (Xen), it will not be initialized before to be used. This leads to segv.

---

It works with this simple initialization to NULL, but would it be necessary (or better) to assign a proper value to this variables ?

Yes, is this really the right fix? I raised this before 1.6 came out (since clang complains about it):
http://lists.gnu.org/archive/html/qemu-devel/2013-07/msg05383.html
(though I see I got the sense of the conditional wrong in the subject line of that mail)

and Stefano suggested the right fix was more complicated than just passing NULL. Also IIRC if you follow the variable down then it eventually gets actually used by code, so just passing NULL sounds wrong.

thanks
-- PMM

#10 lore raw
In reply to Anthony PERARD
Quoted 9 lines · Anthony PERARD

In some cases (Xen), it will not be initialized before to be used. This leads to segv.

---

It works with this simple initialization to NULL, but would it be necessary (or better) to assign a proper value to this variables ?

Yes, is this really the right fix? I raised this before 1.6 came out (since clang complains about it):
http://lists.gnu.org/archive/html/qemu-devel/2013-07/msg05383.html
(though I see I got the sense of the conditional wrong in the subject line of that mail)

and Stefano suggested the right fix was more complicated than just passing NULL. Also IIRC if you follow the variable down then it eventually gets actually used by code, so just passing NULL sounds wrong.

thanks
-- PMM

#11 lore raw
In reply to Anthony PERARD

Il 16/08/2013 16:46, Anthony PERARD ha scritto:

Quoted 9 lines

In some cases (Xen), it will not be initialized before to be used. This leads to segv.

---

It works with this simple initialization to NULL, but would it be necessary (or better) to assign a proper value to this variables ?

Yeah, the right value of this variable comes from xen_ram_init (called by xen_hvm_init).

Paolo

Quoted 18 lines
---
 hw/i386/pc_piix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/pc_piix.c +1 -1
index 6e1e654..596d433 100644
@@ -86,7 +86,7 @@ static void pc_init1(MemoryRegion *system_memory,
     BusState *idebus[MAX_IDE_BUS];
     ISADevice *rtc_state;
     ISADevice *floppy;
-    MemoryRegion *ram_memory;
+    MemoryRegion *ram_memory = NULL;
     MemoryRegion *pci_memory;
     MemoryRegion *rom_memory;
     DeviceState *icc_bridge;
#12 lore raw
In reply to Anthony PERARD

Il 16/08/2013 16:46, Anthony PERARD ha scritto:

Quoted 9 lines

In some cases (Xen), it will not be initialized before to be used. This leads to segv.

---

It works with this simple initialization to NULL, but would it be necessary (or better) to assign a proper value to this variables ?

Yeah, the right value of this variable comes from xen_ram_init (called by xen_hvm_init).

Paolo

Quoted 18 lines
---
 hw/i386/pc_piix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/pc_piix.c +1 -1
index 6e1e654..596d433 100644
@@ -86,7 +86,7 @@ static void pc_init1(MemoryRegion *system_memory,
     BusState *idebus[MAX_IDE_BUS];
     ISADevice *rtc_state;
     ISADevice *floppy;
-    MemoryRegion *ram_memory;
+    MemoryRegion *ram_memory = NULL;
     MemoryRegion *pci_memory;
     MemoryRegion *rom_memory;
     DeviceState *icc_bridge;
#13 lore raw

Il 29/08/2013 11:00, Paolo Bonzini ha scritto:

Quoted 6 lines

Il 16/08/2013 16:46, Anthony PERARD ha scritto:

Quoted 5 lines

In some cases (Xen), it will not be initialized before to be used. This leads to segv.

Quoted 8 lines
Quoted 4 lines

---

It works with this simple initialization to NULL, but would it be necessary (or better) to assign a proper value to this variables ?

Yeah, the right value of this variable comes from xen_ram_init (called by xen_hvm_init).

Paolo

I done a fast search of patch between 1.5 and 1.6 about memory on xen files and I found this patch:

Commit:2c9b15cab12c21e32dffb67c5e18f3dc407ca224
* memory: add owner argument to initialization functions

I not understand if can be this that have introduced an unexpected event with xen and how to solve correctly.

Thanks for any reply and sorry for my bad english.

Quoted 24 lines
Quoted 11 lines
---
  hw/i386/pc_piix.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/pc_piix.c +0 -0
index 6e1e654..596d433 100644

hw/i386/pc_piix.c static void pc_init1(MemoryRegion *system_memory, · line 92

Quoted 8 lines
hw/i386/pc_piix.c +1 -1
@@ -86,7 +86,7 @@ static void pc_init1(MemoryRegion *system_memory,
      BusState *idebus[MAX_IDE_BUS];
      ISADevice *rtc_state;
      ISADevice *floppy;
-    MemoryRegion *ram_memory;
+    MemoryRegion *ram_memory = NULL;
      MemoryRegion *pci_memory;
      MemoryRegion *rom_memory;
      DeviceState *icc_bridge;

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#14 lore raw
In reply to Paolo Bonzini

Il 29/08/2013 11:00, Paolo Bonzini ha scritto:

Quoted 6 lines

Il 16/08/2013 16:46, Anthony PERARD ha scritto:

Quoted 5 lines

In some cases (Xen), it will not be initialized before to be used. This leads to segv.

Quoted 8 lines
Quoted 4 lines

---

It works with this simple initialization to NULL, but would it be necessary (or better) to assign a proper value to this variables ?

Yeah, the right value of this variable comes from xen_ram_init (called by xen_hvm_init).

Paolo

I done a fast search of patch between 1.5 and 1.6 about memory on xen files and I found this patch:

Commit:2c9b15cab12c21e32dffb67c5e18f3dc407ca224
* memory: add owner argument to initialization functions

I not understand if can be this that have introduced an unexpected event with xen and how to solve correctly.

Thanks for any reply and sorry for my bad english.

Quoted 24 lines
Quoted 11 lines
---
  hw/i386/pc_piix.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/pc_piix.c +0 -0
index 6e1e654..596d433 100644

hw/i386/pc_piix.c static void pc_init1(MemoryRegion *system_memory, · line 92

Quoted 8 lines
hw/i386/pc_piix.c +1 -1
@@ -86,7 +86,7 @@ static void pc_init1(MemoryRegion *system_memory,
      BusState *idebus[MAX_IDE_BUS];
      ISADevice *rtc_state;
      ISADevice *floppy;
-    MemoryRegion *ram_memory;
+    MemoryRegion *ram_memory = NULL;
      MemoryRegion *pci_memory;
      MemoryRegion *rom_memory;
      DeviceState *icc_bridge;

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel