From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752302AbcIBVyK (ORCPT ); Fri, 2 Sep 2016 17:54:10 -0400 Received: from mail-it0-f51.google.com ([209.85.214.51]:34869 "EHLO mail-it0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751615AbcIBVyJ (ORCPT ); Fri, 2 Sep 2016 17:54:09 -0400 Subject: Re: [Linaro-mm-sig] [PATCHv2 4/4] staging: android: ion: Add ioctl to query available heaps To: Arnd Bergmann , linaro-mm-sig@lists.linaro.org References: <201609020726.BYQpL5LC%fengguang.wu@intel.com> <5771220.ipmQs8UScq@wuerfel> Cc: kbuild test robot , Daniel Vetter , devel@driverdev.osuosl.org, Jon Medhurst , Android Kernel Team , Greg Kroah-Hartman , Jeremy Gebben , Liviu Dudau , =?UTF-8?Q?Arve_Hj=c3=b8nnev=c3=a5g?= , linux-kernel@vger.kernel.org, Riley Andrews , John Stultz , kbuild-all@01.org, Eun Taik Lee , Chen Feng , Brian Starkey From: Laura Abbott Message-ID: <89e914cc-e050-a901-1674-e9efcd53a981@redhat.com> Date: Fri, 2 Sep 2016 14:53:52 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <5771220.ipmQs8UScq@wuerfel> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/02/2016 02:37 PM, Arnd Bergmann wrote: > On Friday, September 2, 2016 2:27:21 PM CEST Laura Abbott wrote: >>> >>> All warnings (new ones prefixed by >>): >>> >>> drivers/staging/android/ion/ion.c: In function 'ion_query_heaps': >>>>> drivers/staging/android/ion/ion.c:1181:3: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] >>> (struct ion_heap_data __user *)query->heaps; >>> ^ >>> >> >> botching-up-ioctls.txt says: >> >> * Pointers are __u64, cast from/to a uintprt_t on the userspace side and >> from/to a void __user * in the kernel. Try really hard not to delay this >> conversion or worse, fiddle the raw __u64 through your code since that >> diminishes the checking tools like sparse can provide. >> >> This doesn't seem like it will work on 32-bit systems since you'll end up >> with the warning above. Is there a better option or did I misunderstand >> how that is supposed to work? >> > > I don't know a better way that two cast, doing > > (struct ion_heap_data __user *)(uintptr_t)query->heaps; > > It may help to put this into an inline function though. > > Arnd > There already is one it turns out in kernel.h: #define u64_to_user_ptr(x) ( \ { \ typecheck(u64, x); \ (void __user *)(uintptr_t)x; \ } \ ) At least this way I don't have to look at the double casts. Thanks, Laura