Skip to contentSkip to conversation

mips-linux-user and POSIX IPC

Qemu-devel Holger Freyther 2 participants 2 messages Jul 26, 2011 – Jul 28, 2011

lore
Share & tools
lore
#0 lore raw

Hi All,

I have no idea about the MIPS ABI (or which one I am actually using). I try to run Qt/Embedded using the linux-user target and have some issues with the code.

For semctl qemu enters through the do_ipc method, it appears to be that the 'variable' ptr is really a ptr (to the stack) and needs to be dereferenced. The below snippet seems to fix that issue for me.

My next problem is with do_shmctl, somehow third is NULL but it should point to the out parameter (and the application is doing this correctly as well). While trying to understand the issue it looks like target_to_host_shmid_ds will not properly unlock the struct on all paths.

Is the IPC emulation supposed to work? Is this an 'obvious' API issue for MIPS?

@@ -2873,7 +2886,13 @@ static abi_long do_ipc(

         break;
 
     case IPCOP_semctl:

- ret = do_semctl(first, second, third, (union \n
target_semun)(abi_ulong) ptr);
+ if (!lock_user_struct(VERIFY_READ, semun, ptr, 1))
+ ret = -TARGET_EFAULT;
+ else {

+               __get_user(t_semun.buf, &semun->buf);
+               ret = do_semctl(first, second, third, t_semun);
+               unlock_user_struct(semun, ptr, 0);
+       }
         break;
#1 lore raw
Quoted 5 lines · Holger Freyther

For semctl qemu enters through the do_ipc method, it appears to be that the 'variable' ptr is really a ptr (to the stack) and needs to be dereferenced. The below snippet seems to fix that issue for me.

Quoted 8 lines

My next problem is with do_shmctl, somehow third is NULL but it should point to the out parameter (and the application is doing this correctly as well). While trying to understand the issue it looks like target_to_host_shmid_ds will not properly unlock the struct on all paths.

Is the IPC emulation supposed to work? Is this an 'obvious' API issue for MIPS?

The ltp testsuite has many semaphore and other ipc tests. Comparing results of running the same ltp binaries on real mips and qemu-mips should quickly reveal which syscall emulations are broken. And provide a good testcase for fixes.

Quoted 4 lines
(quoted diff) +0 -0
@@ -2873,7 +2886,13 @@ static abi_long do_ipc(
         break;
 
     case IPCOP_semctl:

Review static abi_long do_ipc( · line 2897

Quoted 10 lines
(quoted diff) +7 -1
-        ret = do_semctl(first, second, third, (union \n
 target_semun)(abi_ulong) ptr);
+        if (!lock_user_struct(VERIFY_READ, semun, ptr, 1))
+               ret = -TARGET_EFAULT;
+       else {
+               __get_user(t_semun.buf, &semun->buf);
+               ret = do_semctl(first, second, third, t_semun);
+               unlock_user_struct(semun, ptr, 0);
+       }
         break;

This looks from a quick view a correct fix.