From owner-freebsd-ports@freebsd.org Mon Dec 31 01:26:16 2018 Return-Path: Delivered-To: freebsd-ports@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 44A0D143D206 for ; Mon, 31 Dec 2018 01:26:16 +0000 (UTC) (envelope-from marklmi@yahoo.com) Received: from sonic314-14.consmr.mail.bf2.yahoo.com (sonic314-14.consmr.mail.bf2.yahoo.com [74.6.132.124]) (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 8649C77032 for ; Mon, 31 Dec 2018 01:26:14 +0000 (UTC) (envelope-from marklmi@yahoo.com) X-YMail-OSG: GCCA8DAVM1kUKxhiZC8K8BRc3IuZ3yLJKqIXG.4_x_.P8EH8M7AagoQvnyA5vTG 5AvuN8stcgjNaxL9Z1HIvS79Yf0mnvF8yWwGNK9H6I22rLXQr2cvQYUyBzb2NHeyKzEhNkF.I7gf AT1gqwO8UQnMy.f1xseIx2lRfJkWnUWBs_paoelClh02aNIc3k9EY0r_VbabEIO7CzEcCfYCRP2l Ixws9HIw2mjF6Se.Hx2WqSXUaVb8E6RvQ6e3q6dhZ1C_C4hXbjVCu6pTCPL0X1EaVq39iWMvt5Ax fGIfgOZjZoGrc._pWtdtDh2v5bncKvsKRtrb1Zvy3tIq22USMlsBVWA_e_PuStLvnJ.sqae.XQ7V zh9MCPnhpvnoyqnQYpnfaBk4kx9zMU5VYMu.gvvJdGrrH6R0D4EmwDuSe_uW3dT4ol0q1qXdSlA0 vPO0WFE_pPYCyvY8K6Zi7G.L2Be3AwqPdu.1a2dQgCLmUrl79701SNNnSXakEW6ZGknARz9bIpos .9Y0n6yjA5L8Rbc7MyTr2bH8ZlaUS64_Ruwxr6gSZMEaKI1lCnDt5Foc0uckzQ3nFNU9ZyZ.JShv pPjfq1vTyBQgQOX9VT_fivUoIzeKMEnE_ssLiLtNCaaYkaaHePGd_qB.JH2.cNhlaYTDFsTkJICT gYph1la6EJ3H3Vw_9_rzr3HlZ42tPP_nx9F1TY0cjjsCAchArofoNlvGR20iSDJmqw8W2NnxWySG SLqtcoRlD0r3zTxeysQF1Bg5Es0fgnHdnK7oBJ7IXrIWGIaDxqIPAIBE1MEaPqhKG9sFwUkCBQS3 OZ7FyYGxbEcgBTBjTawK2zxNK6povtllziHMruDNUD1dMfjSV.Iq5KerMx5N8_XQUkDW1EOdWS2t RzOFeJTi8LzkH8K7ZkzZTrWjnlcBicPFnD2P0StLY_u9yUzHwyEDWTiKqYGc1BtGUVicKersZZCP Zz2TZD3eMQmwUktY5oQf9gnEPj37V6KQZEbhPWjXdMik47gtXxU5JGLD._BtPwN_I0UR8uHwgWn8 LjRqP9RCh_FovgCix9YUfMf6RTes7Jg0TnRGkTO_tc7YFQeWCt4mSY1UNWd_g9Lj2BiImZLE0VMg - Received: from sonic.gate.mail.ne1.yahoo.com by sonic314.consmr.mail.bf2.yahoo.com with HTTP; Mon, 31 Dec 2018 01:26:08 +0000 Received: from c-67-170-167-181.hsd1.or.comcast.net (EHLO [192.168.1.109]) ([67.170.167.181]) by smtp403.mail.bf1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 04ffb892c2e4a018446db2706dc31fd2; Mon, 31 Dec 2018 01:26:04 +0000 (UTC) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: Re: A reliable port cross-build failure (hangup) in my context (amd64->armv7 cross build, with native-tool speedup involved) [details of a specific qemu-arm-static source code problem] From: Mark Millard In-Reply-To: Date: Sun, 30 Dec 2018 17:26:01 -0800 Cc: freebsd-emulation@freebsd.org, FreeBSD Current , ports-list freebsd , freebsd-arm , FreeBSD Toolchain Content-Transfer-Encoding: quoted-printable Message-Id: References: <865A13C8-9749-486E-9F79-5EEDDECBE621@yahoo.com> <0154C3AC-D85B-4FCF-BA63-454BC26BC1A2@yahoo.com> <13f5e4dd-33fb-2170-e31a-1b5d5f155869@freebsd.org> <2E3F6196-4652-40D2-937F-8860B6005A35@yahoo.com> To: mmel@freebsd.org X-Mailer: Apple Mail (2.3445.102.3) X-Rspamd-Queue-Id: 8649C77032 X-Spamd-Bar: ++ X-Spamd-Result: default: False [2.01 / 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)[6]; 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:26101, ipnet:74.6.128.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)[]; NEURAL_HAM_MEDIUM(-0.10)[-0.098,0]; R_DKIM_ALLOW(-0.20)[yahoo.com:s=s2048]; FROM_HAS_DN(0.00)[]; NEURAL_SPAM_SHORT(0.90)[0.904,0]; MIME_GOOD(-0.10)[text/plain]; IP_SCORE(1.58)[ip: (5.23), ipnet: 74.6.128.0/21(1.54), asn: 26101(1.23), country: US(-0.08)]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_SPAM_LONG(0.13)[0.125,0]; RCVD_IN_DNSWL_NONE(0.00)[124.132.6.74.list.dnswl.org : 127.0.5.0] X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Dec 2018 01:26:16 -0000 [Removing __packed did make the size and offsets match armv7 and the build worked based on the reconstructed qemu-arm-static.] On 2018-Dec-30, at 16:38, Mark Millard wrote: > On 2018-Dec-28, at 12:12, Mark Millard wrote: >=20 >> On 2018-Dec-28, at 05:13, Michal Meloun = wrote: >>=20 >>> Mark, >>> this is known problem with qemu-user-static. >>> Emulation of every single interruptible syscall is broken by design = (it >>> have signal related races). Theses races cannot be solved without = major >>> rewrite of syscall emulation code. >>> Unfortunately, nobody actively works on this, I think. >>>=20 >>=20 >> Thanks for the note setting some expectations. >> . . . >=20 >=20 > It turns out that I've been through (part of?) this before and > mikael.urankar@gmail.com had back then provided a qemu-user-static > patch (that might have been arm specific or 32-bit target specific > when running on a 64-bit host). (The qemu-user-static code structure > seems to have changed some afterwards and the patch is no longer > where he had pointed me to back then.) >=20 > To show size and offsets on armv7 vs. armd64 for struct kevent > I use: >=20 > # more kevent_size_offsets.c=20 > #include "/usr/include/sys/event.h" // kevent > #include // offsetof > #include // printf >=20 > int > main() > { > printf("%lu\n", (unsigned long) sizeof(struct kevent)); > printf("ident %lu\n", (unsigned long) offsetof(struct kevent, = ident)); > printf("filter %lu\n", (unsigned long) offsetof(struct kevent, = filter)); > printf("flags %lu\n", (unsigned long) offsetof(struct kevent, = flags)); > printf("fflags %lu\n", (unsigned long) offsetof(struct kevent, = fflags)); > printf("data %lu\n", (unsigned long) offsetof(struct kevent, = data)); > printf("udata %lu\n", (unsigned long) offsetof(struct kevent, = udata)); > printf("ext %lu\n", (unsigned long) offsetof(struct kevent, = ext)); > return 0; > } >=20 > It ends up showing on armv7 (under qemu-arm-static insteead of native, = not > that it matters here): >=20 > # ./a.out > 64 > ident 0 > filter 4 > flags 6 > fflags 8 > data 16 > udata 24 > ext 32 >=20 > On amd64 (native) it ends up as: >=20 > # ./a.out > 64 > ident 0 > filter 8 > flags 10 > fflags 12 > data 16 > udata 24 > ext 32 >=20 > Thus a translation of layout is required when hosted. This is for: >=20 > struct kevent { > __uintptr_t ident; /* identifier for this event */ > short filter; /* filter for event */ > unsigned short flags; /* action flags for kqueue */ > unsigned int fflags; /* filter flag value */ > __int64_t data; /* filter data value */ > void *udata; /* opaque user data identifier = */ > __uint64_t ext[4]; /* extensions */ > }; >=20 > But qemu-user-static has for translation purposes: >=20 > struct target_freebsd_kevent { > abi_ulong ident; > int16_t filter; > uint16_t flags; > uint32_t fflags; > int64_t data; > abi_ulong udata; > uint64_t ext[4]; > } __packed; >=20 > (note the __packed) for which in amd64's qemu_arm_static has > the size and offsets: >=20 > # gdb qemu-arm-static > . . . > (gdb) p/d sizeof(struct target_freebsd_kevent) > $1 =3D 56 > (gdb) p/d &((struct target_freebsd_kevent *)0)->ident > $2 =3D 0 > (gdb) p/d &((struct target_freebsd_kevent *)0)->filter > $3 =3D 4 > (gdb) p/d &((struct target_freebsd_kevent *)0)->flags > $4 =3D 6 > (gdb) p/d &((struct target_freebsd_kevent *)0)->fflags > $5 =3D 8 > (gdb) p/d &((struct target_freebsd_kevent *)0)->data > $6 =3D 12 > (gdb) p/d &((struct target_freebsd_kevent *)0)->udata > $7 =3D 20 > (gdb) p/d &((struct target_freebsd_kevent *)0)->ext > $8 =3D 24 >=20 > which which does not match the armv7 offsets for > data, udata, or ext and does not have the right size > for struct target_freebsd_kevent[] indexing to > match armv7's struct target_freebsd_kevent[] indexing. >=20 > This in turn makes the do_freebsd_kevent code do the wrong > thing in its: >=20 > struct target_freebsd_kevent *target_changelist, *target_eventlist; > . . . > for (i =3D 0; i < arg3; i++) { > __get_user(changelist[i].ident, = &target_changelist[i].ident); > __get_user(changelist[i].filter, = &target_changelist[i].filter); > __get_user(changelist[i].flags, = &target_changelist[i].flags); > __get_user(changelist[i].fflags, = &target_changelist[i].fflags); > __get_user(changelist[i].data, &target_changelist[i].data); > /* __get_user(changelist[i].udata, = &target_changelist[i].udata); */ > #if TARGET_ABI_BITS =3D=3D 32 > changelist[i].udata =3D (void = *)(uintptr_t)target_changelist[i].udata; > tswap32s((uint32_t *)&changelist[i].udata); > #else > changelist[i].udata =3D (void = *)(uintptr_t)target_changelist[i].udata; > tswap64s((uint64_t *)&changelist[i].udata); > #endif > __get_user(changelist[i].ext[0], = &target_changelist[i].ext[0]); > __get_user(changelist[i].ext[1], = &target_changelist[i].ext[1]); > __get_user(changelist[i].ext[2], = &target_changelist[i].ext[2]); > __get_user(changelist[i].ext[3], = &target_changelist[i].ext[3]); > } > . . . > for (i =3D 0; i < arg5; i++) { > __put_user(eventlist[i].ident, &target_eventlist[i].ident); > __put_user(eventlist[i].filter, = &target_eventlist[i].filter); > __put_user(eventlist[i].flags, &target_eventlist[i].flags); > __put_user(eventlist[i].fflags, = &target_eventlist[i].fflags); > __put_user(eventlist[i].data, &target_eventlist[i].data); > /* __put_user(eventlist[i].udata, = &target_eventlist[i].udata);*/ > #if TARGET_ABI_BITS =3D=3D 32 > tswap32s((uint32_t *)&eventlist[i].data); > target_eventlist[i].data =3D (uintptr_t)eventlist[i].data; > #else > tswap64s((uint64_t *)&eventlist[i].data); > target_eventlist[i].data =3D (uintptr_t)eventlist[i].data; > #endif > __put_user(eventlist[i].ext[0], = &target_eventlist[i].ext[0]); > __put_user(eventlist[i].ext[1], = &target_eventlist[i].ext[1]); > __put_user(eventlist[i].ext[2], = &target_eventlist[i].ext[2]); > __put_user(eventlist[i].ext[3], = &target_eventlist[i].ext[3]); > } >=20 >=20 >=20 > I'll eventually do something to have struct target_freebsd_kevent for > amd64-native targeting armv7 and see if that is sufficient to avoid = the > problem in my context. Previously removing the __packed was enough to > make the structure the same size with the same offsets as for armv7. > (Such might not have been appropriate to all targets.) >=20 > armv6 would have the same problem as I understand things. Using commented out __packed in: struct target_freebsd11_kevent { abi_ulong ident; int16_t filter; uint16_t flags; uint32_t fflags; abi_long data; abi_ulong udata; } ; // __packed; struct target_freebsd_kevent { abi_ulong ident; int16_t filter; uint16_t flags; uint32_t fflags; int64_t data; abi_ulong udata; uint64_t ext[4]; } ; // __packed; in = /wrkdirs/usr/ports/emulators/qemu-user-static/work/qemu-bsd-user-4ef7d07/b= sd-user/syscall_defs.h was sufficient to allow the multimedia/gstreamer1-qt@qt5 build to = complete: no more hang-up. So this is likely what is wrong for the packages-builders as well. =3D=3D=3D Mark Millard marklmi at yahoo.com ( dsl-only.net went away in early 2018-Mar)