Skip to contentSkip to conversation

linux-user/syscall.c: Notice about lock bitmask translation for fcntl

PATCH In review Chen Gang 3 participants 11 messages Dec 18, 2015 – Dec 21, 2015

lore
Share & tools
lore

Chen Gang

author
#0 lore raw

PATCH 1/1 linux-user/syscall.c: Notice about lock bitmask translation for fcntl

For fcntl, it always needs to notice about it, just like do_fcntl() has done, or it will cause issue (e.g. alpha host run i386 guest).

---
 linux-user/syscall.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)
linux-user/syscall.c +12 -6
index 0f8adeb..1a60e6f 100644
@@ -9007,7 +9007,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             if (((CPUARMState *)cpu_env)->eabi) {
                 if (!lock_user_struct(VERIFY_READ, target_efl, arg3, 1)) 
                     goto efault;
-                fl.l_type = tswap16(target_efl->l_type);
+                fl.l_type = target_to_host_bitmask(tswap16(target_fl->l_type),
+                                                   flock_tbl);
                 fl.l_whence = tswap16(target_efl->l_whence);
                 fl.l_start = tswap64(target_efl->l_start);
                 fl.l_len = tswap64(target_efl->l_len);
@@ -9018,7 +9019,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             {
                 if (!lock_user_struct(VERIFY_READ, target_fl, arg3, 1)) 
                     goto efault;
-                fl.l_type = tswap16(target_fl->l_type);
+                fl.l_type = target_to_host_bitmask(tswap16(target_fl->l_type),
+                                                   flock_tbl);
                 fl.l_whence = tswap16(target_fl->l_whence);
                 fl.l_start = tswap64(target_fl->l_start);
                 fl.l_len = tswap64(target_fl->l_len);
@@ -9031,7 +9033,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
                 if (((CPUARMState *)cpu_env)->eabi) {
                     if (!lock_user_struct(VERIFY_WRITE, target_efl, arg3, 0)) 
                         goto efault;
-                    target_efl->l_type = tswap16(fl.l_type);
+                    target_efl->l_type = host_to_target_bitmask(
+                                                 tswap16(fl.l_type), flock_tbl);
                     target_efl->l_whence = tswap16(fl.l_whence);
                     target_efl->l_start = tswap64(fl.l_start);
                     target_efl->l_len = tswap64(fl.l_len);
@@ -9042,7 +9045,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
                 {
                     if (!lock_user_struct(VERIFY_WRITE, target_fl, arg3, 0)) 
                         goto efault;
-                    target_fl->l_type = tswap16(fl.l_type);
+                    target_fl->l_type = host_to_target_bitmask(
+                                                 tswap16(fl.l_type), flock_tbl);
                     target_fl->l_whence = tswap16(fl.l_whence);
                     target_fl->l_start = tswap64(fl.l_start);
                     target_fl->l_len = tswap64(fl.l_len);
@@ -9058,7 +9062,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             if (((CPUARMState *)cpu_env)->eabi) {
                 if (!lock_user_struct(VERIFY_READ, target_efl, arg3, 1)) 
                     goto efault;
-                fl.l_type = tswap16(target_efl->l_type);
+                fl.l_type = target_to_host_bitmask(tswap16(target_fl->l_type),
+                                                   flock_tbl);
                 fl.l_whence = tswap16(target_efl->l_whence);
                 fl.l_start = tswap64(target_efl->l_start);
                 fl.l_len = tswap64(target_efl->l_len);
@@ -9069,7 +9074,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             {
                 if (!lock_user_struct(VERIFY_READ, target_fl, arg3, 1)) 
                     goto efault;
-                fl.l_type = tswap16(target_fl->l_type);
+                fl.l_type = target_to_host_bitmask(tswap16(target_fl->l_type),
+                                                   flock_tbl);
                 fl.l_whence = tswap16(target_fl->l_whence);
                 fl.l_start = tswap64(target_fl->l_start);
                 fl.l_len = tswap64(target_fl->l_len);
Signature · 1 line
1.7.3.4
author
#1 lore raw

I found this issue during my working time, it is about sw_64 (almost the same as alpha) host running i386 wine programs.

I also found another issue, but I am not quite sure whether it is worth enough for our upstream: The related fix patch is below, which will let the initialization slower, but for most archs, they have no this issue.

linux-user/mmap.c: Always zero MAP_ANONYMOUS memory in target_mmap()

In some architectures, they have no policy to zero MAP_ANONYMOUS memory, which will cause issue for qemu target_mmap.

linux-user/mmap.c +4 -0
index 7b459d5..9c9152d 100644
@@ -567,6 +567,10 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
     printf("\n");
 #endif
     tb_invalidate_phys_range(start, start + len);
+    if ((prot & PROT_WRITE) && (flags & MAP_ANONYMOUS)
+        && ((flags & MAP_PRIVATE) || (fd == -1))) {
+        memset(g2h(start), 0, len);
+    }
     mmap_unlock();
     return start;
 fail:

Thanks.

Quoted 74 lines · Chen Gang

For fcntl, it always needs to notice about it, just like do_fcntl() has done, or it will cause issue (e.g. alpha host run i386 guest).

---
 linux-user/syscall.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)
linux-user/syscall.c +12 -6
index 0f8adeb..1a60e6f 100644
@@ -9007,7 +9007,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             if (((CPUARMState *)cpu_env)->eabi) {
                 if (!lock_user_struct(VERIFY_READ, target_efl, arg3, 1)) 
                     goto efault;
-                fl.l_type = tswap16(target_efl->l_type);
+                fl.l_type = target_to_host_bitmask(tswap16(target_fl->l_type),
+                                                   flock_tbl);
                 fl.l_whence = tswap16(target_efl->l_whence);
                 fl.l_start = tswap64(target_efl->l_start);
                 fl.l_len = tswap64(target_efl->l_len);
@@ -9018,7 +9019,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             {
                 if (!lock_user_struct(VERIFY_READ, target_fl, arg3, 1)) 
                     goto efault;
-                fl.l_type = tswap16(target_fl->l_type);
+                fl.l_type = target_to_host_bitmask(tswap16(target_fl->l_type),
+                                                   flock_tbl);
                 fl.l_whence = tswap16(target_fl->l_whence);
                 fl.l_start = tswap64(target_fl->l_start);
                 fl.l_len = tswap64(target_fl->l_len);
@@ -9031,7 +9033,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
                 if (((CPUARMState *)cpu_env)->eabi) {
                     if (!lock_user_struct(VERIFY_WRITE, target_efl, arg3, 0)) 
                         goto efault;
-                    target_efl->l_type = tswap16(fl.l_type);
+                    target_efl->l_type = host_to_target_bitmask(
+                                                 tswap16(fl.l_type), flock_tbl);
                     target_efl->l_whence = tswap16(fl.l_whence);
                     target_efl->l_start = tswap64(fl.l_start);
                     target_efl->l_len = tswap64(fl.l_len);
@@ -9042,7 +9045,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
                 {
                     if (!lock_user_struct(VERIFY_WRITE, target_fl, arg3, 0)) 
                         goto efault;
-                    target_fl->l_type = tswap16(fl.l_type);
+                    target_fl->l_type = host_to_target_bitmask(
+                                                 tswap16(fl.l_type), flock_tbl);
                     target_fl->l_whence = tswap16(fl.l_whence);
                     target_fl->l_start = tswap64(fl.l_start);
                     target_fl->l_len = tswap64(fl.l_len);
@@ -9058,7 +9062,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             if (((CPUARMState *)cpu_env)->eabi) {
                 if (!lock_user_struct(VERIFY_READ, target_efl, arg3, 1)) 
                     goto efault;
-                fl.l_type = tswap16(target_efl->l_type);
+                fl.l_type = target_to_host_bitmask(tswap16(target_fl->l_type),
+                                                   flock_tbl);
                 fl.l_whence = tswap16(target_efl->l_whence);
                 fl.l_start = tswap64(target_efl->l_start);
                 fl.l_len = tswap64(target_efl->l_len);
@@ -9069,7 +9074,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             {
                 if (!lock_user_struct(VERIFY_READ, target_fl, arg3, 1)) 
                     goto efault;
-                fl.l_type = tswap16(target_fl->l_type);
+                fl.l_type = target_to_host_bitmask(tswap16(target_fl->l_type),
+                                                   flock_tbl);
                 fl.l_whence = tswap16(target_fl->l_whence);
                 fl.l_start = tswap64(target_fl->l_start);
                 fl.l_len = tswap64(target_fl->l_len);
Signature · 3 lines
Chen Gang (陈刚)

Open, share, and attitude like air, water, and life which God blessed
#2 lore raw
Quoted 20 lines · Chen Gang

I found this issue during my working time, it is about sw_64 (almost the same as alpha) host running i386 wine programs.

I also found another issue, but I am not quite sure whether it is worth enough for our upstream: The related fix patch is below, which will let the initialization slower, but for most archs, they have no this issue.

linux-user/mmap.c: Always zero MAP_ANONYMOUS memory in target_mmap()

In some architectures, they have no policy to zero MAP_ANONYMOUS memory, which will cause issue for qemu target_mmap.

linux-user/mmap.c +0 -0
index 7b459d5..9c9152d 100644

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

Quoted 7 lines
linux-user/mmap.c +4 -0
@@ -567,6 +567,10 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
     printf("\n");
 #endif
     tb_invalidate_phys_range(start, start + len);
+    if ((prot & PROT_WRITE) && (flags & MAP_ANONYMOUS)
+        && ((flags & MAP_PRIVATE) || (fd == -1))) {
+        memset(g2h(start), 0, len);
+    }

IMHO, their kernel needs a fix, mmap(2):

MAP_ANONYMOUS
The mapping is not backed by any file; its contents are initial‐ ized to zero.

Quoted 6 lines
linux-user/mmap.c +0 -0
     mmap_unlock();
     return start;
 fail:

Thanks.

Laurent

author
#3 lore raw
Quoted 33 lines · Laurent Vivier
Quoted 20 lines · Chen Gang

I found this issue during my working time, it is about sw_64 (almost the same as alpha) host running i386 wine programs.

I also found another issue, but I am not quite sure whether it is worth enough for our upstream: The related fix patch is below, which will let the initialization slower, but for most archs, they have no this issue.

linux-user/mmap.c: Always zero MAP_ANONYMOUS memory in target_mmap()

In some architectures, they have no policy to zero MAP_ANONYMOUS memory, which will cause issue for qemu target_mmap.

linux-user/mmap.c +0 -0
index 7b459d5..9c9152d 100644

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

Quoted 7 lines
linux-user/mmap.c +4 -0
@@ -567,6 +567,10 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
     printf("\n");
 #endif
     tb_invalidate_phys_range(start, start + len);
+    if ((prot & PROT_WRITE) && (flags & MAP_ANONYMOUS)
+        && ((flags & MAP_PRIVATE) || (fd == -1))) {
+        memset(g2h(start), 0, len);
+    }

IMHO, their kernel needs a fix, mmap(2):

Quoted 4 lines

MAP_ANONYMOUS
The mapping is not backed by any file; its contents are initial‐ ized to zero.

OK, Thanks.

Signature · 3 lines
Chen Gang (陈刚)

Open, share, and attitude like air, water, and life which God blessed
author
#4 lore raw
Quoted 4 lines · Chen Gang
Quoted 2 lines · Laurent Vivier

Le 18/12/2015 07:51, Chen Gang a écrit :

[...]

Quoted 13 lines
Quoted 13 lines

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

Quoted 10 lines

+++ b/linux-user/mmap.c

linux-user/mmap.c +4 -0
@@ -567,6 +567,10 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
     printf("\n");
 #endif
     tb_invalidate_phys_range(start, start + len);
+    if ((prot & PROT_WRITE) && (flags & MAP_ANONYMOUS)
+        && ((flags & MAP_PRIVATE) || (fd == -1))) {
+        memset(g2h(start), 0, len);
+    }

IMHO, their kernel needs a fix, mmap(2):

Quoted 4 lines
Quoted 4 lines

MAP_ANONYMOUS
The mapping is not backed by any file; its contents are initial‐ ized to zero.

Oh, sorry, after check again, it is not kernel's issue: mmap() will always zero the ANONYMOUS memory for kernel 3.8 in sw_64 arch.

It is still our qemu's issue in mmap_frag (do not zero ANONYMOUS memory fragments), so I sent patch v2 for it, please help check.

Thanks.

Quoted 4 lines

OK, Thanks.

Signature · 3 lines
Chen Gang (陈刚)

Open, share, and attitude like air, water, and life which God blessed
Reviewed-by on v1 1/1
#5 lore raw
In reply to Chen Gang
Quoted 65 lines · Chen Gang

For fcntl, it always needs to notice about it, just like do_fcntl() has done, or it will cause issue (e.g. alpha host run i386 guest).

---
 linux-user/syscall.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)
linux-user/syscall.c +10 -5
index 0f8adeb..1a60e6f 100644
@@ -9007,7 +9007,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             if (((CPUARMState *)cpu_env)->eabi) {
                 if (!lock_user_struct(VERIFY_READ, target_efl, arg3, 1)) 
                     goto efault;
-                fl.l_type = tswap16(target_efl->l_type);
+                fl.l_type = target_to_host_bitmask(tswap16(target_fl->l_type),
+                                                   flock_tbl);
                 fl.l_whence = tswap16(target_efl->l_whence);
                 fl.l_start = tswap64(target_efl->l_start);
                 fl.l_len = tswap64(target_efl->l_len);
@@ -9018,7 +9019,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             {
                 if (!lock_user_struct(VERIFY_READ, target_fl, arg3, 1)) 
                     goto efault;
-                fl.l_type = tswap16(target_fl->l_type);
+                fl.l_type = target_to_host_bitmask(tswap16(target_fl->l_type),
+                                                   flock_tbl);
                 fl.l_whence = tswap16(target_fl->l_whence);
                 fl.l_start = tswap64(target_fl->l_start);
                 fl.l_len = tswap64(target_fl->l_len);
@@ -9031,7 +9033,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
                 if (((CPUARMState *)cpu_env)->eabi) {
                     if (!lock_user_struct(VERIFY_WRITE, target_efl, arg3, 0)) 
                         goto efault;
-                    target_efl->l_type = tswap16(fl.l_type);
+                    target_efl->l_type = host_to_target_bitmask(
+                                                 tswap16(fl.l_type), flock_tbl);
                     target_efl->l_whence = tswap16(fl.l_whence);
                     target_efl->l_start = tswap64(fl.l_start);
                     target_efl->l_len = tswap64(fl.l_len);
@@ -9042,7 +9045,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
                 {
                     if (!lock_user_struct(VERIFY_WRITE, target_fl, arg3, 0)) 
                         goto efault;
-                    target_fl->l_type = tswap16(fl.l_type);
+                    target_fl->l_type = host_to_target_bitmask(
+                                                 tswap16(fl.l_type), flock_tbl);
                     target_fl->l_whence = tswap16(fl.l_whence);
                     target_fl->l_start = tswap64(fl.l_start);
                     target_fl->l_len = tswap64(fl.l_len);
@@ -9058,7 +9062,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             if (((CPUARMState *)cpu_env)->eabi) {
                 if (!lock_user_struct(VERIFY_READ, target_efl, arg3, 1)) 
                     goto efault;
-                fl.l_type = tswap16(target_efl->l_type);
+                fl.l_type = target_to_host_bitmask(tswap16(target_fl->l_type),
+                                                   flock_tbl);
                 fl.l_whence = tswap16(target_efl->l_whence);
                 fl.l_start = tswap64(target_efl->l_start);
                 fl.l_len = tswap64(target_efl->l_len);

linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 9081

Quoted 9 lines
linux-user/syscall.c +2 -1
@@ -9069,7 +9074,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             {
                 if (!lock_user_struct(VERIFY_READ, target_fl, arg3, 1)) 
                     goto efault;
-                fl.l_type = tswap16(target_fl->l_type);
+                fl.l_type = target_to_host_bitmask(tswap16(target_fl->l_type),
+                                                   flock_tbl);
                 fl.l_whence = tswap16(target_fl->l_whence);
                 fl.l_start = tswap64(target_fl->l_start);
                 fl.l_len = tswap64(target_fl->l_len);

This patch looks good to me, except that script/checkpatch.pl complains about "DOS line ending" and "line over 80 characters".

#6 lore raw
Quoted 71 lines · Laurent Vivier
Quoted 69 lines · Chen Gang

For fcntl, it always needs to notice about it, just like do_fcntl() has done, or it will cause issue (e.g. alpha host run i386 guest).

---
 linux-user/syscall.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)
linux-user/syscall.c +11 -6
index 0f8adeb..1a60e6f 100644
@@ -9007,7 +9007,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             if (((CPUARMState *)cpu_env)->eabi) {
                 if (!lock_user_struct(VERIFY_READ, target_efl, arg3, 1)) 
                     goto efault;
-                fl.l_type = tswap16(target_efl->l_type);
+                fl.l_type = target_to_host_bitmask(tswap16(target_fl->l_type),
+                                                   flock_tbl);
                 fl.l_whence = tswap16(target_efl->l_whence);
                 fl.l_start = tswap64(target_efl->l_start);
                 fl.l_len = tswap64(target_efl->l_len);
@@ -9018,7 +9019,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             {
                 if (!lock_user_struct(VERIFY_READ, target_fl, arg3, 1)) 
                     goto efault;
-                fl.l_type = tswap16(target_fl->l_type);
+                fl.l_type = target_to_host_bitmask(tswap16(target_fl->l_type),
+                                                   flock_tbl);
                 fl.l_whence = tswap16(target_fl->l_whence);
                 fl.l_start = tswap64(target_fl->l_start);
                 fl.l_len = tswap64(target_fl->l_len);
@@ -9031,7 +9033,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
                 if (((CPUARMState *)cpu_env)->eabi) {
                     if (!lock_user_struct(VERIFY_WRITE, target_efl, arg3, 0)) 
                         goto efault;
-                    target_efl->l_type = tswap16(fl.l_type);
+                    target_efl->l_type = host_to_target_bitmask(
+                                                 tswap16(fl.l_type), flock_tbl);
                     target_efl->l_whence = tswap16(fl.l_whence);
                     target_efl->l_start = tswap64(fl.l_start);
                     target_efl->l_len = tswap64(fl.l_len);
@@ -9042,7 +9045,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
                 {
                     if (!lock_user_struct(VERIFY_WRITE, target_fl, arg3, 0)) 
                         goto efault;
-                    target_fl->l_type = tswap16(fl.l_type);
+                    target_fl->l_type = host_to_target_bitmask(
+                                                 tswap16(fl.l_type), flock_tbl);
                     target_fl->l_whence = tswap16(fl.l_whence);
                     target_fl->l_start = tswap64(fl.l_start);
                     target_fl->l_len = tswap64(fl.l_len);
@@ -9058,7 +9062,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             if (((CPUARMState *)cpu_env)->eabi) {
                 if (!lock_user_struct(VERIFY_READ, target_efl, arg3, 1)) 
                     goto efault;
-                fl.l_type = tswap16(target_efl->l_type);
+                fl.l_type = target_to_host_bitmask(tswap16(target_fl->l_type),
+                                                   flock_tbl);
                 fl.l_whence = tswap16(target_efl->l_whence);
                 fl.l_start = tswap64(target_efl->l_start);
                 fl.l_len = tswap64(target_efl->l_len);
@@ -9069,7 +9074,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             {
                 if (!lock_user_struct(VERIFY_READ, target_fl, arg3, 1)) 
                     goto efault;
-                fl.l_type = tswap16(target_fl->l_type);
+                fl.l_type = target_to_host_bitmask(tswap16(target_fl->l_type),
Quoted 9 lines

linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 9026

Quoted 5 lines
linux-user/syscall.c +1 -0
+                                                   flock_tbl);
                 fl.l_whence = tswap16(target_fl->l_whence);
                 fl.l_start = tswap64(target_fl->l_start);
                 fl.l_len = tswap64(target_fl->l_len);

This patch looks good to me, except that script/checkpatch.pl complains about "DOS line ending" and "line over 80 characters".

I did not get any script/checkpatch.pl complains, originally.

Does my email client configuration is incorrect, then cause incorrect mail format? I guess not. The related reason is below.

- I copy your full reply mail contents to a new file (diff.patch).

- Remove all '> ' in vi editor (1,% s/^> //g) (so get the original patch contents).

- ./script/checkpatch.pl diff.patch, it has no any complains.

Quoted 2 lines

Thanks.

Signature · 3 lines
Chen Gang

Open, share, and attitude like air, water, and life which God blessed
#7 lore raw
Quoted 83 lines · Chen Gang
Quoted 71 lines · Laurent Vivier
Quoted 69 lines · Chen Gang

For fcntl, it always needs to notice about it, just like do_fcntl() has done, or it will cause issue (e.g. alpha host run i386 guest).

---
 linux-user/syscall.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)
linux-user/syscall.c +11 -6
index 0f8adeb..1a60e6f 100644
@@ -9007,7 +9007,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             if (((CPUARMState *)cpu_env)->eabi) {
                 if (!lock_user_struct(VERIFY_READ, target_efl, arg3, 1)) 
                     goto efault;
-                fl.l_type = tswap16(target_efl->l_type);
+                fl.l_type = target_to_host_bitmask(tswap16(target_fl->l_type),
+                                                   flock_tbl);
                 fl.l_whence = tswap16(target_efl->l_whence);
                 fl.l_start = tswap64(target_efl->l_start);
                 fl.l_len = tswap64(target_efl->l_len);
@@ -9018,7 +9019,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             {
                 if (!lock_user_struct(VERIFY_READ, target_fl, arg3, 1)) 
                     goto efault;
-                fl.l_type = tswap16(target_fl->l_type);
+                fl.l_type = target_to_host_bitmask(tswap16(target_fl->l_type),
+                                                   flock_tbl);
                 fl.l_whence = tswap16(target_fl->l_whence);
                 fl.l_start = tswap64(target_fl->l_start);
                 fl.l_len = tswap64(target_fl->l_len);
@@ -9031,7 +9033,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
                 if (((CPUARMState *)cpu_env)->eabi) {
                     if (!lock_user_struct(VERIFY_WRITE, target_efl, arg3, 0)) 
                         goto efault;
-                    target_efl->l_type = tswap16(fl.l_type);
+                    target_efl->l_type = host_to_target_bitmask(
+                                                 tswap16(fl.l_type), flock_tbl);
                     target_efl->l_whence = tswap16(fl.l_whence);
                     target_efl->l_start = tswap64(fl.l_start);
                     target_efl->l_len = tswap64(fl.l_len);
@@ -9042,7 +9045,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
                 {
                     if (!lock_user_struct(VERIFY_WRITE, target_fl, arg3, 0)) 
                         goto efault;
-                    target_fl->l_type = tswap16(fl.l_type);
+                    target_fl->l_type = host_to_target_bitmask(
+                                                 tswap16(fl.l_type), flock_tbl);
                     target_fl->l_whence = tswap16(fl.l_whence);
                     target_fl->l_start = tswap64(fl.l_start);
                     target_fl->l_len = tswap64(fl.l_len);
@@ -9058,7 +9062,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             if (((CPUARMState *)cpu_env)->eabi) {
                 if (!lock_user_struct(VERIFY_READ, target_efl, arg3, 1)) 
                     goto efault;
-                fl.l_type = tswap16(target_efl->l_type);
+                fl.l_type = target_to_host_bitmask(tswap16(target_fl->l_type),
+                                                   flock_tbl);
                 fl.l_whence = tswap16(target_efl->l_whence);
                 fl.l_start = tswap64(target_efl->l_start);
                 fl.l_len = tswap64(target_efl->l_len);
@@ -9069,7 +9074,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             {
                 if (!lock_user_struct(VERIFY_READ, target_fl, arg3, 1)) 
                     goto efault;
-                fl.l_type = tswap16(target_fl->l_type);
+                fl.l_type = target_to_host_bitmask(tswap16(target_fl->l_type),
Quoted 9 lines

linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 9026

Quoted 5 lines
linux-user/syscall.c +1 -0
+                                                   flock_tbl);
                 fl.l_whence = tswap16(target_fl->l_whence);
                 fl.l_start = tswap64(target_fl->l_start);
                 fl.l_len = tswap64(target_fl->l_len);

This patch looks good to me, except that script/checkpatch.pl complains about "DOS line ending" and "line over 80 characters".

Quoted 6 lines

I did not get any script/checkpatch.pl complains, originally.

Does my email client configuration is incorrect, then cause incorrect mail format? I guess not. The related reason is below.

- I copy your full reply mail contents to a new file (diff.patch).

If you copy, you loose the special characters. I do a "Save as".

Quoted 5 lines

- Remove all '> ' in vi editor (1,% s/^> //g) (so get the original patch contents).

- ./script/checkpatch.pl diff.patch, it has no any complains.

If I run "file" on the saved file, I have:

    $ file orig.eml
    orig.eml: SMTP mail, ASCII text, with CRLF line terminators

I can convert it with "tr":

    $ tr "\r" "\n" < orig.eml > new.eml
    $ file new.eml
    new.eml: SMTP mail, ASCII text
    $ ./scripts/checkpatch.pl new.eml
    total: 0 errors, 0 warnings, 54 lines checked

new.eml has no obvious style problems and is ready for submission.

Laurent

#8 lore raw
Quoted 3 lines · Laurent Vivier
Quoted 1 line · Chen Gang

[...]

Quoted 27 lines
Quoted 6 lines

I did not get any script/checkpatch.pl complains, originally.

Does my email client configuration is incorrect, then cause incorrect mail format? I guess not. The related reason is below.

- I copy your full reply mail contents to a new file (diff.patch).

If you copy, you loose the special characters. I do a "Save as".

Quoted 5 lines

- Remove all '> ' in vi editor (1,% s/^> //g) (so get the original patch contents).

- ./script/checkpatch.pl diff.patch, it has no any complains.

If I run "file" on the saved file, I have:

    $ file orig.eml
    orig.eml: SMTP mail, ASCII text, with CRLF line terminators

I can convert it with "tr":

    $ tr "\r" "\n" < orig.eml > new.eml
    $ file new.eml
    new.eml: SMTP mail, ASCII text
Quoted 7 lines
    $ ./scripts/checkpatch.pl new.eml
    total: 0 errors, 0 warnings, 54 lines checked

new.eml has no obvious style problems and is ready for submission.

Laurent

OK, thank you very much. I shall config my email client again to notice about it.

Thanks.

Signature · 3 lines
Chen Gang

Open, share, and attitude like air, water, and life which God blessed.
#9 lore raw
Quoted 38 lines · Chen Gang
Quoted 3 lines · Laurent Vivier
Quoted 1 line · Chen Gang

[...]

Quoted 30 lines
Quoted 6 lines

I did not get any script/checkpatch.pl complains, originally.

Does my email client configuration is incorrect, then cause incorrect mail format? I guess not. The related reason is below.

- I copy your full reply mail contents to a new file (diff.patch).

If you copy, you loose the special characters. I do a "Save as".

Quoted 5 lines

- Remove all '> ' in vi editor (1,% s/^> //g) (so get the original patch contents).

- ./script/checkpatch.pl diff.patch, it has no any complains.

If I run "file" on the saved file, I have:

    $ file orig.eml
    orig.eml: SMTP mail, ASCII text, with CRLF line terminators

I can convert it with "tr":

    $ tr "\r" "\n" < orig.eml > new.eml
    $ file new.eml
    new.eml: SMTP mail, ASCII text
    $ ./scripts/checkpatch.pl new.eml
    total: 0 errors, 0 warnings, 54 lines checked
Quoted 7 lines
Quoted 4 lines

new.eml has no obvious style problems and is ready for submission.

Laurent

OK, thank you very much. I shall config my email client again to notice about it.

You should not use your email client to send patches, you should use "git send-email":

http://wiki.qemu.org/Contribute/SubmitAPatch

Laurent

#10 lore raw
Quoted 3 lines · Laurent Vivier
Quoted 1 line · Chen Gang

[...]

Quoted 9 lines
Quoted 3 lines

OK, thank you very much. I shall config my email client again to notice about it.

You should not use your email client to send patches, you should use "git send-email":

http://wiki.qemu.org/Contribute/SubmitAPatch

OK, thanks.

Signature · 3 lines
Chen Gang

Open, share, and attitude like air, water, and life which God blessed