Skip to contentSkip to conversation

fix qemu crash with memory-backend-* prealloc=yes

PATCH In review Igor Mammedov 2 participants 5 messages Mar 25, 2020 – Apr 9, 2020 Arm STM32

lore
Share & tools
lore
#0 lore raw

cover fix qemu crash with memory-backend-* prealloc=yes

Igor Mammedov (2):
hostmem: set default prealloc_threads to valid value
tests: numa: test one backend with prealloc enabled

 backends/hostmem.c      | 1 +
 tests/qtest/numa-test.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
Signature · 1 line
2.18.1
#1 lore raw

PATCH 1/2 hostmem: set default prealloc_threads to valid value

Commit 4ebc74dbbf removed default prealloc_threads initialization by mistake, and that makes QEMU crash with division on zero at
numpages_per_thread = numpages / memset_num_threads;
when QEMU is started with following backend
-object memory-backend-ram,id=ram-node0,prealloc=yes,size=128M

Return back initialization removed by 4ebc74dbbf to fix issue.

Fixes 4ebc74dbbf7ad50e4101629f3f5da5fdc1544051
---
 backends/hostmem.c | 1 +
 1 file changed, 1 insertion(+)
backends/hostmem.c +1 -0
index a70867b255..327f9eebc3 100644
@@ -280,6 +280,7 @@ static void host_memory_backend_init(Object *obj)
     /* TODO: convert access to globals to compat properties */
     backend->merge = machine_mem_merge(machine);
     backend->dump = machine_dump_guest_core(machine);
+    backend->prealloc_threads = 1;
 }
 
 static void host_memory_backend_post_init(Object *obj)
Signature · 1 line
2.18.1
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH for-5.0 1/2] hostmem: set default prealloc_threads to valid value

Quoted 21 lines · Igor Mammedov

Commit 4ebc74dbbf removed default prealloc_threads initialization by mistake, and that makes QEMU crash with division on zero at
numpages_per_thread = numpages / memset_num_threads;
when QEMU is started with following backend
-object memory-backend-ram,id=ram-node0,prealloc=yes,size=128M

Return back initialization removed by 4ebc74dbbf to fix issue.

Fixes 4ebc74dbbf7ad50e4101629f3f5da5fdc1544051
---
 backends/hostmem.c | 1 +
 1 file changed, 1 insertion(+)
backends/hostmem.c +0 -0
index a70867b255..327f9eebc3 100644

backends/hostmem.c static void host_memory_backend_init(Object *obj) · line 286

Quoted 7 lines
backends/hostmem.c +1 -0
@@ -280,6 +280,7 @@ static void host_memory_backend_init(Object *obj)
     /* TODO: convert access to globals to compat properties */
     backend->merge = machine_mem_merge(machine);
     backend->dump = machine_dump_guest_core(machine);
+    backend->prealloc_threads = 1;
 }
 
 static void host_memory_backend_post_init(Object *obj)
#3 lore raw

PATCH 2/2 tests: numa: test one backend with prealloc enabled

In reply to Igor Mammedov

canbalize one backend in hmat test to make sure that prealloc=y is tested

---
 tests/qtest/numa-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/qtest/numa-test.c +1 -1
index 2f9b7f663a..e1ed6d4322 100644
@@ -455,7 +455,7 @@ static void pc_hmat_off_cfg(const void *data)
     cli = make_cli(data, "-nodefaults --preconfig "
                          "-smp 2,sockets=2 "
                          "-m 128M,slots=2,maxmem=1G "
-                         "-object memory-backend-ram,size=64M,id=m0 "
+                         "-object memory-backend-ram,size=64M,id=m0,prealloc=y "
                          "-object memory-backend-ram,size=64M,id=m1 "
                          "-numa node,nodeid=0,memdev=m0");
     qs = qtest_init(cli);
Signature · 1 line
2.18.1
#4 lore raw
In reply to Igor Mammedov
Quoted 8 lines · On Wed, 25 Mar 2020 05:44:21 -0400 Igor Mammedov <[email protected]> wrote:

Igor Mammedov (2):
hostmem: set default prealloc_threads to valid value
tests: numa: test one backend with prealloc enabled

 backends/hostmem.c      | 1 +
 tests/qtest/numa-test.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

it looks like it's fallen through cracks.

Peter, Paolo

Could you pick it up for 5.0, pls?