Re: [kvm:queue 305/328] arch/x86/kvm/x86.c:4345:32: warning: cast to pointer from integer of different size

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx/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@xxxxxxxxx>

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@xxxxxxxxxxxx




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux