Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 5 Jan 2019 17:02:13 -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_semd_ds too small vs. arm natives semid_ds
Message-ID:  <3480CAB5-6F8C-4160-97C7-AF38A5F55078@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_semd_ds" is meant to match the memory =
layout
of the target's native "struct semid_ds". Otherwise the reported =
differences
below could be irrelevant.

For armv7 (and likely armv6) the following code:

        printf("sizeof(struct semid_ds) =3D %lu\n", (unsigned long) =
sizeof(struct semid_ds));
        printf("sem_perm %lu\n", (unsigned long) offsetof(struct =
semid_ds, sem_perm));
        printf("__sem_base %lu\n", (unsigned long) offsetof(struct =
semid_ds, __sem_base));
        printf("sem_nsems %lu\n", (unsigned long) offsetof(struct =
semid_ds, sem_nsems));
        printf("sem_otime %lu\n", (unsigned long) offsetof(struct =
semid_ds, sem_otime));
        printf("sem_ctime %lu\n", (unsigned long) offsetof(struct =
semid_ds, sem_ctime));
=20
produces:

sizeof(struct semid_ds) =3D 48
sem_perm 0
__sem_base 24
sem_nsems 28
sem_otime 32
sem_ctime 40

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

(gdb) p/d sizeof(struct target_semid_ds)
$25 =3D 40
(gdb) p/d &((struct target_semid_ds *)0)->sem_perm=20
$26 =3D 0
(gdb) p/d &((struct target_semid_ds *)0)->sem_base =20
$27 =3D 24
(gdb) p/d &((struct target_semid_ds *)0)->sem_nsems
$28 =3D 28
(gdb) p/d &((struct target_semid_ds *)0)->sem_otime
$29 =3D 32
(gdb) p/d &((struct target_semid_ds *)0)->sem_ctime
$30 =3D 36

so after sem_otime the offsets are different.

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

struct semid_ds {
        struct ipc_perm sem_perm;       /* operation permission struct =
*/
        struct sem      *__sem_base;    /* pointer to first semaphore in =
set */
        unsigned short  sem_nsems;      /* number of sems in set */
        time_t          sem_otime;      /* last operation time */
        time_t          sem_ctime;      /* last change time */
                                        /* Times measured in secs since =
*/
                                        /* 00:00:00 UTC, Jan. 1, 1970, =
without leap seconds */
};

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

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 */
    abi_ulong   sem_otime;  /* last operation time */
    abi_ulong   sem_ctime;  /* times measured in secs */
};

abi_ulong's for sem_otime, and sem_otime 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?3480CAB5-6F8C-4160-97C7-AF38A5F55078>