From owner-freebsd-arm@freebsd.org Fri Jan 4 09:18:06 2019 Return-Path: Delivered-To: freebsd-arm@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 6A53D142262F for ; Fri, 4 Jan 2019 09:18:06 +0000 (UTC) (envelope-from marklmi@yahoo.com) Received: from sonic317-29.consmr.mail.bf2.yahoo.com (sonic317-29.consmr.mail.bf2.yahoo.com [74.6.129.84]) (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 7E95687DA8 for ; Fri, 4 Jan 2019 09:18:05 +0000 (UTC) (envelope-from marklmi@yahoo.com) X-YMail-OSG: _omNhBkVM1nZlTPAtL0PP1wCtfNJzm.2ufgw0cCLxwF8784wVfEjWFNhkuXFUbA eNjtNjZbC8eIadw6j50TFf_MSrs2dEKSOUBbBCkcvP.5cYzsxF3EWEvjvB3yn1xmBDkbTxebZ7Fx gRab.4LLSC_G8WV1jP9Zt_3zEQ56VjDeF6H1Zs2ZsEl7QwFCAKpX1psS8Y1eZZuAA1x.MiAmCybu oLKlhouxv8ctmMW8bQ_2tluYjOWJF2SOyvGgBQdfG1ciuxWKoOYIRuu9MbYJw.5xrB3DhjiBydIu pYpqvqvso1jakGrwMzpu1Q8gBwR71YE6FvLdsoM32tz8rxtUXRoHcQxhQM2FNc5LNj8iMLn40MIn pA0g11N6FNZZO8Rg45CgrJXZkJLRP_6lmcwXIDFLT7zRQdUJv4w65FZw.bkGLskfFY14LCPNOwyw Vn_sAcjAmmFk9tGkQ5.nTLWSG3TdaW1I3ymKsPjvYAMOsuPoSAGHnMGPTiVJnc4sS0ehGQEhU1mI DAqCQ94Q_c6B.5ap3aEMfgs0J.bWCEEdOcl8FsMr.TRkFrlQfKs5qlkdxj2d73HJq5nZhn5z.GT8 LEB2uklKvTbpjIlaviS_Up0STQYzDI._OYUQTOD3qfZpPXrnhwCwTdrdbpeyfHq8JrKbYdQziYv5 XqvezLfIVtEGmIMcSj.UenBONSd5E0K45wgh9h1CREoQRE_U9nWQrvpe2tUmNnP6okK_daprZDhh JDccCAnYIoFd0qpJ1oMUgmxoSd2nQuQKTRXO47pDWYBe3JQPgWOCMJlbUFRe7djpWsDx2i.ntlHL .CBlgvoUmvuZCFG8ppPyRfzs7Jv41b7tnzG.qewGhClzy0_0XYgzGRxcJWn9lDT_BYA.k9Osgve5 uEVOtBTlEGolpwmOd3EW0f17G9sGg_qWLDGvCRfifPAt8rFbCuU.MY1xtDobMO.bolvEGFHwRWg9 huxeaSwseG.6z_ekwZsFI9E4CN4mfocAkDFNwCPVAO1_5Wz3O8ogVYFJFVj4_6IHrmzWFnsZLxqI Ddi4ImIjZ3Ojt9P6WAHazjc8VboV9iH5zwL9IwpoSedlA5MORMuqs65txxjjI57p1reVtzr4n Received: from sonic.gate.mail.ne1.yahoo.com by sonic317.consmr.mail.bf2.yahoo.com with HTTP; Fri, 4 Jan 2019 09:17:59 +0000 Received: from c-67-170-167-181.hsd1.or.comcast.net (EHLO [192.168.1.109]) ([67.170.167.181]) by smtp428.mail.bf1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID c4e54658c1a98d8dd65b4cbbaccdfeaa; Fri, 04 Jan 2019 09:17:55 +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) From: Mark Millard In-Reply-To: Date: Fri, 4 Jan 2019 01:17:52 -0800 Cc: Dennis Clarke , freebsd-arm@freebsd.org, FreeBSD Current Content-Transfer-Encoding: 7bit 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: 7E95687DA8 X-Spamd-Bar: ++ X-Spamd-Result: default: False [2.40 / 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]; 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)[]; R_DKIM_ALLOW(-0.20)[yahoo.com:s=s2048]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; NEURAL_SPAM_SHORT(0.94)[0.940,0]; MIME_GOOD(-0.10)[text/plain]; IP_SCORE(1.38)[ip: (4.30), ipnet: 74.6.128.0/21(1.48), asn: 26101(1.18), country: US(-0.08)]; NEURAL_SPAM_MEDIUM(0.37)[0.373,0]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_SPAM_LONG(0.22)[0.221,0]; RCVD_IN_DNSWL_NONE(0.00)[84.129.6.74.list.dnswl.org : 127.0.5.0]; RWL_MAILSPIKE_POSSIBLE(0.00)[84.129.6.74.rep.mailspike.net : 127.0.0.17] X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Jan 2019 09:18:06 -0000 On 2019-Jan-3, at 22:56, Michal Meloun wrote: > On 29.12.2018 18:47, Dennis Clarke wrote: >> On 12/28/18 9:56 PM, Mark Millard via freebsd-arm wrote: >>> >>> On 2018-Dec-28, at 12:12, Mark Millard wrote: >>> >>>> On 2018-Dec-28, at 05:13, Michal Meloun >>>> wrote: >>>> >>>>> 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. >>>>> >> >> Following along here quietly and I had to blink at this a few times. >> Is there a bug report somewhere within the qemu world related to this >> 'broken by design' qemu feature? > > Firstly, I apologize for late answer. Writing a technically accurate but > still comprehensible report is extremely difficult for me. Thanks for doing so. > . . . > Mark, I hope that this is also the answer to your question posted to > hackers@ and also the exploitation why you see hang. Again thanks: it was helpful for my gaining some understanding of the code structure. But it turns out that another of your list of problems is involved in the hang-up: > . . . > - and last major one. At this time, all guest structures are maintained > by hand. Due to huge amount of these structures, this is the extreme > error prone approach. We should convert this to script generated code, > including guest syscalls definition. It turns out that "struct target_cmsghdr" has the wrong overall size, the wrong first field size, and the wrong offsets for later fields for amd64->aarch64 use (or likely any 64-bit->64-bit host-target pair, even amd64->x86_64). In fact the code reports via: gemu_log("Unsupported ancillary data: %d/%d\n", cmsg->cmsg_level, cmsg->cmsg_type); because of msg->cmsg_level and cmsg->cmsg_type ending up with messed up values. It hangs after that message shows up. The more complete code containing that qemu_log call is: if ((cmsg->cmsg_level == TARGET_SOL_SOCKET) && (cmsg->cmsg_type == SCM_RIGHTS)) { int *fd = (int *)data; int *target_fd = (int *)target_data; int i, numfds = len / sizeof(int); for (i = 0; i < numfds; i++) { fd[i] = tswap32(target_fd[i]); } } else if ((cmsg->cmsg_level == TARGET_SOL_SOCKET) && (cmsg->cmsg_type == SCM_TIMESTAMP) && (len == sizeof(struct timeval))) { /* copy struct timeval to host */ struct timeval *tv = (struct timeval *)data; struct target_freebsd_timeval *target_tv = (struct target_freebsd_timeval *)target_data; __get_user(tv->tv_sec, &target_tv->tv_sec); __get_user(tv->tv_usec, &target_tv->tv_usec); } else { gemu_log("Unsupported ancillary data: %d/%d\n", cmsg->cmsg_level, cmsg->cmsg_type); memcpy(data, target_data, len); } Of 3 types of hangups that I've run into recently, one was from a missing statement, one was from struct target_kevent having the wrong overall size and wrong field offsets after the first field (amd64->armv7 was an example), and the one involving struct target_cmsghdr above. (There may be more to the target_cmsghdr one.) > Again, my apology for slightly (or much) chaotic report, but this is the > best what's I capable. Not chaotic in my view. === Mark Millard marklmi at yahoo.com ( dsl-only.net went away in early 2018-Mar)