Skip to contentSkip to conversation

possible mmap regression

PATCH In review Felipe Contreras 2 participants 5 messages Feb 12, 2008 – Feb 20, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 possible mmap regression

Hi,

I don't know what I'm doing but this seems to fix the weird issue I was having.
http://article.gmane.org/gmane.comp.emulators.qemu/23314

I've found out that this happens on linux 2.6.23, but not 2.6.24.

Cheers.

Signature · 1 line
Felipe Contreras
linux-user/mmap.c +1 -1
index 6292826..3050ad9 100644
@@ -251,7 +251,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
            especially important if qemu_host_page_size >
            qemu_real_host_page_size */
         p = mmap(g2h(mmap_start),
-                 host_len, prot, flags | MAP_FIXED, fd, host_offset);
+                 host_len, prot, flags, fd, host_offset);
         if (p == MAP_FAILED)
             return -1;
         /* update start so that it points to the file position at 'offset' */
#1 lore raw
Quoted 16 lines · Felipe Contreras

Hi,

I don't know what I'm doing but this seems to fix the weird issue I was having.
http://article.gmane.org/gmane.comp.emulators.qemu/23314

I've found out that this happens on linux 2.6.23, but not 2.6.24.

Cheers.

Signature · 1 line
Felipe Contreras
linux-user/mmap.c +0 -0
index 6292826..3050ad9 100644

linux-user/mmap.c abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, · line 257

Quoted 8 lines
linux-user/mmap.c +1 -1
@@ -251,7 +251,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
            especially important if qemu_host_page_size >
            qemu_real_host_page_size */
         p = mmap(g2h(mmap_start),
-                 host_len, prot, flags | MAP_FIXED, fd, host_offset);
+                 host_len, prot, flags, fd, host_offset);
         if (p == MAP_FAILED)
             return -1;
         /* update start so that it points to the file position at 'offset' */

Hello,

Sorry, but I beleive your patch will break simulations where the targets pagesize is larger than the hosts.

Would you mind trying the attach patched and let us know if it helps for you?
If not, it would be great if you could provide a small test case that trigs the bug you are seeing so we can debug the problem.

Best regards

Signature · 2 lines
Edgar E. Iglesias
Axis Communications AB
linux-user/mmap.c +3 -0
index 6292826..78a8162 100644
@@ -385,6 +385,9 @@ int target_munmap(abi_ulong start, abi_ulong len)
             real_end -= qemu_host_page_size;
     }
 
+    if (start < mmap_next_start)
+    	mmap_next_start = start;
+
     /* unmap what we can */
     if (real_start < real_end) {
         ret = munmap(g2h(real_start), real_end - real_start);
#2 lore raw

Hi Edgar,

Quoted 45 lines · Edgar E. Iglesias
Quoted 16 lines · Felipe Contreras

Hi,

I don't know what I'm doing but this seems to fix the weird issue I was having.
http://article.gmane.org/gmane.comp.emulators.qemu/23314

I've found out that this happens on linux 2.6.23, but not 2.6.24.

Cheers.

--
Felipe Contreras

linux-user/mmap.c +0 -0
index 6292826..3050ad9 100644

linux-user/mmap.c abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, · line 257

Quoted 8 lines
linux-user/mmap.c +1 -1
@@ -251,7 +251,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
            especially important if qemu_host_page_size >
            qemu_real_host_page_size */
         p = mmap(g2h(mmap_start),
-                 host_len, prot, flags | MAP_FIXED, fd, host_offset);
+                 host_len, prot, flags, fd, host_offset);
         if (p == MAP_FAILED)
             return -1;
         /* update start so that it points to the file position at 'offset' */

Hello,

Sorry, but I beleive your patch will break simulations where the targets pagesize is larger than the hosts.

Would you mind trying the attach patched and let us know if it helps for you?
If not, it would be great if you could provide a small test case that trigs the bug you are seeing so we can debug the problem.

Best regards
--
Edgar E. Iglesias
Axis Communications AB

linux-user/mmap.c +0 -0
index 6292826..78a8162 100644

linux-user/mmap.c int target_munmap(abi_ulong start, abi_ulong len) · line 393

Quoted 9 lines
linux-user/mmap.c +3 -0
@@ -385,6 +385,9 @@ int target_munmap(abi_ulong start, abi_ulong len)
             real_end -= qemu_host_page_size;
     }
 
+    if (start < mmap_next_start)
+       mmap_next_start = start;
+
     /* unmap what we can */
     if (real_start < real_end) {
         ret = munmap(g2h(real_start), real_end - real_start);

I tried your patch and it still crashes.

I sent the details before:
http://article.gmane.org/gmane.comp.emulators.qemu/23314
http://article.gmane.org/gmane.comp.emulators.qemu/23328

Basically it was triggered by this change:
http://repo.or.cz/w/qemu.git?a=commitdiff;h=edbcc0b2eb1d4caee5f293e5c79f81023f3394e2

And it happens with some recursive Makefiles stuff.

Best regards.

Signature · 1 line
Felipe Contreras
#3 lore raw
Quoted 60 lines · Felipe Contreras

Hi Edgar,

Quoted 45 lines · Edgar E. Iglesias
Quoted 16 lines · Felipe Contreras

Hi,

I don't know what I'm doing but this seems to fix the weird issue I was having.
http://article.gmane.org/gmane.comp.emulators.qemu/23314

I've found out that this happens on linux 2.6.23, but not 2.6.24.

Cheers.

--
Felipe Contreras

linux-user/mmap.c +0 -0
index 6292826..3050ad9 100644

linux-user/mmap.c abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, · line 257

Quoted 8 lines
linux-user/mmap.c +1 -1
@@ -251,7 +251,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
            especially important if qemu_host_page_size >
            qemu_real_host_page_size */
         p = mmap(g2h(mmap_start),
-                 host_len, prot, flags | MAP_FIXED, fd, host_offset);
+                 host_len, prot, flags, fd, host_offset);
         if (p == MAP_FAILED)
             return -1;
         /* update start so that it points to the file position at 'offset' */

Hello,

Sorry, but I beleive your patch will break simulations where the targets pagesize is larger than the hosts.

Would you mind trying the attach patched and let us know if it helps for you?
If not, it would be great if you could provide a small test case that trigs the bug you are seeing so we can debug the problem.

Best regards
--
Edgar E. Iglesias
Axis Communications AB

linux-user/mmap.c +0 -0
index 6292826..78a8162 100644

linux-user/mmap.c int target_munmap(abi_ulong start, abi_ulong len) · line 393

Quoted 9 lines
linux-user/mmap.c +3 -0
@@ -385,6 +385,9 @@ int target_munmap(abi_ulong start, abi_ulong len)
             real_end -= qemu_host_page_size;
     }
 
+    if (start < mmap_next_start)
+       mmap_next_start = start;
+
     /* unmap what we can */
     if (real_start < real_end) {
         ret = munmap(g2h(real_start), real_end - real_start);

I tried your patch and it still crashes.

Quoted 8 lines

I sent the details before:
http://article.gmane.org/gmane.comp.emulators.qemu/23314
http://article.gmane.org/gmane.comp.emulators.qemu/23328

Basically it was triggered by this change:
http://repo.or.cz/w/qemu.git?a=commitdiff;h=edbcc0b2eb1d4caee5f293e5c79f81023f3394e2

And it happens with some recursive Makefiles stuff.

Thanks Felipe,

I was also seeing errors with that commit. Later that same evening I found a few more errors with the mmap code which tried to fix. Would you mind trying that patch too?

You can find it here:
http://lists.gnu.org/archive/html/qemu-devel/2008-02/msg00331.html

Best regards
-
Edgar E. Iglesias
Axis Communications AB

#4 lore raw
Quoted 69 lines · Edgar E. Iglesias
Quoted 67 lines · Felipe Contreras

Hi Edgar,

Quoted 45 lines · Edgar E. Iglesias
Quoted 16 lines · Felipe Contreras

Hi,

I don't know what I'm doing but this seems to fix the weird issue I was having.
http://article.gmane.org/gmane.comp.emulators.qemu/23314

I've found out that this happens on linux 2.6.23, but not 2.6.24.

Cheers.

--
Felipe Contreras

linux-user/mmap.c +0 -0
index 6292826..3050ad9 100644

linux-user/mmap.c abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, · line 257

Quoted 8 lines
linux-user/mmap.c +1 -1
@@ -251,7 +251,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
            especially important if qemu_host_page_size >
            qemu_real_host_page_size */
         p = mmap(g2h(mmap_start),
-                 host_len, prot, flags | MAP_FIXED, fd, host_offset);
+                 host_len, prot, flags, fd, host_offset);
         if (p == MAP_FAILED)
             return -1;
         /* update start so that it points to the file position at 'offset' */

Hello,

Sorry, but I beleive your patch will break simulations where the targets pagesize is larger than the hosts.

Would you mind trying the attach patched and let us know if it helps for you?
If not, it would be great if you could provide a small test case that trigs the bug you are seeing so we can debug the problem.

Best regards
--
Edgar E. Iglesias
Axis Communications AB

linux-user/mmap.c +0 -0
index 6292826..78a8162 100644

linux-user/mmap.c int target_munmap(abi_ulong start, abi_ulong len) · line 393

Quoted 9 lines
linux-user/mmap.c +3 -0
@@ -385,6 +385,9 @@ int target_munmap(abi_ulong start, abi_ulong len)
             real_end -= qemu_host_page_size;
     }
 
+    if (start < mmap_next_start)
+       mmap_next_start = start;
+
     /* unmap what we can */
     if (real_start < real_end) {
         ret = munmap(g2h(real_start), real_end - real_start);

I tried your patch and it still crashes.

I sent the details before:
http://article.gmane.org/gmane.comp.emulators.qemu/23314
http://article.gmane.org/gmane.comp.emulators.qemu/23328

Basically it was triggered by this change:
http://repo.or.cz/w/qemu.git?a=commitdiff;h=edbcc0b2eb1d4caee5f293e5c79f81023f3394e2

Quoted 8 lines
Quoted 1 line

And it happens with some recursive Makefiles stuff.

Thanks Felipe,

I was also seeing errors with that commit. Later that same evening I found a few more errors with the mmap code which tried to fix. Would you mind trying that patch too?

You can find it here:
http://lists.gnu.org/archive/html/qemu-devel/2008-02/msg00331.html

Good to know I'm not the only one :)

I tried your patch, I still get the crash.

Best regards.

Signature · 1 line
Felipe Contreras