* [kvm:queue 305/328] arch/x86/kvm/x86.c:4345:32: warning: cast to pointer from integer of different size
@ 2022-01-27 1:52 kernel test robot
2022-01-27 8:08 ` Like Xu
0 siblings, 1 reply; 4+ messages in thread
From: kernel test robot @ 2022-01-27 1:52 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: kbuild-all, kvm, Robert Hu, Farrah Chen, Danmei Wei
tree: https://git.kernel.org/pub/scm/virt/kvm/kvm.git queue
head: b029c138e8f090f5cb9ba77ef20509f903ef0004
commit: db9556a4eb6b43313cee57abcbbbad01f2708baa [305/328] KVM: x86: add system attribute to retrieve full set of supported xsave states
config: i386-randconfig-a003 (https://download.01.org/0day-ci/archive/20220127/202201270930.LTyNaecg-lkp@intel.com/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
# https://git.kernel.org/pub/scm/virt/kvm/kvm.git/commit/?id=db9556a4eb6b43313cee57abcbbbad01f2708baa
git remote add kvm https://git.kernel.org/pub/scm/virt/kvm/kvm.git
git fetch --no-tags kvm queue
git checkout db9556a4eb6b43313cee57abcbbbad01f2708baa
# save the config file to linux build tree
mkdir build_dir
make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash arch/x86/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
In file included from include/linux/uaccess.h:11,
from include/linux/sched/task.h:11,
from include/linux/sched/signal.h:9,
from include/linux/rcuwait.h:6,
from include/linux/percpu-rwsem.h:7,
from include/linux/fs.h:33,
from include/linux/huge_mm.h:8,
from include/linux/mm.h:717,
from include/linux/kvm_host.h:16,
from arch/x86/kvm/x86.c:19:
arch/x86/kvm/x86.c: In function 'kvm_x86_dev_get_attr':
>> arch/x86/kvm/x86.c:4345:32: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
4345 | if (put_user(supported_xcr0, (u64 __user *)attr->addr))
| ^
arch/x86/include/asm/uaccess.h:221:24: note: in definition of macro 'do_put_user_call'
221 | register __typeof__(*(ptr)) __val_pu asm("%"_ASM_AX); \
| ^~~
arch/x86/kvm/x86.c:4345:7: note: in expansion of macro 'put_user'
4345 | if (put_user(supported_xcr0, (u64 __user *)attr->addr))
| ^~~~~~~~
>> arch/x86/kvm/x86.c:4345:32: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
4345 | if (put_user(supported_xcr0, (u64 __user *)attr->addr))
| ^
arch/x86/include/asm/uaccess.h:223:14: note: in definition of macro 'do_put_user_call'
223 | __ptr_pu = (ptr); \
| ^~~
arch/x86/kvm/x86.c:4345:7: note: in expansion of macro 'put_user'
4345 | if (put_user(supported_xcr0, (u64 __user *)attr->addr))
| ^~~~~~~~
>> arch/x86/kvm/x86.c:4345:32: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
4345 | if (put_user(supported_xcr0, (u64 __user *)attr->addr))
| ^
arch/x86/include/asm/uaccess.h:230:31: note: in definition of macro 'do_put_user_call'
230 | [size] "i" (sizeof(*(ptr))) \
| ^~~
arch/x86/kvm/x86.c:4345:7: note: in expansion of macro 'put_user'
4345 | if (put_user(supported_xcr0, (u64 __user *)attr->addr))
| ^~~~~~~~
vim +4345 arch/x86/kvm/x86.c
4337
4338 static int kvm_x86_dev_get_attr(struct kvm_device_attr *attr)
4339 {
4340 if (attr->group)
4341 return -ENXIO;
4342
4343 switch (attr->attr) {
4344 case KVM_X86_XCOMP_GUEST_SUPP:
> 4345 if (put_user(supported_xcr0, (u64 __user *)attr->addr))
4346 return -EFAULT;
4347 return 0;
4348 default:
4349 return -ENXIO;
4350 break;
4351 }
4352 }
4353
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [kvm:queue 305/328] arch/x86/kvm/x86.c:4345:32: warning: cast to pointer from integer of different size
2022-01-27 1:52 [kvm:queue 305/328] arch/x86/kvm/x86.c:4345:32: warning: cast to pointer from integer of different size kernel test robot
@ 2022-01-27 8:08 ` Like Xu
2022-01-27 8:09 ` Paolo Bonzini
0 siblings, 1 reply; 4+ messages in thread
From: Like Xu @ 2022-01-27 8:08 UTC (permalink / raw)
To: Paolo Bonzini
Cc: kbuild-all, kvm, Robert Hu, Farrah Chen, Danmei Wei, kernel test robot
On 27/1/2022 9:52 am, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/virt/kvm/kvm.git queue
> head: b029c138e8f090f5cb9ba77ef20509f903ef0004
> commit: db9556a4eb6b43313cee57abcbbbad01f2708baa [305/328] KVM: x86: add system attribute to retrieve full set of supported xsave states
> config: i386-randconfig-a003 (https://download.01.org/0day-ci/archive/20220127/202201270930.LTyNaecg-lkp@intel.com/config)
> compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
> reproduce (this is a W=1 build):
> # https://git.kernel.org/pub/scm/virt/kvm/kvm.git/commit/?id=db9556a4eb6b43313cee57abcbbbad01f2708baa
> git remote add kvm https://git.kernel.org/pub/scm/virt/kvm/kvm.git
> git fetch --no-tags kvm queue
> git checkout db9556a4eb6b43313cee57abcbbbad01f2708baa
> # save the config file to linux build tree
> mkdir build_dir
> make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash arch/x86/
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
> All warnings (new ones prefixed by >>):
>
> In file included from include/linux/uaccess.h:11,
> from include/linux/sched/task.h:11,
> from include/linux/sched/signal.h:9,
> from include/linux/rcuwait.h:6,
> from include/linux/percpu-rwsem.h:7,
> from include/linux/fs.h:33,
> from include/linux/huge_mm.h:8,
> from include/linux/mm.h:717,
> from include/linux/kvm_host.h:16,
> from arch/x86/kvm/x86.c:19:
> arch/x86/kvm/x86.c: In function 'kvm_x86_dev_get_attr':
>>> arch/x86/kvm/x86.c:4345:32: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
> 4345 | if (put_user(supported_xcr0, (u64 __user *)attr->addr))
> | ^
Similar to kvm_arch_tsc_{s,g}et_attr(), how about this fix:
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 8033eca6f..6d4e961d0 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4342,7 +4342,7 @@ static int kvm_x86_dev_get_attr(struct kvm_device_attr *attr)
switch (attr->attr) {
case KVM_X86_XCOMP_GUEST_SUPP:
- if (put_user(supported_xcr0, (u64 __user *)attr->addr))
+ if (put_user(supported_xcr0, (u64 __user *)(unsigned
long)attr->addr))
return -EFAULT;
return 0;
default:
> arch/x86/include/asm/uaccess.h:221:24: note: in definition of macro 'do_put_user_call'
> 221 | register __typeof__(*(ptr)) __val_pu asm("%"_ASM_AX); \
> | ^~~
> arch/x86/kvm/x86.c:4345:7: note: in expansion of macro 'put_user'
> 4345 | if (put_user(supported_xcr0, (u64 __user *)attr->addr))
> | ^~~~~~~~
>>> arch/x86/kvm/x86.c:4345:32: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
> 4345 | if (put_user(supported_xcr0, (u64 __user *)attr->addr))
> | ^
> arch/x86/include/asm/uaccess.h:223:14: note: in definition of macro 'do_put_user_call'
> 223 | __ptr_pu = (ptr); \
> | ^~~
> arch/x86/kvm/x86.c:4345:7: note: in expansion of macro 'put_user'
> 4345 | if (put_user(supported_xcr0, (u64 __user *)attr->addr))
> | ^~~~~~~~
>>> arch/x86/kvm/x86.c:4345:32: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
> 4345 | if (put_user(supported_xcr0, (u64 __user *)attr->addr))
> | ^
> arch/x86/include/asm/uaccess.h:230:31: note: in definition of macro 'do_put_user_call'
> 230 | [size] "i" (sizeof(*(ptr))) \
> | ^~~
> arch/x86/kvm/x86.c:4345:7: note: in expansion of macro 'put_user'
> 4345 | if (put_user(supported_xcr0, (u64 __user *)attr->addr))
> | ^~~~~~~~
>
>
> vim +4345 arch/x86/kvm/x86.c
>
> 4337
> 4338 static int kvm_x86_dev_get_attr(struct kvm_device_attr *attr)
> 4339 {
> 4340 if (attr->group)
> 4341 return -ENXIO;
> 4342
> 4343 switch (attr->attr) {
> 4344 case KVM_X86_XCOMP_GUEST_SUPP:
>> 4345 if (put_user(supported_xcr0, (u64 __user *)attr->addr))
> 4346 return -EFAULT;
> 4347 return 0;
> 4348 default:
> 4349 return -ENXIO;
> 4350 break;
> 4351 }
> 4352 }
> 4353
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
>
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [kvm:queue 305/328] arch/x86/kvm/x86.c:4345:32: warning: cast to pointer from integer of different size
2022-01-27 8:08 ` Like Xu
@ 2022-01-27 8:09 ` Paolo Bonzini
2022-01-27 11:39 ` Paolo Bonzini
0 siblings, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2022-01-27 8:09 UTC (permalink / raw)
To: Like Xu
Cc: kbuild-all, kvm, Robert Hu, Farrah Chen, Danmei Wei, kernel test robot
On 1/27/22 09:08, Like Xu wrote:
>>
>
> Similar to kvm_arch_tsc_{s,g}et_attr(), how about this fix:
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 8033eca6f..6d4e961d0 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -4342,7 +4342,7 @@ static int kvm_x86_dev_get_attr(struct
> kvm_device_attr *attr)
>
> switch (attr->attr) {
> case KVM_X86_XCOMP_GUEST_SUPP:
> - if (put_user(supported_xcr0, (u64 __user *)attr->addr))
> + if (put_user(supported_xcr0, (u64 __user *)(unsigned
> long)attr->addr))
> return -EFAULT;
> return 0;
> default:
This has to be (at least in the future) 64 bits, so it has to use
copy_to_user.
I'll send a v2 of the patches today.
Paolo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [kvm:queue 305/328] arch/x86/kvm/x86.c:4345:32: warning: cast to pointer from integer of different size
2022-01-27 8:09 ` Paolo Bonzini
@ 2022-01-27 11:39 ` Paolo Bonzini
0 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2022-01-27 11:39 UTC (permalink / raw)
To: Like Xu
Cc: kbuild-all, kvm, Robert Hu, Farrah Chen, Danmei Wei, kernel test robot
On 1/27/22 09:09, Paolo Bonzini wrote:
> On 1/27/22 09:08, Like Xu wrote:
>>>
>>
>> Similar to kvm_arch_tsc_{s,g}et_attr(), how about this fix:
>>
>> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
>> index 8033eca6f..6d4e961d0 100644
>> --- a/arch/x86/kvm/x86.c
>> +++ b/arch/x86/kvm/x86.c
>> @@ -4342,7 +4342,7 @@ static int kvm_x86_dev_get_attr(struct
>> kvm_device_attr *attr)
>>
>> switch (attr->attr) {
>> case KVM_X86_XCOMP_GUEST_SUPP:
>> - if (put_user(supported_xcr0, (u64 __user *)attr->addr))
>> + if (put_user(supported_xcr0, (u64 __user *)(unsigned
>> long)attr->addr))
>> return -EFAULT;
>> return 0;
>> default:
>
> This has to be (at least in the future) 64 bits, so it has to use
> copy_to_user.
Nevermind, I was still asleep. Of course you're right.
Paolo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-01-27 11:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-27 1:52 [kvm:queue 305/328] arch/x86/kvm/x86.c:4345:32: warning: cast to pointer from integer of different size kernel test robot
2022-01-27 8:08 ` Like Xu
2022-01-27 8:09 ` Paolo Bonzini
2022-01-27 11:39 ` Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).