From: Avi Kivity <avi@redhat.com>
To: "François Diakhate" <fdiakh@gmail.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH 2/2] KVM: Fix kvm_free_physmem memory leak.
Date: Sun, 26 Oct 2008 16:54:54 +0200 [thread overview]
Message-ID: <490484BE.9050807@redhat.com> (raw)
In-Reply-To: <6ad07c640810230629x1ed57744xf636d6b73c0e215a@mail.gmail.com>
François Diakhate wrote:
> Make sure that kvm_free_physmem actually frees memory
> when a memory slot is not user allocated.
>
> @@ -4195,7 +4195,7 @@ int kvm_arch_set_memory_region(struct kvm *kvm,
> memslot->userspace_addr = userspace_addr;
> spin_unlock(&kvm->mmu_lock);
> } else {
> - if (!old.user_alloc && old.rmap) {
> + if (!old.user_alloc && old.rmap && current->mm) {
> int ret;
>
>
What's the purpose of this?
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index a87f45e..b0d7435 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -639,8 +639,17 @@ void kvm_free_physmem(struct kvm *kvm)
> {
> int i;
>
> - for (i = 0; i < kvm->nmemslots; ++i)
> + for (i = 0; i < kvm->nmemslots; ++i) {
> + struct kvm_userspace_memory_region mem = {
> + .slot = i,
> + .guest_phys_addr = kvm->memslots[i].base_gfn << PAGE_SHIFT,
> + .memory_size = 0,
> + .flags = 0,
> + };
> +
> + kvm_set_memory_region(kvm, &mem, kvm->memslots[i].user_alloc);
> kvm_free_physmem_slot(&kvm->memslots[i], NULL);
> + }
> }
>
Better to fix kvm_free_physmem_slot() if it doesn't handle
!user_allocated memory properly.
--
error compiling committee.c: too many arguments to function
prev parent reply other threads:[~2008-10-26 14:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-23 13:29 [PATCH 2/2] KVM: Fix kvm_free_physmem memory leak François Diakhate
2008-10-26 14:54 ` Avi Kivity [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=490484BE.9050807@redhat.com \
--to=avi@redhat.com \
--cc=fdiakh@gmail.com \
--cc=kvm@vger.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 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.