Skip to contentSkip to conversation

linux-user/mmap.c: Use end instead of real_end in target_mmap

PATCH In review [email protected] 4 participants 5 messages Dec 24, 2015 – Jan 11, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-user/mmap.c: Use end instead of real_end in target_mmap

From: Chen Gang <[email protected]>

In this case, real_end is larger than end, which may cause mmap_frag process the incorrect memory region.

---
 linux-user/mmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/mmap.c +1 -1
index 7b459d5..57b0361 100644
@@ -536,7 +536,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
         /* handle the end of the mapping */
         if (end < real_end) {
             ret = mmap_frag(real_end - qemu_host_page_size,
-                            real_end - qemu_host_page_size, real_end,
+                            real_end - qemu_host_page_size, end,
                             prot, flags, fd,
                             offset + real_end - qemu_host_page_size - start);
             if (ret == -1)
Signature · 1 line
1.9.1
author
#1 lore raw

Hello all:

After this patch, the i386 wine notepad.exe can be bootup and run under sw_64 host.

- The initialization is very very slow (about 10 minutes), it is mainly running in find_vma_reserved (consume more than 95% time resource). I guess, it can be optimized.

- After initialization, for real using, the performance is acceptable!! :-)

- Next, I shall try the real Windows XP notepad.exe.

I guess, we need not softmmu, at least, for wine, it is true (wine will mmap all memory areas during initializing, and manage them by itself when real running).

Welcome any suggestions, ideas, and completions.

BTW: Merry Christmas! :-)

Thanks.

Quoted 24 lines · On 2015年12月24日 09:07, [email protected] wrote:

From: Chen Gang <[email protected]>

In this case, real_end is larger than end, which may cause mmap_frag process the incorrect memory region.

---
 linux-user/mmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/mmap.c +1 -1
index 7b459d5..57b0361 100644
@@ -536,7 +536,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
         /* handle the end of the mapping */
         if (end < real_end) {
             ret = mmap_frag(real_end - qemu_host_page_size,
-                            real_end - qemu_host_page_size, real_end,
+                            real_end - qemu_host_page_size, end,
                             prot, flags, fd,
                             offset + real_end - qemu_host_page_size - start);
             if (ret == -1)
Signature · 3 lines
Chen Gang (陈刚)

Open, share, and attitude like air, water, and life which God blessed
Reviewed-by on v1 1/1
#2 lore raw
In reply to [email protected]
Quoted 16 lines · Le 24/12/2015 02:07, [email protected] a écrit :

From: Chen Gang <[email protected]>

In this case, real_end is larger than end, which may cause mmap_frag process the incorrect memory region.

---
 linux-user/mmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/mmap.c +0 -0
index 7b459d5..57b0361 100644

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

Quoted 8 lines
linux-user/mmap.c +1 -1
@@ -536,7 +536,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
         /* handle the end of the mapping */
         if (end < real_end) {
             ret = mmap_frag(real_end - qemu_host_page_size,
-                            real_end - qemu_host_page_size, real_end,
+                            real_end - qemu_host_page_size, end,
                             prot, flags, fd,
                             offset + real_end - qemu_host_page_size - start);
             if (ret == -1)

The fragment must effectively be mapped only to "end" not to "real_end" (which is a host page aligned address, and thus this is not a fragment). It is consistent with what it is done in the case of one single page.

#3 lore raw
Quoted 31 lines · Laurent Vivier
Quoted 16 lines · Le 24/12/2015 02:07, [email protected] a écrit :

From: Chen Gang <[email protected]>

In this case, real_end is larger than end, which may cause mmap_frag process the incorrect memory region.

---
 linux-user/mmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/mmap.c +0 -0
index 7b459d5..57b0361 100644

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

Quoted 8 lines
linux-user/mmap.c +1 -1
@@ -536,7 +536,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
         /* handle the end of the mapping */
         if (end < real_end) {
             ret = mmap_frag(real_end - qemu_host_page_size,
-                            real_end - qemu_host_page_size, real_end,
+                            real_end - qemu_host_page_size, end,
                             prot, flags, fd,
                             offset + real_end - qemu_host_page_size - start);
             if (ret == -1)

The fragment must effectively be mapped only to "end" not to "real_end" (which is a host page aligned address, and thus this is not a fragment). It is consistent with what it is done in the case of one single page.

Quoted 1 line

Thank you for your comments. I only met this issue, and knew it should be fixed in this way, but really don't know the related details.

Thanks.

Signature · 3 lines
Chen Gang

Open, share, and attitude like air, water, and life which God blessed
#4 lore raw
In reply to Laurent Vivier
Quoted 7 lines · Laurent Vivier
Quoted 5 lines · Le 24/12/2015 02:07, [email protected] a écrit :

From: Chen Gang <[email protected]>

In this case, real_end is larger than end, which may cause mmap_frag process the incorrect memory region.

Quoted 8 lines
Quoted 2 lines

--- ...

The fragment must effectively be mapped only to "end" not to "real_end" (which is a host page aligned address, and thus this is not a fragment). It is consistent with what it is done in the case of one single page.

Applied with changing the patch comment to Laurent's explanation.

Riku