Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754686Ab1BBRKY (ORCPT ); Wed, 2 Feb 2011 12:10:24 -0500 Received: from caramon.arm.linux.org.uk ([78.32.30.218]:58209 "EHLO caramon.arm.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754503Ab1BBRKW (ORCPT ); Wed, 2 Feb 2011 12:10:22 -0500 Date: Wed, 2 Feb 2011 17:09:59 +0000 From: Russell King - ARM Linux To: Richard Guenther Cc: Arnd Bergmann , Peter Maydell , gcc@gcc.gnu.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Ulrich Weigand , linux-arm-kernel@lists.infradead.org Subject: Re: ARM unaligned MMIO access with attribute((packed)) Message-ID: <20110202170959.GA31043@n2100.arm.linux.org.uk> References: <201102021700.20683.arnd@arndb.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.19 (2009-01-05) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1310 Lines: 44 On Wed, Feb 02, 2011 at 05:51:27PM +0100, Richard Guenther wrote: > > I would suggest fixing this by: > > > > 1. auditing all uses of __attribute__((packed)) in the Linux USB code > > and other drivers, removing the ones that are potentially harmful. > > > > 2. Changing the ARM MMIO functions to use inline assembly instead of > > direct pointer dereference. > > > > 3. Documenting the gcc behavior as undefined. > > The pointer conversions already invoke undefined behavior as specified by the > C standard (6.3.2.3/7). Just to be clear: you are not saying that the ARM implementation is undefined. What you're saying is that converting from a pointer with less strict alignment requirements to a pointer with more strict alignment requirements is undefined. IOW: unsigned long *blah(unsigned char *c) { return (unsigned long *)c; } would be undefined, but: unsigned char *blah(unsigned long *c) { return (unsigned char *)c; } would not be. If you're saying something else, please explain with reference to the point in the C standard you quote above. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/