Bug 5138

Summary: 64bit put_unaligned/get_unaligned does not work on 32bit kernel
Product: Other Reporter: Atsushi Nemoto (anemo)
Component: OtherAssignee: other_other
Status: RESOLVED CODE_FIX    
Severity: normal CC: akpm
Priority: P2    
Hardware: i386   
OS: Linux   
Kernel Version: 2.6.12 Subsystem:
Regression: --- Bisected commit-id:

Description Atsushi Nemoto 2005-08-27 07:46:52 UTC
Most recent kernel where this bug did not occur:2.6.11
Distribution:any
Hardware Environment:mips, possibly parisc, sh, sparc
Software Environment:32bit kernel
Problem Description:
put_unaligned/get_unaligned in include/asm-generic/unaligned.h use 'unsigned
long' to hold 64bit value.
So if sizeof(long) was smaller than 8, higher 32bit will be lost. 
Steps to reproduce:
Comment 1 Andrew Morton 2005-08-27 10:20:31 UTC
bugme-daemon@kernel-bugs.osdl.org wrote:
>
> http://bugzilla.kernel.org/show_bug.cgi?id=5138
> 
>            Summary: 64bit put_unaligned/get_unaligned does not work on 32bit
>                     kernel
>     Kernel Version: 2.6.12
>             Status: NEW
>           Severity: normal
>              Owner: other_other@kernel-bugs.osdl.org
>          Submitter: anemo@mba.ocn.ne.jp
> 
> 
> Most recent kernel where this bug did not occur:2.6.11
> Distribution:any
> Hardware Environment:mips, possibly parisc, sh, sparc
> Software Environment:32bit kernel
> Problem Description:
> put_unaligned/get_unaligned in include/asm-generic/unaligned.h use 'unsigned
> long' to hold 64bit value.
> So if sizeof(long) was smaller than 8, higher 32bit will be lost. 

get_unaligned() looks OK to me.

But yes, there is a seemingly-unneeded typecast in put_unaligned() which
I think will indeed truncate 64-bit values.

Comment 2 Atsushi Nemoto 2005-08-28 06:23:43 UTC
> get_unaligned() looks OK to me.

No, __get_unaligned() uses 'unsigned long val' to hold a 64bit value.
Also __uldp() loads a __u64 value but returns a 'unsigned long' value.
Comment 3 Atsushi Nemoto 2005-08-28 06:28:45 UTC
> Also __uldp() loads a __u64 value but returns a 'unsigned long' value.

Sorry, I mean __uldq().
Comment 4 Andrew Morton 2007-01-31 00:57:18 UTC
Closing this - we seem to have fixed __get_unaligned()