<html><body>
<p><tt>Roland Dreier <rolandd@cisco.com> wrote on 11/14/2005 07:49:14 AM:<br>
<br>
>     Pradeep> I am seeking suggestions with respect to the<br>
>     Pradeep> 32-bit/64-bit issues. Is the macro<br>
>     Pradeep> test_thread_flag(TIF_32BIT), to ascertain if we are in<br>
>     Pradeep> the kernel in the context of a 32-bit app or not, generic<br>
>     Pradeep> enought that it will work across all the 64-bit platforms<br>
>     Pradeep> of interest. It should work for<br>
>     Pradeep> ppc64/sparc64/x86_64/parisc. Is that good enough?<br>
> <br>
> What are you trying to do?  It would be best to make your ABI the same<br>
> for both 32-bit and 64-bit kernels, so no compatibility code is<br>
> required.  Failing that, just hook into the existing compatibility<br>
> support (ie compat_ioctl and friends).</tt><br>
<br>
<tt>I am trying to use copy_from_user()/copy_to_user of data structures that</tt><br>
<tt>contains pointers.</tt><br>
<br>
<tt>To address the differences in pointer sizes, here are the possible combinations</tt><br>
<tt>that I am trying to address:</tt><br>
<tt>user          kernel</tt><br>
<tt>32             32 -----> this is simple and copy_*_user() works as expected</tt><br>
<tt>64             32 -----> not supported</tt><br>
<tt>32             64 -----> compat_ptr functions provide the necessary support.</tt><br>
<tt>                           This function takes a compat_ptr_t which is a u32 as input</tt><br>
<br>
<tt>64             64 ------> This case still needs to be addressed. One could do</tt><br>
<tt>                              a copy_*_user() without using the compat_ptr() if it is</tt><br>
<tt>                              known that this is a 64-bit app.</tt><br>
<br>
<tt>Unless, there is a guarantee that only 32-bit apps are supported, there is still</tt><br>
<tt>one case that needs to be addressed and that is the last case above. Hence the need</tt><br>
<tt>to ascertain if the invoking app is 32-bit or 64-bit.</tt><br>
<br>
<tt><br>
> <br>
>     Pradeep> Also, do I use __LP64__ to find out if this is a 64-bit<br>
>     Pradeep> kernel? My research has revealed that this macro will<br>
>     Pradeep> work for gcc versions greater than 3.4.  Now, Sles9sp2<br>
>     Pradeep> uses gcc 3.3.3 and so will not work on Sles9sp2. However,<br>
>     Pradeep> RHEL4U2 uses gcc version 3.4.4. So, even though one may<br>
>     Pradeep> be using the same kernel version, it will work on one<br>
>     Pradeep> distro and not the other. How does one address such<br>
>     Pradeep> issues?<br>
> <br>
> BITS_PER_LONG should be sufficient I think.  But again, what are you<br>
> trying to do?  It would be better to write your code so that it<br>
> doesn't matter whether it is being built for a 32-bit kernel or a<br>
> 64-bit kernel.<br>
> </tt><br>
<tt>Ok, this will do nicely. Thanks for pointing it out.</tt><br>
<br>
<tt>Pradeep</tt><br>
<tt>pradeep@us.ibm.com<br>
</tt></body></html>