From owner-svn-src-all@freebsd.org Mon Aug 22 09:21:58 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DD4B0BC0C32; Mon, 22 Aug 2016 09:21:58 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from zxy.spb.ru (zxy.spb.ru [195.70.199.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A0B131DB0; Mon, 22 Aug 2016 09:21:58 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from slw by zxy.spb.ru with local (Exim 4.86 (FreeBSD)) (envelope-from ) id 1bblQT-0007TX-99; Mon, 22 Aug 2016 12:21:49 +0300 Date: Mon, 22 Aug 2016 12:21:49 +0300 From: Slawa Olhovchenkov To: Bruce Evans Cc: Ed Schouten , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r304555 - head/sys/compat/cloudabi Message-ID: <20160822092149.GE8192@zxy.spb.ru> References: <20160821105207.GS22212@zxy.spb.ru> <20160821210751.J2219@besplex.bde.org> <20160821120016.GZ8192@zxy.spb.ru> <20160821223255.K2478@besplex.bde.org> <20160821131447.GA8192@zxy.spb.ru> <20160821232721.G2639@besplex.bde.org> <20160821135826.GB8192@zxy.spb.ru> <20160822022832.Q3214@besplex.bde.org> <20160821170611.GC8192@zxy.spb.ru> <20160822184056.M1897@besplex.bde.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160822184056.M1897@besplex.bde.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: slw@zxy.spb.ru X-SA-Exim-Scanned: No (on zxy.spb.ru); SAEximRunCond expanded to false X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Aug 2016 09:21:59 -0000 On Mon, Aug 22, 2016 at 06:55:58PM +1000, Bruce Evans wrote: > On Sun, 21 Aug 2016, Slawa Olhovchenkov wrote: > > > On Mon, Aug 22, 2016 at 02:49:07AM +1000, Bruce Evans wrote: > > > >> On Sun, 21 Aug 2016, Slawa Olhovchenkov wrote: > >> > >>> On Sun, Aug 21, 2016 at 11:39:02PM +1000, Bruce Evans wrote: > >>> > >>>> On Sun, 21 Aug 2016, Slawa Olhovchenkov wrote: > >>>>> I am remeber about platforms with missaligment trap when > >>>>> accessing int16 by odd address. Now platforms like this do not exist > >>>>> anymore? > >>>> > >>>> i386 still exists, and it supports trapping on misalignement for at least > >>>> CPL 3 (not kernel CPL 0). IIRC, amd64 drops support for this. > >>> > >>> Someone enable and support this? I am don't see. > >>> May be PPC trap on this? > >>> Alpha trap on this, but support of Alpha is droped. > >> > >> It is a 1-line change in asm (or a little more in C with #includes) to > >> enable the trap: > > > > OK, we can turn amd64 in this mode. > > And cat do request to kernel with unalligned access, this cause trap > > and panic, yes? > > No. PSL_AC is ignored in kernel mode. OK. I.e. i386 and amd64 is not target. cloudabi work in kernel mode, yes? > >> It is a trillion-line change to fix the compilers and applications to not > >> do misaligned accesses :-). I only tried to use this ~25 years ago. Then > >> the most obvious compiler bug was generating 32-bit acccesses to assign > >> large but misaligned structs. If the compiler just generated calls to > >> memcpy(), that might work, but in practice libraries also assume alignment. > > > > This issuse can be trigerred and by two-bytes assigmen, yes? > > Not quite that short. i386 has the 1-byte cli instruction for conveniently > setting the interrupt enable flag, but setting PSL_AC seems to take at > least 3 instructions and 6-7 bytes (pushf; orb $N,$M(%[re][bs]p); popf). I am miss something. Why you talk about bytes per instruction? I think this is about returning value to applications unaligning buffer? 8 bytes in this commit or 2 bytes in my example. (for this commit, as I see, td_retval always aligned) > >>>>>> There are also endianness problems. The old version was even more broken > >>>>>> on big endian systems. The current version needs some magic to reverse > >>>>>> the memcpy() of the bits. We already depend on this for some 64-bit > >>>>>> syscalls like lseek(). > >>>>> > >>>>> Can you explain some more? > >>>>> This is not transfer over network and don't read from external media. > >>>>> Where is problem? > >>>> > >>>> It is similar to a network transfer. It needs a protocol to pass values > >>>> to applications. Type puns are fragile even within a single compilation > >>>> unit. > >>> > >>> Application ad kernel run with same byte order, not? > >> > >> The application can do anything it wants, but has to translate if it uses > >> the kernel or a library written in another language. > > > > You talk about different byte order in differenr languages? > > Could be, or the same language with a different ABI. ABI enforced by `server`, ex: kernel, or cloudabi in this case. If language need communicate -- language need adopted, not kernel or cloadabi. No simple way from kernel/cloudabi/etc detect caller abi. Or I am missunderstund you.