Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 5 Jan 2019 17:14:27 -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_shmd_ds too small vs. arm native's shmid_ds
Message-ID:  <6B222E96-A644-46A7-9D1C-D164ED465631@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_shmd_ds" is meant to match the memory =
layout
of the target's native "struct shmid_ds". Otherwise the reported =
differences
below could be irrelevant.

For armv7 (and likely armv6) the following code:

        printf("sizeof(struct shmid_ds) =3D %lu\n", (unsigned long) =
sizeof(struct shmid_ds));
        printf("shm_perm %lu\n", (unsigned long) offsetof(struct =
shmid_ds, shm_perm));
        printf("shm_segsz %lu\n", (unsigned long) offsetof(struct =
shmid_ds, shm_segsz));
        printf("shm_lpid %lu\n", (unsigned long) offsetof(struct =
shmid_ds, shm_lpid));
        printf("shm_cpid %lu\n", (unsigned long) offsetof(struct =
shmid_ds, shm_cpid));
        printf("shm_nattch %lu\n", (unsigned long) offsetof(struct =
shmid_ds, shm_nattch));
        printf("shm_atime %lu\n", (unsigned long) offsetof(struct =
shmid_ds, shm_atime));
        printf("shm_dtime %lu\n", (unsigned long) offsetof(struct =
shmid_ds, shm_dtime));
        printf("shm_ctime %lu\n", (unsigned long) offsetof(struct =
shmid_ds, shm_ctime));

produces:

sizeof(struct shmid_ds) =3D 64
shm_perm 0
shm_segsz 24
shm_lpid 28
shm_cpid 32
shm_nattch 36
shm_atime 40
shm_dtime 48
shm_ctime 56

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

(gdb) p/d &((struct target_shmid_ds *)0)->shm_perm
$33 =3D 0
(gdb) p/d &((struct target_shmid_ds *)0)->shm_segsz
$34 =3D 24
(gdb) p/d &((struct target_shmid_ds *)0)->shm_lpid=20
$35 =3D 28
(gdb) p/d &((struct target_shmid_ds *)0)->shm_cpid
$36 =3D 32
(gdb) p/d &((struct target_shmid_ds *)0)->shm_nattch
$37 =3D 36
(gdb) p/d &((struct target_shmid_ds *)0)->shm_atime=20
$38 =3D 40
(gdb) p/d &((struct target_shmid_ds *)0)->shm_dtime
$39 =3D 44
(gdb) p/d &((struct target_shmid_ds *)0)->shm_ctime
$40 =3D 48

so after shm_atime the offsets are different.

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

struct shmid_ds {
        struct ipc_perm shm_perm;       /* operation permission =
structure */
        size_t          shm_segsz;      /* size of segment in bytes */
        pid_t           shm_lpid;   /* process ID of last shared memory =
op */
        pid_t           shm_cpid;       /* process ID of creator */
        shmatt_t        shm_nattch;     /* number of current attaches */
        time_t          shm_atime;      /* time of last shmat() */
        time_t          shm_dtime;      /* time of last shmdt() */
        time_t          shm_ctime;      /* time of last change by =
shmctl() */
};

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

struct target_shmid_ds {
    struct  target_ipc_perm shm_perm; /* peration permission structure =
*/
    abi_ulong   shm_segsz;  /* size of segment in bytes */
    int32_t     shm_lpid;   /* process ID of last shared memory op */
    int32_t     shm_cpid;   /* process ID of creator */
    int32_t     shm_nattch; /* number of current attaches */
    abi_ulong   shm_atime;  /* time of last shmat() */
    abi_ulong   shm_dtime;  /* time of last shmdt() */
    abi_ulong   shm_ctime;  /* time of last change by shmctl() */
};

abi_ulong's for shm_atime, shm_dtime, and shm_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?6B222E96-A644-46A7-9D1C-D164ED465631>