From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34933) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UiKcI-0001am-B9 for qemu-devel@nongnu.org; Fri, 31 May 2013 04:23:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UiKcH-0005oW-3Y for qemu-devel@nongnu.org; Fri, 31 May 2013 04:23:18 -0400 Received: from mail-ea0-x22d.google.com ([2a00:1450:4013:c01::22d]:59538) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UiKcG-0005oK-Ty for qemu-devel@nongnu.org; Fri, 31 May 2013 04:23:17 -0400 Received: by mail-ea0-f173.google.com with SMTP id n15so1274398ead.32 for ; Fri, 31 May 2013 01:23:16 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <51A85DE8.2090600@redhat.com> Date: Fri, 31 May 2013 10:23:04 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <20130530114604.4b12cb22@redhat.com> <51A77838.4060707@redhat.com> <20130530120832.5abe1c65@redhat.com> <51A8485A.4000605@linux.vnet.ibm.com> In-Reply-To: <51A8485A.4000605@linux.vnet.ibm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [BUG]: kvm_set_phys_mem: error unregistering overlapping slot: Invalid argument List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Xiao Guangrong Cc: "Justen, Jordan L" , Jordan Justen , qemu-devel , Luiz Capitulino Il 31/05/2013 08:51, Xiao Guangrong ha scritto: > On 05/31/2013 12:50 AM, Jordan Justen wrote: >> On Thu, May 30, 2013 at 9:08 AM, Luiz Capitulino wrote: >>> On Thu, 30 May 2013 18:03:04 +0200 >>> Paolo Bonzini wrote: >>> >>>> Il 30/05/2013 17:46, Luiz Capitulino ha scritto: >>>>> The culprit is commit: >>>>> >>>>> commit 235e8982ad393e5611cb892df54881c872eea9e1 >>>>> Author: Jordan Justen >>>>> Date: Wed May 29 01:27:26 2013 -0700 >>>>> >>>>> kvm: support using KVM_MEM_READONLY flag for regions >>>>> >>>>> I'm running 3.9.2-200.fc18, btw. And, error checking is missing on the >>>>> first call to kvm_vm_ioctl(). >> >> As noted in the code, the first call is for KVM commit 75d61fbc. >> >> I'm not sure we want to fail if an error occurs when making that call. >> (I'm pretty sure we don't want to in fact.) >> >> Xiao, any thoughts? > > I have reproduced this bug, it seems that the bug is caused by double free > the memslot. After these change, it can boot the guest now. > > diff --git a/kvm-all.c b/kvm-all.c > index 8e7bbf8..405480e 100644 > --- a/kvm-all.c > +++ b/kvm-all.c > @@ -206,7 +206,8 @@ static int kvm_set_user_memory_region(KVMState *s, KVMSlot *slot) > if (s->migration_log) { > mem.flags |= KVM_MEM_LOG_DIRTY_PAGES; > } > - if (mem.flags & KVM_MEM_READONLY) { > + > + if (slot->memory_size && mem.flags & KVM_MEM_READONLY) { > /* Set the slot size to 0 before setting the slot to the desired > * value. This is needed based on KVM commit 75d61fbc. */ > mem.memory_size = 0; > > > > Thanks, can you submit it for uq/master? Please Cc kvm@vger.kernel.org too, and use [PATCH uq/master] as the prefix. Paolo