Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 5 Jan 2019 16:37:59 -0800
From:      Mark Millard <marklmi@yahoo.com>
To:        Kyle Evans <kevans@FreeBSD.org>, freebsd-emulation@freebsd.org, ports-list freebsd <freebsd-ports@freebsd.org>
Cc:        Sean Bruno <sbruno@freebsd.org>, freebsd-arm <freebsd-arm@freebsd.org>
Subject:   qemu-arm-static has target_msqid_ds too small vs. arm natives msqid_ds
Message-ID:  <C10A9B6F-3FC6-4B10-B883-593895985683@yahoo.com>

next in thread | raw e-mail | index | archive | help
[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) =3D %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) =3D 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 =3D 64
(gdb) p/d &((struct target_msqid_ds *)0)->msg_first
$15 =3D 24
(gdb) p/d &((struct target_msqid_ds *)0)->msg_last=20
$16 =3D 28
(gdb) p/d &((struct target_msqid_ds *)0)->msg_cbytes
$17 =3D 32
(gdb) p/d &((struct target_msqid_ds *)0)->msg_qnum =20
$18 =3D 36
(gdb) p/d &((struct target_msqid_ds *)0)->msg_qbytes
$19 =3D 40
(gdb) p/d &((struct target_msqid_ds *)0)->msg_lspid=20
$20 =3D 44
(gdb) p/d &((struct target_msqid_ds *)0)->msg_lrpid
$21 =3D 48
(gdb) p/d &((struct target_msqid_ds *)0)->msg_stime
$22 =3D 52
(gdb) p/d &((struct target_msqid_ds *)0)->msg_rtime
$23 =3D 56
(gdb) p/d &((struct target_msqid_ds *)0)->msg_ctime
$24 =3D 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/b=
sd-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.

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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?C10A9B6F-3FC6-4B10-B883-593895985683>