qemu-arm-static has target_msqid_ds too small vs. arm natives msqid_ds

Mark Millard marklmi at yahoo.com
Sun Jan 6 00:38:12 UTC 2019


[The context here is FreeBSD head -r341836 based and ports head -r488859 based.]

Note: I assume that "struct target_msqid_ds" is meant to match the memory layout
of the target's native "struct msqid_ds". Otherwise the reported differences
below could be irrelevant.

For armv7 (and likely armv6) the following code:

        printf("sizeof(struct msqid_ds) = %lu\n", (unsigned long) sizeof(struct msqid_ds));
        printf("msg_perm %lu\n", (unsigned long) offsetof(struct msqid_ds, msg_perm));
        printf("__msg_first %lu\n", (unsigned long) offsetof(struct msqid_ds, __msg_first));
        printf("__msg_last %lu\n", (unsigned long) offsetof(struct msqid_ds, __msg_last));
        printf("msg_cbytes %lu\n", (unsigned long) offsetof(struct msqid_ds, msg_cbytes));
        printf("msg_qnum %lu\n", (unsigned long) offsetof(struct msqid_ds, msg_qnum));
        printf("msg_qbytes %lu\n", (unsigned long) offsetof(struct msqid_ds, msg_qbytes));
        printf("msg_lspid %lu\n", (unsigned long) offsetof(struct msqid_ds, msg_lspid));
        printf("msg_lrpid %lu\n", (unsigned long) offsetof(struct msqid_ds, msg_lrpid));
        printf("msg_stime %lu\n", (unsigned long) offsetof(struct msqid_ds, msg_stime));
        printf("msg_rtime %lu\n", (unsigned long) offsetof(struct msqid_ds, msg_rtime));
        printf("msg_ctime %lu\n", (unsigned long) offsetof(struct msqid_ds, msg_ctime));

produces:

sizeof(struct msqid_ds) = 80
msg_perm 0
__msg_first 24
__msg_last 28
msg_cbytes 32
msg_qnum 36
msg_qbytes 40
msg_lspid 44
msg_lrpid 48
msg_stime 56
msg_rtime 64
msg_ctime 72


However gdb reports for qemu-arm-static (on amd64):

(gdb) p/d sizeof(struct target_msqid_ds)
$14 = 64
(gdb) p/d &((struct target_msqid_ds *)0)->msg_first
$15 = 24
(gdb) p/d &((struct target_msqid_ds *)0)->msg_last 
$16 = 28
(gdb) p/d &((struct target_msqid_ds *)0)->msg_cbytes
$17 = 32
(gdb) p/d &((struct target_msqid_ds *)0)->msg_qnum  
$18 = 36
(gdb) p/d &((struct target_msqid_ds *)0)->msg_qbytes
$19 = 40
(gdb) p/d &((struct target_msqid_ds *)0)->msg_lspid 
$20 = 44
(gdb) p/d &((struct target_msqid_ds *)0)->msg_lrpid
$21 = 48
(gdb) p/d &((struct target_msqid_ds *)0)->msg_stime
$22 = 52
(gdb) p/d &((struct target_msqid_ds *)0)->msg_rtime
$23 = 56
(gdb) p/d &((struct target_msqid_ds *)0)->msg_ctime
$24 = 60

so after msg_lrpid the offsets are different.

/usr/include/sys/msg.h has:

struct msqid_ds {
        struct  ipc_perm msg_perm;      /* msg queue permission bits */
        struct  msg *__msg_first;       /* first message in the queue */
        struct  msg *__msg_last;        /* last message in the queue */
        msglen_t msg_cbytes;    /* number of bytes in use on the queue */
        msgqnum_t msg_qnum;     /* number of msgs in the queue */
        msglen_t msg_qbytes;    /* max # of bytes on the queue */
        pid_t   msg_lspid;      /* pid of last msgsnd() */
        pid_t   msg_lrpid;      /* pid of last msgrcv() */
        time_t  msg_stime;      /* time of last msgsnd() */
        time_t  msg_rtime;      /* time of last msgrcv() */
        time_t  msg_ctime;      /* time of last msgctl() */
};

/wrkdirs/usr/ports/emulators/qemu-user-static/work/qemu-bsd-user-4ef7d07/bsd-user/syscall_defs.h
has:

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() */
    abi_ulong   msg_stime;  /* time of last msgsnd() */
    abi_ulong   msg_rtime;  /* time of last msgrcv() */
    abi_ulong   msg_ctime;  /* time of last msgctl() */
};

abi_ulong's for msg_stime, msg_rtime, and msg_ctime are the wrong
size for armv7: arm uses 64-bit time_t. As of 12+ only i386
uses 32-bit time_t if I understand right. In 11.x 32-bit powerpc
also uses 32-bit time_t.

===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)



More information about the freebsd-ports mailing list