Message ID | 1232233990-20383-1-git-send-email-xudong.hao@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
> mmap is used in qemu_vmalloc function instead of qemu_memalign(commit > 7dda5dc8), so it should change qemu_vfree to munmap to fix a unmatched > issue. > > This issue appears when a PCI device is being assigned to KVM guest, > failure to read PCI rom file will bring RAM free, then the incorrect > qemu_vfree calling will cause a segment fault. > > Signed-off-by: Xudong Hao <xudong.hao@intel.com> > --- > exec.c | 6 +----- > 1 files changed, 1 insertions(+), 5 deletions(-) > > diff --git a/exec.c b/exec.c > index fa1e0c3..d40d237 100644 > --- a/exec.c > +++ b/exec.c > @@ -1152,15 +1152,11 @@ void qemu_ram_free(ram_addr_t addr) > abort(); > #endif > } else { > -#if defined(TARGET_S390X) && defined(CONFIG_KVM) > - munmap(block->host, block->length); > -#else > if (xen_enabled()) { > xen_invalidate_map_cache_entry(block->host); > } else { > - qemu_vfree(block->host); > + munmap(block->host, block->length); > } > -#endif > } > g_free(block); > break; Just "git pull". :) This is very similar to commit e7a09b9 (osdep: introduce qemu_anon_ram_free to free qemu_anon_ram_alloc-ed memory, 2013-05-13) Paolo -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
PiAtLS0tLU9yaWdpbmFsIE1lc3NhZ2UtLS0tLQ0KPiBGcm9tOiBQYW9sbyBCb256aW5pIFttYWls dG86cGJvbnppbmlAcmVkaGF0LmNvbV0NCj4gU2VudDogRnJpZGF5LCBNYXkgMjQsIDIwMTMgMTox MyBBTQ0KPiBUbzogSGFvLCBYdWRvbmcNCj4gQ2M6IGt2bUB2Z2VyLmtlcm5lbC5vcmc7IGdsZWJA cmVkaGF0LmNvbTsgcWVtdS1kZXZlbEBub25nbnUub3JnDQo+IFN1YmplY3Q6IFJlOiBbUEFUQ0hd IHFlbXUta3ZtOiBmaXggdW5tYXRjaGVkIFJBTSBhbGxvY3Rpb24vZnJlZQ0KPiANCj4gP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ZWNhdXNlIG1hbnkgdXNlciBhcmUgdXNpbmcgcWVtdS1rdm0gZm9yIEtWTS4gDQoNCkFueXdh eSBwbGVhc2UgaWdub3JlIHRoaXMgcGF0Y2guDQoNClRoYW5rcywNCi1YdWRvbmcNCg0K -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 05/23/2013 07:21 PM, Hao, Xudong wrote: >> Just "git pull". :) This is very similar to commit e7a09b9 (osdep: introduce >> qemu_anon_ram_free to free qemu_anon_ram_alloc-ed memory, 2013-05-13) >> > > OK, this commit do the same thing as my patch, I did not notice qemu upstream tree, just take a look at qemu-kvm tree, but I think this commit should be backport to qemu-kvm tree, because many user are using qemu-kvm for KVM. That argues that the qemu-kvm tree needs one final commit that wipes everything and replaces it with a readme file that tells users to upgrade to the qemu upstream tree, now that the qemu-kvm tree has been merged upstream and is no longer actively maintained.
Um, something's wrong with the Date. Care to resend with that fixed? Thanks, /mjt 18.01.2009 02:13, Xudong Hao wrote: > mmap is used in qemu_vmalloc function instead of qemu_memalign(commit > 7dda5dc8), so it should change qemu_vfree to munmap to fix a unmatched > issue. [...] -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
> -----Original Message----- > From: Michael Tokarev [mailto:mjt@tls.msk.ru] > Sent: Wednesday, May 29, 2013 2:34 AM > To: Hao, Xudong > Cc: kvm@vger.kernel.org; gleb@redhat.com; pbonzini@redhat.com; > qemu-devel@nongnu.org > Subject: Re: [PATCH] qemu-kvm: fix unmatched RAM alloction/free > > Um, something's wrong with the Date. Care to resend with that fixed? > Because the similar fix are already in qemu upstream, seems we need not this patch longer. > Thanks, > > /mjt > > 18.01.2009 02:13, Xudong Hao wrote: > > mmap is used in qemu_vmalloc function instead of qemu_memalign(commit > > 7dda5dc8), so it should change qemu_vfree to munmap to fix a unmatched > > issue. > [...] -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/exec.c b/exec.c index fa1e0c3..d40d237 100644 --- a/exec.c +++ b/exec.c @@ -1152,15 +1152,11 @@ void qemu_ram_free(ram_addr_t addr) abort(); #endif } else { -#if defined(TARGET_S390X) && defined(CONFIG_KVM) - munmap(block->host, block->length); -#else if (xen_enabled()) { xen_invalidate_map_cache_entry(block->host); } else { - qemu_vfree(block->host); + munmap(block->host, block->length); } -#endif } g_free(block); break;
mmap is used in qemu_vmalloc function instead of qemu_memalign(commit 7dda5dc8), so it should change qemu_vfree to munmap to fix a unmatched issue. This issue appears when a PCI device is being assigned to KVM guest, failure to read PCI rom file will bring RAM free, then the incorrect qemu_vfree calling will cause a segment fault. Signed-off-by: Xudong Hao <xudong.hao@intel.com> --- exec.c | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-)