Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754029Ab2BVQoO (ORCPT ); Wed, 22 Feb 2012 11:44:14 -0500 Received: from mx.scalarmail.ca ([98.158.95.75]:53621 "EHLO ironport-01.sms.scalar.ca" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752639Ab2BVQoM (ORCPT ); Wed, 22 Feb 2012 11:44:12 -0500 Date: Wed, 22 Feb 2012 11:44:02 -0500 From: Nick Bowler To: Matt Fleming Cc: Stephen Rothwell , x86@kernel.org, linux-kernel@vger.kernel.org, Matt Fleming , "H. Peter Anvin" Subject: Re: [PATCH] x86, efi: Fix unaligned access and endian issues Message-ID: <20120222164402.GA13354@elliptictech.com> References: <1329919208-8700-1-git-send-email-matt@console-pimps.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1329919208-8700-1-git-send-email-matt@console-pimps.org> Organization: Elliptic Technologies Inc. User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1216 Lines: 44 On 2012-02-22 14:00 +0000, Matt Fleming wrote: > From: Matt Fleming > > We need to read from and write to 'buf' a byte at a time otherwise > it's possible we'll perform an unaligned access, which can lead to a > segfault when cross-building an x86 kernel on risc architectures. > > Also, we may need to convert the endianness of the data we read > from/write to buf, so let's add some helper functions to do that. [...] > +static inline u32 read32_le(u8 *src) > +{ > + u32 data; > + > + data = *src++; > + data |= *src++ << 8; > + data |= *src++ << 16; > + data |= *src++ << 24; > + > + return data; > +} We already have get_unaligned_le32 in for this. > + > +static inline void write32_le(u8 *dst, u32 data) > +{ > + *dst++ = data; > + *dst++ = data >> 8; > + *dst++ = data >> 16; > + *dst++ = data >> 24; > +} Similarly, put_unaligned_le32. Cheers, -- Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/) -- 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/