From owner-freebsd-emulation@freebsd.org Sun Jan 6 05:16:02 2019 Return-Path: Delivered-To: freebsd-emulation@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E40281435870 for ; Sun, 6 Jan 2019 05:16:01 +0000 (UTC) (envelope-from marklmi@yahoo.com) Received: from sonic301-30.consmr.mail.ne1.yahoo.com (sonic301-30.consmr.mail.ne1.yahoo.com [66.163.184.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9BEC38933D for ; Sun, 6 Jan 2019 05:16:00 +0000 (UTC) (envelope-from marklmi@yahoo.com) X-YMail-OSG: K3siBVEVM1mKmInREghJ4j9LGRe3n769QmR0HPI7RfuOKTMdENjM..wcazcmhMz lDG_hxcl02h9D1koLOz2r0TOCV2Ccrf7z4wfwSyzziMpu49vtpcVjNamins_Fva98.4XunzFauyy 73TdEHfhjWSRM3H5ABG3creVDg10e_ZtoLXk7X7OS8qZBgpSJ5nPf479ssHsMNRUY3NjGg.4iHZs tCtbU3CnP4v.lPRla6jT31jTqLJcd08.t.56U3tbSJF2SkeCpR9f8L4jQz9ZO94BrmtWxKhNlFRa Bs4iDX4UI8jY4rF.pMA7SHnYHBnxeW84Rjh11QC07zpYZvSp1JqsPO6sFZyrkUK2dONr300q8Ne4 XlIraNcapTaXWiAgOsi.ZfxelU32II4ANr2_TgidY3wQBovVC.7VTqHrwigshG2Ff.kADOCf.a95 WwJKrdBWQIfMecEfghtaqbvbLQerXO.HEsGXjN4YSaTGa0zQltzYffR820PujMytdYSkl55h_5_F XuROJqKKaT0CfCGG2oUHKQPEeFVZk5g2inpbYNeuneoA4Zvgho7fcgXwhUbtXHWqNzRTFtj2iUNQ tIYnW9IVbe7V3e_qeIyuKN.cbwR1mp8HPrBxAcdFzybeCngvXj2UzPFakJpbUCTUQSH6PC9YFj0f yCrqUZHz3W3SfsQogGPjCVPZ7IUfvNd7qsq4cOJVbv9at2GcHTcp8bGvMNp.uOF0nHm3xdnmlItw gv2gLMKVnQ.btdEXo3Ya4AoB8fZoS89HNjxXVm1F34cebegdBgn2W0Vo5B0RnZgUJq29JpaEpB_E lV5nzCpEhOuKX7mh4g5pEdHgQO8mnEd634RQ2XQvTHUu4.bMyRUDxt82DzS6MdFdVN0VbK_KG5jd oMMmrs.ypwlPcrs25bkwq6nxBLUCyczLElyNdMM3_ksub.H6QzXrsSUglRp56aAYpNlHA9C5V5hi RQ6kWiZqFe4svbpzA41ulf99dsb0KdyL6VrzQ870qQefT42eTApprN4l1P5Uwc2TujCEqOWz4Psq PMpHPknvSGuc58wKwyy4082.QMKl5mfKQTIAqCal9GFIKElKI3L98DC8CmsoW9eU.xcILaRJvlHE Wm8tf6YHvqQ-- Received: from sonic.gate.mail.ne1.yahoo.com by sonic301.consmr.mail.ne1.yahoo.com with HTTP; Sun, 6 Jan 2019 05:15:53 +0000 Received: from c-67-170-167-181.hsd1.or.comcast.net (EHLO [192.168.1.109]) ([67.170.167.181]) by smtp409.mail.ne1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 8cab793bfb3bbecbcae688229725c3cd; Sun, 06 Jan 2019 05:15:52 +0000 (UTC) From: Mark Millard Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: qemu-arm-static has target_freebsd11_nstat too small vs. arm native's struct nstat Message-Id: <62F581E3-EBB6-4980-BD20-4E121D64BBC5@yahoo.com> Date: Sat, 5 Jan 2019 21:15:51 -0800 Cc: Sean Bruno , freebsd-arm To: Kyle Evans , freebsd-emulation@freebsd.org, ports-list freebsd X-Mailer: Apple Mail (2.3445.102.3) X-Rspamd-Queue-Id: 9BEC38933D X-Spamd-Bar: + X-Spamd-Result: default: False [1.08 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ptr:yahoo.com]; MV_CASE(0.50)[]; FREEMAIL_FROM(0.00)[yahoo.com]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[yahoo.com:+]; MX_GOOD(-0.01)[cached: mta6.am0.yahoodns.net]; DMARC_POLICY_ALLOW(-0.50)[yahoo.com,reject]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[yahoo.com]; ASN(0.00)[asn:36646, ipnet:66.163.184.0/21, country:US]; MID_RHS_MATCH_FROM(0.00)[]; DWL_DNSWL_NONE(0.00)[yahoo.com.dwl.dnswl.org : 127.0.5.0]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[yahoo.com:s=s2048]; FROM_HAS_DN(0.00)[]; NEURAL_SPAM_SHORT(0.97)[0.972,0]; NEURAL_HAM_LONG(-0.63)[-0.628,0]; MIME_GOOD(-0.10)[text/plain]; IP_SCORE(1.07)[ip: (3.47), ipnet: 66.163.184.0/21(1.09), asn: 36646(0.87), country: US(-0.08)]; NEURAL_SPAM_MEDIUM(0.17)[0.175,0]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[199.184.163.66.list.dnswl.org : 127.0.5.0] X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Jan 2019 05:16:02 -0000 [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 nstat) =3D %lu\n", (unsigned long) = sizeof(struct nstat)); printf("st_dev %lu\n", (unsigned long) offsetof(struct nstat, = st_dev)); printf("st_ino %lu\n", (unsigned long) offsetof(struct nstat, = st_ino)); printf("st_mode %lu\n", (unsigned long) offsetof(struct nstat, = st_mode)); printf("st_nlink %lu\n", (unsigned long) offsetof(struct nstat, = st_nlink)); printf("st_uid %lu\n", (unsigned long) offsetof(struct nstat, = st_uid)); printf("st_gid %lu\n", (unsigned long) offsetof(struct nstat, = st_gid)); printf("st_rdev %lu\n", (unsigned long) offsetof(struct nstat, = st_rdev)); printf("st_atim %lu\n", (unsigned long) offsetof(struct nstat, = st_atim)); printf("st_mtim %lu\n", (unsigned long) offsetof(struct nstat, = st_mtim)); printf("st_ctim %lu\n", (unsigned long) offsetof(struct nstat, = st_ctim)); printf("st_size %lu\n", (unsigned long) offsetof(struct nstat, = st_size)); printf("st_blocks %lu\n", (unsigned long) offsetof(struct nstat, = st_blocks)); printf("st_blksize %lu\n", (unsigned long) offsetof(struct = nstat, st_blksize)); printf("st_flags %lu\n", (unsigned long) offsetof(struct nstat, = st_flags)); printf("st_gen %lu\n", (unsigned long) offsetof(struct nstat, = st_gen)); printf("st_birthtim %lu\n", (unsigned long) offsetof(struct = nstat, st_birthtim)); produces: sizeof(struct nstat) =3D 128 st_dev 0 st_ino 4 st_mode 8 st_nlink 12 st_uid 16 st_gid 20 st_rdev 24 st_atim 32 st_mtim 48 st_ctim 64 st_size 80 st_blocks 88 st_blksize 96 st_flags 100 st_gen 104 st_birthtim 112 However gdb reports for qemu-arm-static (on amd64): (gdb) p/d sizeof(struct target_freebsd11_nstat) $41 =3D 116 (gdb) p/d &((struct target_freebsd11_nstat *)0)->st_dev =20 $42 =3D 0 (gdb) p/d &((struct target_freebsd11_nstat *)0)->st_ino $43 =3D 4 (gdb) p/d &((struct target_freebsd11_nstat *)0)->st_mode $44 =3D 8 (gdb) p/d &((struct target_freebsd11_nstat *)0)->st_nlink $45 =3D 10 (gdb) p/d &((struct target_freebsd11_nstat *)0)->st_uid =20 $46 =3D 12 (gdb) p/d &((struct target_freebsd11_nstat *)0)->st_gid $47 =3D 16 (gdb) p/d &((struct target_freebsd11_nstat *)0)->st_rdev $48 =3D 20 (gdb) p/d &((struct target_freebsd11_nstat *)0)->st_atim $49 =3D 24 (gdb) p/d &((struct target_freebsd11_nstat *)0)->st_mtim =20 $50 =3D 40 (gdb) p/d &((struct target_freebsd11_nstat *)0)->st_ctim $51 =3D 56 (gdb) p/d &((struct target_freebsd11_nstat *)0)->st_size =20 $52 =3D 72 (gdb) p/d &((struct target_freebsd11_nstat *)0)->st_blocks $53 =3D 80 (gdb) p/d &((struct target_freebsd11_nstat *)0)->st_blksize $54 =3D 88 (gdb) p/d &((struct target_freebsd11_nstat *)0)->st_flags =20 $55 =3D 92 (gdb) p/d &((struct target_freebsd11_nstat *)0)->st_gen =20 $56 =3D 96 (gdb) p/d &((struct target_freebsd11_nstat *)0)->st_birthtim $57 =3D 100 So after st_mode the offsets are wrong relative to struct nstat (native to armv7). /usr/include/sys/stat.h has: struct nstat { __uint32_t st_dev; /* inode's device */ __uint32_t st_ino; /* inode's number */ __uint32_t st_mode; /* inode protection mode */ __uint32_t st_nlink; /* number of hard links */ uid_t st_uid; /* user ID of the file's owner = */ gid_t st_gid; /* group ID of the file's group = */ __uint32_t st_rdev; /* device type */ struct timespec st_atim; /* time of last access */ struct timespec st_mtim; /* time of last data = modification */ struct timespec st_ctim; /* time of last file status = change */ off_t st_size; /* file size, in bytes */ blkcnt_t st_blocks; /* blocks allocated for file */ blksize_t st_blksize; /* optimal blocksize for I/O */ fflags_t st_flags; /* user defined flags for file = */ __uint32_t st_gen; /* file generation number */ struct timespec st_birthtim; /* time of file creation */ /* * See comment in the definition of struct freebsd11_stat * above about the following padding. */ unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec)); unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec)); }; = /wrkdirs/usr/ports/emulators/qemu-user-static/work/qemu-bsd-user-4ef7d07/b= sd-user/syscall_defs.h has: struct target_freebsd11_nstat { uint32_t st_dev; /* inode's device */ uint32_t st_ino; /* inode's number */ int16_t st_mode; /* inode protection mode */ int16_t st_nlink; /* number of hard links */ uint32_t st_uid; /* user ID of the file's owner */ uint32_t st_gid; /* group ID of the file's group */ uint32_t st_rdev; /* device type */ struct target_freebsd_timespec st_atim; /* time last accessed */ struct target_freebsd_timespec st_mtim; /* time last data = modification */ struct target_freebsd_timespec st_ctim; /* time last file status = change */ int64_t st_size; /* file size, in bytes */ int64_t st_blocks; /* blocks allocated for file */ uint32_t st_blksize; /* optimal blocksize for I/O */ uint32_t st_flags; /* user defined flags for file */ __uint32_t st_gen; /* file generation number */ /* __int32_t st_lspare; */ struct target_freebsd_timespec st_birthtim; /* time of file creation = */ /* * Explicitly pad st_birthtim to 16 bytes so that the size of * struct stat is backwards compatible. We use bitfields instead * of an array of chars so that this doesn't require a C99 compiler * to compile if the size of the padding is 0. We use 2 bitfields * to cover up to 64 bits on 32-bit machines. We assume that * CHAR_BIT is 8... */ unsigned int:(8 / 2) * (16 - (int)sizeof(struct = target_freebsd_timespec)); unsigned int:(8 / 2) * (16 - (int)sizeof(struct = target_freebsd_timespec)); } __packed; There are multiple issues here, for example: __uint32_t (native nstat) = vs. int16_t (target_nstat) for st_mode. Similarly for st_nlink. And there is = __packed changing the padding for another example. =3D=3D=3D Mark Millard marklmi at yahoo.com ( dsl-only.net went away in early 2018-Mar)