From owner-freebsd-wireless@FreeBSD.ORG Tue Jul 30 02:25:06 2013 Return-Path: Delivered-To: freebsd-wireless@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 618EC74C; Tue, 30 Jul 2013 02:25:06 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mho-01-ewr.mailhop.org (mho-03-ewr.mailhop.org [204.13.248.66]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 24A8D2D3A; Tue, 30 Jul 2013 02:25:05 +0000 (UTC) Received: from c-24-8-230-52.hsd1.co.comcast.net ([24.8.230.52] helo=damnhippie.dyndns.org) by mho-01-ewr.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1V3zcQ-0003qn-LO; Tue, 30 Jul 2013 02:24:58 +0000 Received: from [172.22.42.240] (revolution.hippie.lan [172.22.42.240]) by damnhippie.dyndns.org (8.14.3/8.14.3) with ESMTP id r6U2Otlr017693; Mon, 29 Jul 2013 20:24:55 -0600 (MDT) (envelope-from ian@FreeBSD.org) X-Mail-Handler: Dyn Standard SMTP by Dyn X-Originating-IP: 24.8.230.52 X-Report-Abuse-To: abuse@dyndns.com (see http://www.dyndns.com/services/sendlabs/outbound_abuse.html for abuse reporting information) X-MHO-User: U2FsdGVkX1+E1uPtrsStc5/oJSWS8JDY Subject: Re: My WLI-UC-GNM up crash From: Ian Lepore To: John-Mark Gurney In-Reply-To: <20130729211540.GZ26412@funkthat.com> References: <20130729211540.GZ26412@funkthat.com> Content-Type: text/plain; charset="us-ascii" Date: Mon, 29 Jul 2013 20:24:55 -0600 Message-ID: <1375151095.45247.54.camel@revolution.hippie.lan> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit Cc: freebsd-arm , "freebsd-wireless@freebsd.org" , Hans Petter Selasky X-BeenThere: freebsd-wireless@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Discussions of 802.11 stack, tools device driver development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Jul 2013 02:25:06 -0000 On Mon, 2013-07-29 at 14:15 -0700, John-Mark Gurney wrote: > Hans Petter Selasky wrote this message on Mon, Jul 29, 2013 at 19:58 +0200: > > The aligned will make sure that the structure gets padded properly to the size specified. Only on ARM/MIPS etc, structures get automatically aligned according to the element in the structure requiring the greatest alignment. I've test-compiled the USB WLAN drivers, and the aligned makes a difference. The problem is that the radiotap header skews some following elements, so that they are no longer aligned. The radiotap header itself is packed, and this is not a problem. > > Ouch, has anyone looked at the code that caused this? > > in ieee80211_radiotap.c, it looks like the original fault was in either > set_channel, or set_xchannel, and both do (the equivalent of): > struct { > uint16_t freq; > uint16_t flags; > } *rc = p; > > rc->freq = htole16(c->ic_freq); > rc->flags = htole16(c->ic_flags); > If there's any chance the pointer isn't aligned in code like this, then htole16() is the wrong function, it should be using le16enc() such as le16enc(&rc->freq, c->ic_freq); le16enc(&rc->flags, c->ic_flags); With any luck, an x86 compiler can optimize the inline code for the endian enc/dec functions to take advantage of the platform's ability to do unaligned accesses. But that's a side issue to code correctness -- portable code has to get these things right even when it's inefficient. -- Ian > And then there is complicated code that calculates offsets, etc, in > radiotap_offset.. What we probably really need is to mark the above > as __packed or equiv so that we don't assume that the passed in pointer > is aligned... > > The whole management of this radiochan and radiotap_offset is pretty > nasty... If marking the structures __packed works, it's probably > because two bugs are offsetting, and magicly making things align > again... > > > -----Original message----- > > > From:Warner Losh > > > > Sent: Monday 29th July 2013 17:04 > > > To: Adrian Chadd > > > > Cc: Hans Petter Selasky >; freebsd-arm >; freebsd-wireless@freebsd.org > > > Subject: Re: My WLI-UC-GNM up crash > > > > > > Aren't structures already aligned to 4 bytes when placed inside other structures (unless marked __packed)? > > > > > > Warner > > > > > > On Jul 28, 2013, at 11:50 AM, Adrian Chadd wrote: > > > > > > > As long as that results in the radiotap structures being 4 or 8 byte > > > > padded when it's embedded in the softc - then yes, indeed. > > > > > > > > Xiao, can you try? > > > > > > > > > > > > -adrian > > > > > > > > On 28 July 2013 03:35, Hans Petter Selasky > wrote: > > > >> Hi, > > > >> > > > >> Can you try the attached patch? > > > >> > > > >> --HPS > > > > _______________________________________________ > > > > freebsd-arm@freebsd.org mailing list > > > > http://lists.freebsd.org/mailman/listinfo/freebsd-arm > > > > To unsubscribe, send any mail to "freebsd-arm-unsubscribe@freebsd.org " > > > > > > > > > > _______________________________________________ > > freebsd-arm@freebsd.org mailing list > > http://lists.freebsd.org/mailman/listinfo/freebsd-arm > > To unsubscribe, send any mail to "freebsd-arm-unsubscribe@freebsd.org" >