[PATCH 03/24] bsd-user: Add target_semid_ds and target_msqid_ds structures

Warner Losh posted 24 patches 3 days, 15 hours ago
Maintainers: Warner Losh <imp@bsdimp.com>, Kyle Evans <kevans@freebsd.org>, Riku Voipio <riku.voipio@iki.fi>, Paolo Bonzini <pbonzini@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>
There is a newer version of this series
[PATCH 03/24] bsd-user: Add target_semid_ds and target_msqid_ds structures
Posted by Warner Losh 3 days, 15 hours ago
Add the target ABI definitions for System V semaphore and message queue
data structures, needed for semctl() and msgctl() syscall emulation.

Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Mikael Urankar <mikael.urankar@gmail.com>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/syscall_defs.h | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/bsd-user/syscall_defs.h b/bsd-user/syscall_defs.h
index cc4b484f3a..98bdf8cc1a 100644
--- a/bsd-user/syscall_defs.h
+++ b/bsd-user/syscall_defs.h
@@ -92,6 +92,39 @@ struct bsd_shm_regions {
     abi_long size;
 };
 
+/*
+ * sys/sem.h
+ */
+struct target_semid_ds {
+    struct target_ipc_perm sem_perm; /* operation permission struct */
+    abi_ulong   sem_base;   /* pointer to first semaphore in set */
+    uint16_t    sem_nsems;  /* number of sems in set */
+    target_time_t   sem_otime;  /* last operation time */
+    target_time_t   sem_ctime;  /* times measured in secs */
+};
+
+/*
+ * sys/msg.h
+ */
+struct target_msqid_ds {
+    struct  target_ipc_perm msg_perm; /* msg queue permission bits */
+    abi_ulong   msg_first;  /* first message in the queue */
+    abi_ulong   msg_last;   /* last message in the queue */
+    abi_ulong   msg_cbytes; /* # of bytes in use on the queue */
+    abi_ulong   msg_qnum;   /* number of msgs in the queue */
+    abi_ulong   msg_qbytes; /* max # of bytes on the queue */
+    int32_t     msg_lspid;  /* pid of last msgsnd() */
+    int32_t     msg_lrpid;  /* pid of last msgrcv() */
+    target_time_t   msg_stime;  /* time of last msgsnd() */
+    target_time_t   msg_rtime;  /* time of last msgrcv() */
+    target_time_t   msg_ctime;  /* time of last msgctl() */
+};
+
+struct target_msgbuf {
+    abi_long    mtype;      /* message type */
+    char        mtext[1];   /* body of message */
+};
+
 /*
  *  sys/mman.h
  */

-- 
2.52.0
Re: [PATCH 03/24] bsd-user: Add target_semid_ds and target_msqid_ds structures
Posted by Richard Henderson 3 days, 8 hours ago
On 2/6/26 03:26, Warner Losh wrote:
> Add the target ABI definitions for System V semaphore and message queue
> data structures, needed for semctl() and msgctl() syscall emulation.
> 
> Signed-off-by: Stacey Son <sson@FreeBSD.org>
> Signed-off-by: Mikael Urankar <mikael.urankar@gmail.com>
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> ---
>   bsd-user/syscall_defs.h | 33 +++++++++++++++++++++++++++++++++
>   1 file changed, 33 insertions(+)
> 
> diff --git a/bsd-user/syscall_defs.h b/bsd-user/syscall_defs.h
> index cc4b484f3a..98bdf8cc1a 100644
> --- a/bsd-user/syscall_defs.h
> +++ b/bsd-user/syscall_defs.h
> @@ -92,6 +92,39 @@ struct bsd_shm_regions {
>       abi_long size;
>   };
>   
> +/*
> + * sys/sem.h
> + */
> +struct target_semid_ds {
> +    struct target_ipc_perm sem_perm; /* operation permission struct */
> +    abi_ulong   sem_base;   /* pointer to first semaphore in set */

While they'll be the same underlying type, abi_ptr is "more correct".

> +    uint16_t    sem_nsems;  /* number of sems in set */

abi_ushort.

> +struct target_msqid_ds {
> +    struct  target_ipc_perm msg_perm; /* msg queue permission bits */
> +    abi_ulong   msg_first;  /* first message in the queue */
> +    abi_ulong   msg_last;   /* last message in the queue */

Both abi_ptr.


r~
Re: [PATCH 03/24] bsd-user: Add target_semid_ds and target_msqid_ds structures
Posted by Warner Losh 3 days, 6 hours ago
On Thu, Feb 5, 2026 at 5:15 PM Richard Henderson <
richard.henderson@linaro.org> wrote:

> On 2/6/26 03:26, Warner Losh wrote:
> > Add the target ABI definitions for System V semaphore and message queue
> > data structures, needed for semctl() and msgctl() syscall emulation.
> >
> > Signed-off-by: Stacey Son <sson@FreeBSD.org>
> > Signed-off-by: Mikael Urankar <mikael.urankar@gmail.com>
> > Signed-off-by: Warner Losh <imp@bsdimp.com>
> > ---
> >   bsd-user/syscall_defs.h | 33 +++++++++++++++++++++++++++++++++
> >   1 file changed, 33 insertions(+)
> >
> > diff --git a/bsd-user/syscall_defs.h b/bsd-user/syscall_defs.h
> > index cc4b484f3a..98bdf8cc1a 100644
> > --- a/bsd-user/syscall_defs.h
> > +++ b/bsd-user/syscall_defs.h
> > @@ -92,6 +92,39 @@ struct bsd_shm_regions {
> >       abi_long size;
> >   };
> >
> > +/*
> > + * sys/sem.h
> > + */
> > +struct target_semid_ds {
> > +    struct target_ipc_perm sem_perm; /* operation permission struct */
> > +    abi_ulong   sem_base;   /* pointer to first semaphore in set */
>
> While they'll be the same underlying type, abi_ptr is "more correct".
>
> > +    uint16_t    sem_nsems;  /* number of sems in set */
>
> abi_ushort.
>
> > +struct target_msqid_ds {
> > +    struct  target_ipc_perm msg_perm; /* msg queue permission bits */
> > +    abi_ulong   msg_first;  /* first message in the queue */
> > +    abi_ulong   msg_last;   /* last message in the queue */
>
> Both abi_ptr.
>


Nice catch on all of these. Will fix in v2.

Warner

>
> r~
>
>