All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] mips-linux-user and POSIX IPC
@ 2011-07-26  8:56 Holger Freyther
  2011-07-28 15:25 ` Riku Voipio
  0 siblings, 1 reply; 2+ messages in thread
From: Holger Freyther @ 2011-07-26  8:56 UTC (permalink / raw)
  To: qemu-devel

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;
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] mips-linux-user and POSIX IPC
  2011-07-26  8:56 [Qemu-devel] mips-linux-user and POSIX IPC Holger Freyther
@ 2011-07-28 15:25 ` Riku Voipio
  0 siblings, 0 replies; 2+ messages in thread
From: Riku Voipio @ 2011-07-28 15:25 UTC (permalink / raw)
  To: Holger Freyther; +Cc: qemu-devel

On Tue, Jul 26, 2011 at 08:56:38AM +0000, Holger Freyther wrote:
> 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?

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.

> @@ -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;

This looks from a quick view a correct fix.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-07-28 15:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-26  8:56 [Qemu-devel] mips-linux-user and POSIX IPC Holger Freyther
2011-07-28 15:25 ` Riku Voipio

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.