qemu-arm-static has target_shmd_ds too small vs. arm native's shmid_ds
Mark Millard
marklmi at yahoo.com
Sun Jan 6 01:14:42 UTC 2019
[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) = %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) = 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 = 0
(gdb) p/d &((struct target_shmid_ds *)0)->shm_segsz
$34 = 24
(gdb) p/d &((struct target_shmid_ds *)0)->shm_lpid
$35 = 28
(gdb) p/d &((struct target_shmid_ds *)0)->shm_cpid
$36 = 32
(gdb) p/d &((struct target_shmid_ds *)0)->shm_nattch
$37 = 36
(gdb) p/d &((struct target_shmid_ds *)0)->shm_atime
$38 = 40
(gdb) p/d &((struct target_shmid_ds *)0)->shm_dtime
$39 = 44
(gdb) p/d &((struct target_shmid_ds *)0)->shm_ctime
$40 = 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/bsd-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.
===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)
More information about the freebsd-arm
mailing list