lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <202001260844.jgEtrb7b%lkp@intel.com>
Date:   Sun, 26 Jan 2020 08:39:46 +0800
From:   kbuild test robot <lkp@...el.com>
To:     linmiaohe <linmiaohe@...wei.com>
Cc:     kbuild-all@...ts.01.org, pbonzini@...hat.com, rkrcmar@...hat.com,
        sean.j.christopherson@...el.com, vkuznets@...hat.com,
        wanpengli@...cent.com, jmattson@...gle.com, joro@...tes.org,
        tglx@...utronix.de, mingo@...hat.com, bp@...en8.de, hpa@...or.com,
        linmiaohe@...wei.com, kvm@...r.kernel.org,
        linux-kernel@...r.kernel.org, x86@...nel.org
Subject: Re: [PATCH] KVM: x86: avoid some unnecessary copy in
 __x86_set_memory_region()

Hi linmiaohe,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on kvm/linux-next]
[also build test WARNING on v5.5-rc7 next-20200124]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/linmiaohe/KVM-x86-avoid-some-unnecessary-copy-in-__x86_set_memory_region/20200125-020112
base:   https://git.kernel.org/pub/scm/virt/kvm/kvm.git linux-next
config: i386-allyesconfig (attached as .config)
compiler: gcc-7 (Debian 7.5.0-3) 7.5.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@...el.com>

Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings

All warnings (new ones prefixed by >>):

   In file included from arch/x86/kvm/x86.c:25:0:
   arch/x86/kvm/x86.h: In function 'kvm_dr7_valid':
   arch/x86/kvm/x86.h:363:16: warning: right shift count >= width of type [-Wshift-count-overflow]
     return !(data >> 32);
                   ^~
   arch/x86/kvm/x86.c: In function '__x86_set_memory_region':
>> arch/x86/kvm/x86.c:9730:27: warning: 'npages' may be used uninitialized in this function [-Wmaybe-uninitialized]
      vm_munmap(uaddr, npages * PAGE_SIZE);
>> arch/x86/kvm/x86.c:9730:3: warning: 'uaddr' may be used uninitialized in this function [-Wmaybe-uninitialized]
      vm_munmap(uaddr, npages * PAGE_SIZE);
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vim +/npages +9730 arch/x86/kvm/x86.c

  9682	
  9683	int __x86_set_memory_region(struct kvm *kvm, int id, gpa_t gpa, u32 size)
  9684	{
  9685		int i, r;
  9686		unsigned long hva, uaddr, npages;
  9687		struct kvm_memslots *slots = kvm_memslots(kvm);
  9688		struct kvm_memory_slot *slot;
  9689	
  9690		/* Called with kvm->slots_lock held.  */
  9691		if (WARN_ON(id >= KVM_MEM_SLOTS_NUM))
  9692			return -EINVAL;
  9693	
  9694		slot = id_to_memslot(slots, id);
  9695		if (size) {
  9696			if (slot->npages)
  9697				return -EEXIST;
  9698	
  9699			/*
  9700			 * MAP_SHARED to prevent internal slot pages from being moved
  9701			 * by fork()/COW.
  9702			 */
  9703			hva = vm_mmap(NULL, 0, size, PROT_READ | PROT_WRITE,
  9704				      MAP_SHARED | MAP_ANONYMOUS, 0);
  9705			if (IS_ERR((void *)hva))
  9706				return PTR_ERR((void *)hva);
  9707		} else {
  9708			if (!slot->npages)
  9709				return 0;
  9710	
  9711			hva = 0;
  9712			uaddr = slot->userspace_addr;
  9713			npages = slot->npages;
  9714		}
  9715	
  9716		for (i = 0; i < KVM_ADDRESS_SPACE_NUM; i++) {
  9717			struct kvm_userspace_memory_region m;
  9718	
  9719			m.slot = id | (i << 16);
  9720			m.flags = 0;
  9721			m.guest_phys_addr = gpa;
  9722			m.userspace_addr = hva;
  9723			m.memory_size = size;
  9724			r = __kvm_set_memory_region(kvm, &m);
  9725			if (r < 0)
  9726				return r;
  9727		}
  9728	
  9729		if (!size)
> 9730			vm_munmap(uaddr, npages * PAGE_SIZE);
  9731	
  9732		return 0;
  9733	}
  9734	EXPORT_SYMBOL_GPL(__x86_set_memory_region);
  9735	

---
0-DAY kernel test infrastructure                 Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Intel Corporation

Download attachment ".config.gz" of type "application/gzip" (70348 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ