From: David Ahern <daahern@cisco.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Avi Kivity <avi@redhat.com>,
aliguori@us.ibm.com, qemu-devel <qemu-devel@nongnu.org>,
KVM mailing list <kvm@vger.kernel.org>
Subject: Re: qemu-kvm aborts - vhost_dev_unassign_memory: Assertion `to >= 0' failed.
Date: Wed, 03 Aug 2011 07:55:47 -0600 [thread overview]
Message-ID: <4E395363.5000200@cisco.com> (raw)
In-Reply-To: <20110803122441.GB10538@redhat.com>
On 08/03/2011 06:24 AM, Michael S. Tsirkin wrote:
> On Wed, Aug 03, 2011 at 02:48:05PM +0300, Avi Kivity wrote:
>> On 08/01/2011 08:44 PM, David Ahern wrote:
>>> qemu-kvm.git as of:
>>>
>>> commit dacdc4b10bafbb21120e1c24a9665444768ef999
>>> Merge: 7b69d4f 0af4922
>>> Author: Avi Kivity<avi@redhat.com>
>>> Date: Sun Jul 31 11:42:26 2011 +0300
>>>
>>> Merge branch 'upstream-merge' into next
>>>
>>> is aborting with the error:
>>>
>>> qemu-kvm: qemu-kvm.git/hw/vhost.c:123: vhost_dev_unassign_memory:
>>> Assertion `to>= 0' failed.
>>> Aborted
>>>
>>
>> It's a bug in vhost:
>>
>> /* Assign/unassign. Keep an unsorted array of non-overlapping
>> * memory regions in dev->mem. */
>> static void vhost_dev_unassign_memory(struct vhost_dev *dev,
>> uint64_t start_addr,
>> uint64_t size)
>> {
>> int from, to, n = dev->mem->nregions;
>> /* Track overlapping/split regions for sanity checking. */
>> int overlap_start = 0, overlap_end = 0, overlap_middle = 0, split = 0;
>>
>> for (from = 0, to = 0; from < n; ++from, ++to) {
>> struct vhost_memory_region *reg = dev->mem->regions + to;
>> uint64_t reglast;
>> uint64_t memlast;
>> uint64_t change;
>>
>> /* clone old region */
>> if (to != from) {
>> memcpy(reg, dev->mem->regions + from, sizeof *reg);
>> }
>>
>> /* No overlap is simple */
>> if (!ranges_overlap(reg->guest_phys_addr, reg->memory_size,
>> start_addr, size)) {
>> continue;
>> }
>>
>> /* Split only happens if supplied region
>> * is in the middle of an existing one. Thus it can not
>> * overlap with any other existing region. */
>> assert(!split);
>>
>> reglast = range_get_last(reg->guest_phys_addr, reg->memory_size);
>> memlast = range_get_last(start_addr, size);
>>
>> /* Remove whole region */
>> if (start_addr <= reg->guest_phys_addr && memlast >= reglast) {
>> --dev->mem->nregions;
>> --to;
>> assert(to >= 0);
>> ++overlap_middle;
>> continue;
>> }
>>
>>
>> We're removing the first region, and 'to' goes negative. Michael?
>
> Yes, that assert is wrong.
>
> --->
> Subject: vhost: remove an incorrect assert
>
> The 'to' can go negative when the first region gets removed
> (it gets incremented by to 0 immediately afterward), which
> makes the assertion fail. Nothing breaks if
> to < 0 here so just remove the assert.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>
> ----
>
> diff --git a/hw/vhost.c b/hw/vhost.c
> index c3d8821..19e7255 100644
> --- a/hw/vhost.c
> +++ b/hw/vhost.c
> @@ -120,7 +120,6 @@ static void vhost_dev_unassign_memory(struct vhost_dev *dev,
> if (start_addr <= reg->guest_phys_addr && memlast >= reglast) {
> --dev->mem->nregions;
> --to;
> - assert(to >= 0);
> ++overlap_middle;
> continue;
> }
>
Removing the assert appears to work fine.
Tested-by: David Ahern <daahern@cisco.com>
David
WARNING: multiple messages have this Message-ID (diff)
From: David Ahern <daahern@cisco.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: aliguori@us.ibm.com, Avi Kivity <avi@redhat.com>,
KVM mailing list <kvm@vger.kernel.org>,
qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] qemu-kvm aborts - vhost_dev_unassign_memory: Assertion `to >= 0' failed.
Date: Wed, 03 Aug 2011 07:55:47 -0600 [thread overview]
Message-ID: <4E395363.5000200@cisco.com> (raw)
In-Reply-To: <20110803122441.GB10538@redhat.com>
On 08/03/2011 06:24 AM, Michael S. Tsirkin wrote:
> On Wed, Aug 03, 2011 at 02:48:05PM +0300, Avi Kivity wrote:
>> On 08/01/2011 08:44 PM, David Ahern wrote:
>>> qemu-kvm.git as of:
>>>
>>> commit dacdc4b10bafbb21120e1c24a9665444768ef999
>>> Merge: 7b69d4f 0af4922
>>> Author: Avi Kivity<avi@redhat.com>
>>> Date: Sun Jul 31 11:42:26 2011 +0300
>>>
>>> Merge branch 'upstream-merge' into next
>>>
>>> is aborting with the error:
>>>
>>> qemu-kvm: qemu-kvm.git/hw/vhost.c:123: vhost_dev_unassign_memory:
>>> Assertion `to>= 0' failed.
>>> Aborted
>>>
>>
>> It's a bug in vhost:
>>
>> /* Assign/unassign. Keep an unsorted array of non-overlapping
>> * memory regions in dev->mem. */
>> static void vhost_dev_unassign_memory(struct vhost_dev *dev,
>> uint64_t start_addr,
>> uint64_t size)
>> {
>> int from, to, n = dev->mem->nregions;
>> /* Track overlapping/split regions for sanity checking. */
>> int overlap_start = 0, overlap_end = 0, overlap_middle = 0, split = 0;
>>
>> for (from = 0, to = 0; from < n; ++from, ++to) {
>> struct vhost_memory_region *reg = dev->mem->regions + to;
>> uint64_t reglast;
>> uint64_t memlast;
>> uint64_t change;
>>
>> /* clone old region */
>> if (to != from) {
>> memcpy(reg, dev->mem->regions + from, sizeof *reg);
>> }
>>
>> /* No overlap is simple */
>> if (!ranges_overlap(reg->guest_phys_addr, reg->memory_size,
>> start_addr, size)) {
>> continue;
>> }
>>
>> /* Split only happens if supplied region
>> * is in the middle of an existing one. Thus it can not
>> * overlap with any other existing region. */
>> assert(!split);
>>
>> reglast = range_get_last(reg->guest_phys_addr, reg->memory_size);
>> memlast = range_get_last(start_addr, size);
>>
>> /* Remove whole region */
>> if (start_addr <= reg->guest_phys_addr && memlast >= reglast) {
>> --dev->mem->nregions;
>> --to;
>> assert(to >= 0);
>> ++overlap_middle;
>> continue;
>> }
>>
>>
>> We're removing the first region, and 'to' goes negative. Michael?
>
> Yes, that assert is wrong.
>
> --->
> Subject: vhost: remove an incorrect assert
>
> The 'to' can go negative when the first region gets removed
> (it gets incremented by to 0 immediately afterward), which
> makes the assertion fail. Nothing breaks if
> to < 0 here so just remove the assert.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>
> ----
>
> diff --git a/hw/vhost.c b/hw/vhost.c
> index c3d8821..19e7255 100644
> --- a/hw/vhost.c
> +++ b/hw/vhost.c
> @@ -120,7 +120,6 @@ static void vhost_dev_unassign_memory(struct vhost_dev *dev,
> if (start_addr <= reg->guest_phys_addr && memlast >= reglast) {
> --dev->mem->nregions;
> --to;
> - assert(to >= 0);
> ++overlap_middle;
> continue;
> }
>
Removing the assert appears to work fine.
Tested-by: David Ahern <daahern@cisco.com>
David
next prev parent reply other threads:[~2011-08-03 13:55 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-01 17:44 qemu-kvm aborts - vhost_dev_unassign_memory: Assertion `to >= 0' failed David Ahern
2011-08-01 17:44 ` [Qemu-devel] " David Ahern
2011-08-01 18:04 ` David Ahern
2011-08-01 18:04 ` [Qemu-devel] " David Ahern
2011-08-03 9:01 ` Avi Kivity
2011-08-03 9:01 ` [Qemu-devel] " Avi Kivity
2011-08-03 9:33 ` Wen Congyang
2011-08-03 11:48 ` Avi Kivity
2011-08-03 11:48 ` [Qemu-devel] " Avi Kivity
2011-08-03 12:24 ` Michael S. Tsirkin
2011-08-03 12:24 ` [Qemu-devel] " Michael S. Tsirkin
2011-08-03 13:55 ` David Ahern [this message]
2011-08-03 13:55 ` David Ahern
2011-08-03 15:00 ` Michael S. Tsirkin
2011-08-03 15:00 ` [Qemu-devel] " Michael S. Tsirkin
2011-08-04 18:48 ` David Ahern
2011-08-04 18:48 ` [Qemu-devel] " David Ahern
2011-08-04 19:17 ` Michael S. Tsirkin
2011-08-04 19:17 ` [Qemu-devel] " Michael S. Tsirkin
2011-08-04 19:23 ` David Ahern
2011-08-04 19:23 ` [Qemu-devel] " David Ahern
2011-08-03 13:07 ` Michael S. Tsirkin
2011-08-03 13:07 ` Michael S. Tsirkin
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=4E395363.5000200@cisco.com \
--to=daahern@cisco.com \
--cc=aliguori@us.ibm.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.