From: Nick Bowler <nbowler@elliptictech.com>
To: Matt Fleming <matt@console-pimps.org>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>,
x86@kernel.org, linux-kernel@vger.kernel.org,
Matt Fleming <matt.fleming@intel.com>,
"H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH] x86, efi: Fix unaligned access and endian issues
Date: Wed, 22 Feb 2012 11:44:02 -0500 [thread overview]
Message-ID: <20120222164402.GA13354@elliptictech.com> (raw)
In-Reply-To: <1329919208-8700-1-git-send-email-matt@console-pimps.org>
On 2012-02-22 14:00 +0000, Matt Fleming wrote:
> From: Matt Fleming <matt.fleming@intel.com>
>
> 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 <asm/unaligned.h> 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/)
next prev parent reply other threads:[~2012-02-22 16:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-22 14:00 [PATCH] x86, efi: Fix unaligned access and endian issues Matt Fleming
2012-02-22 16:44 ` Nick Bowler [this message]
2012-02-22 17:37 ` H. Peter Anvin
2012-02-22 22:31 ` Stephen Rothwell
2012-02-22 22:58 ` Matt Fleming
2012-02-22 23:54 ` Stephen Rothwell
2012-02-23 9:09 ` Matt Fleming
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120222164402.GA13354@elliptictech.com \
--to=nbowler@elliptictech.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matt.fleming@intel.com \
--cc=matt@console-pimps.org \
--cc=sfr@canb.auug.org.au \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.