From: Sean Christopherson <sean.j.christopherson@intel.com>
To: Ahmed Abd El Mawgood <ahmedsoliman0x666@gmail.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
rkrcmar@redhat.com, Jonathan Corbet <corbet@lwn.net>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
hpa@zytor.com, x86@kernel.org, kvm@vger.kernel.org,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
ovich00@gmail.com, kernel-hardening@lists.openwall.com,
nigel.edwards@hpe.com,
Boris Lukashev <blukashev@sempervictus.com>,
Hossam Hassan <7ossam9063@gmail.com>,
Ahmed Lotfy <A7med.lotfey@gmail.com>
Subject: Re: [PATCH V5 5/5] KVM: Small Refactoring to kvm_free_memslot
Date: Mon, 29 Oct 2018 09:51:09 -0700 [thread overview]
Message-ID: <20181029165109.GB27144@linux.intel.com> (raw)
In-Reply-To: <20181026151223.16810-6-ahmedsoliman0x666@gmail.com>
On Fri, Oct 26, 2018 at 05:12:23PM +0200, Ahmed Abd El Mawgood wrote:
> This should be a little bit more readable and prone to memory leaks
Describe what is being, both in the subject line and continuing on in
the full changelog, e.g. "Small Refactoring to kvm_free_memslot" doesn't
provide any clue as to what is being done. And this is not what I would
describe as refactoring, e.g. verifying the new behavior means tracing
through its impact on __kvm_set_memory_region().
Lastly, this should be sent as a separate patch. There is no dependency
on the ROE code and if it actually addresses a potential memory leak (I
haven't actually reviewed the code itself) it should go in sooner rather
than later.
>
> Signed-off-by: Ahmed Abd El Mawgood <ahmedsoliman0x666@gmail.com>
> ---
> virt/kvm/kvm_main.c | 15 +++++++--------
> 1 file changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 2d3011e8490e..79c98db03c84 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -550,11 +550,11 @@ static void kvm_destroy_dirty_bitmap(struct kvm_memory_slot *memslot)
> * Free any memory in @free but not in @dont.
> */
> static void kvm_free_memslot(struct kvm *kvm, struct kvm_memory_slot *free,
> - struct kvm_memory_slot *dont)
> + struct kvm_memory_slot *dont,
> + enum kvm_mr_change change)
> {
> + if (change == KVM_MR_DELETE) {
> #ifdef CONFIG_KVM_ROE
> - if (!dont) {
> - //TODO still this might leak
> struct protected_chunk *pos, *n;
> struct list_head *head = free->prot_list;
> kvfree(free->roe_bitmap);
> @@ -564,10 +564,9 @@ static void kvm_free_memslot(struct kvm *kvm, struct kvm_memory_slot *free,
> kvfree(pos);
> }
> kvfree(free->prot_list);
> - }
> #endif
> - if (!dont || free->dirty_bitmap != dont->dirty_bitmap)
> kvm_destroy_dirty_bitmap(free);
> + }
>
> kvm_arch_free_memslot(kvm, free, dont);
>
> @@ -582,7 +581,7 @@ static void kvm_free_memslots(struct kvm *kvm, struct kvm_memslots *slots)
> return;
>
> kvm_for_each_memslot(memslot, slots)
> - kvm_free_memslot(kvm, memslot, NULL);
> + kvm_free_memslot(kvm, memslot, NULL, KVM_MR_DELETE);
>
> kvfree(slots);
> }
> @@ -1100,14 +1099,14 @@ int __kvm_set_memory_region(struct kvm *kvm,
>
> kvm_arch_commit_memory_region(kvm, mem, &old, &new, change);
>
> - kvm_free_memslot(kvm, &old, &new);
> + kvm_free_memslot(kvm, &old, &new, change);
> kvfree(old_memslots);
> return 0;
>
> out_slots:
> kvfree(slots);
> out_free:
> - kvm_free_memslot(kvm, &new, &old);
> + kvm_free_memslot(kvm, &new, &old, change);
> out:
> return r;
> }
> --
> 2.18.1
>
next prev parent reply other threads:[~2018-10-29 16:51 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-26 15:12 [PATCH V5 0/5] KVM: X86: Introducing ROE Protection Kernel Hardening Ahmed Abd El Mawgood
2018-10-26 15:12 ` [PATCH V5 1/5] KVM: X86: Memory ROE documentation Ahmed Abd El Mawgood
2018-10-29 16:42 ` gRe: [PATCH V5 1/5] KVM: X86: Memory ROE documentation^[ Sean Christopherson
2018-10-31 16:02 ` gRe: [PATCH V5 1/5] KVM: X86: Memory ROE documentation Ahmed Soliman
2018-10-26 15:12 ` [PATCH V5 2/5] KVM: X86: Adding arbitrary data pointer in kvm memslot iterator functions Ahmed Abd El Mawgood
2018-10-26 15:12 ` [PATCH V5 3/5] KVM: X86: Adding skeleton for Memory ROE Ahmed Abd El Mawgood
2018-10-26 15:12 ` [PATCH V5 4/5] KVM: X86: Adding support for byte granular memory ROE Ahmed Abd El Mawgood
2018-10-26 15:12 ` [PATCH V5 5/5] KVM: Small Refactoring to kvm_free_memslot Ahmed Abd El Mawgood
2018-10-29 16:51 ` Sean Christopherson [this message]
2018-10-29 6:46 ` [PATCH V5 0/5] KVM: X86: Introducing ROE Protection Kernel Hardening Ingo Molnar
2018-10-30 16:49 ` Ahmed Soliman
2018-10-29 18:01 ` Igor Stoppa
2018-10-31 23:21 ` Ahmed Soliman
2018-11-01 15:56 ` Igor Stoppa
2018-10-30 17:31 ` Christian Borntraeger
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=20181029165109.GB27144@linux.intel.com \
--to=sean.j.christopherson@intel.com \
--cc=7ossam9063@gmail.com \
--cc=A7med.lotfey@gmail.com \
--cc=ahmedsoliman0x666@gmail.com \
--cc=blukashev@sempervictus.com \
--cc=bp@alien8.de \
--cc=corbet@lwn.net \
--cc=hpa@zytor.com \
--cc=kernel-hardening@lists.openwall.com \
--cc=kvm@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=nigel.edwards@hpe.com \
--cc=ovich00@gmail.com \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
--cc=tglx@linutronix.de \
--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;
as well as URLs for NNTP newsgroup(s).