From owner-svn-src-all@freebsd.org Sun Aug 21 13:39:22 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 B7FFBBC111C; Sun, 21 Aug 2016 13:39:22 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail107.syd.optusnet.com.au (mail107.syd.optusnet.com.au [211.29.132.53]) by mx1.freebsd.org (Postfix) with ESMTP id 805C5131E; Sun, 21 Aug 2016 13:39:21 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from c122-106-149-109.carlnfd1.nsw.optusnet.com.au (c122-106-149-109.carlnfd1.nsw.optusnet.com.au [122.106.149.109]) by mail107.syd.optusnet.com.au (Postfix) with ESMTPS id BEB1BD43989; Sun, 21 Aug 2016 23:39:13 +1000 (AEST) Date: Sun, 21 Aug 2016 23:39:02 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Slawa Olhovchenkov cc: Bruce Evans , 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 In-Reply-To: <20160821131447.GA8192@zxy.spb.ru> Message-ID: <20160821232721.G2639@besplex.bde.org> References: <201608210741.u7L7fBnN075023@repo.freebsd.org> <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> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=VIkg5I7X c=1 sm=1 tr=0 a=R/f3m204ZbWUO/0rwPSMPw==:117 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=OPlg6owxQ1kcppeeVSEA:9 a=CjuIK1q_8ugA:10 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: Sun, 21 Aug 2016 13:39:22 -0000 On Sun, 21 Aug 2016, Slawa Olhovchenkov wrote: > On Sun, Aug 21, 2016 at 11:00:24PM +1000, Bruce Evans wrote: > >> On Sun, 21 Aug 2016, Slawa Olhovchenkov wrote: >> >>> On Sun, Aug 21, 2016 at 09:32:35PM +1000, Bruce Evans wrote: >>> ... >>>> *(foo_t *)asks for alignment bugs. We have already fixed lots of these >>>> bugs for copying struct timevals in places like ping.c. Compilers warn >>>> about misalignment when certain warnings are enabled, but only on arches >>>> where misalignment is more than a pessimization. There is no reason why >>>> td_retval would be always aligned on these arches. Alignment of 64-bit >>>> types on 32-bit arches is usually so unimportant that even int32_t is >>>> not required to be aligned by the ABI, and there is no point in >>>> aligning td_retval specially unless you also do it for a large fraction >>>> of 64-bit integers in the kernel, and there are negative points for >>>> doing that. >>> >>> For eliminate aligment bugs need to replace all assigment more then 1 >>> bytes to *td_retval by memcpy? >> >> The copying must be of size 1 or 2 ints unless you are making even larger >> type puns than now. 1 int is obviously safe to just assign, and 2 ints >> should use memcpy(). > > Why? If it has size not 1 * sizeof(int) or 2 * sizeof(int) or is not an integer, than it is had to assign to a 2-byte array and might need more careful packing just to memcpy() it. > 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. >> 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. Bruce