lkml.org 
[lkml]   [2012]   [Feb]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH] x86, efi: Fix unaligned access and endian issues
    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/)



    \
     
     \ /
      Last update: 2012-02-22 17:47    [W:0.024 / U:63.764 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site