mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: kbuild test robot <lkp@intel.com>
To: linmiaohe <linmiaohe@huawei.com>
Cc: kbuild-all@lists.01.org, pbonzini@redhat.com, rkrcmar@redhat.com,
	sean.j.christopherson@intel.com, vkuznets@redhat.com,
	wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org,
	tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
	hpa@zytor.com, linmiaohe@huawei.com, kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org, x86@kernel.org
Subject: Re: [PATCH] KVM: x86: avoid some unnecessary copy in __x86_set_memory_region()
Date: Sun, 26 Jan 2020 08:39:46 +0800	[thread overview]
Message-ID: <202001260844.jgEtrb7b%lkp@intel.com> (raw)
In-Reply-To: <1579748413-432-1-git-send-email-linmiaohe@huawei.com>

[-- Attachment #1: Type: text/plain, Size: 3458 bytes --]

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@intel.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

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 70348 bytes --]

      parent reply	other threads:[~2020-01-26  0:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-23  3:00 linmiaohe
2020-01-23 12:15 ` Paolo Bonzini
2020-01-26  0:39 ` kbuild test robot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202001260844.jgEtrb7b%lkp@intel.com \
    --to=lkp@intel.com \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kbuild-all@lists.01.org \
    --cc=kvm@vger.kernel.org \
    --cc=linmiaohe@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=sean.j.christopherson@intel.com \
    --cc=tglx@linutronix.de \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®