From: Serhii Popovych <spopovyc@redhat.com> To: linux-kernel@vger.kernel.org Cc: michael@ellerman.id.au, paulus@samba.org, linuxppc-dev@lists.ozlabs.org, kvm-ppc@vger.kernel.org, david@gibson.dropbear.id.au Subject: [PATCH 4/4] KVM: PPC: Book3S HV: Remove redundant parameter from resize_hpt_release() Date: Wed, 29 Nov 2017 11:38:26 -0500 [thread overview] Message-ID: <1511973506-65683-5-git-send-email-spopovyc@redhat.com> (raw) In-Reply-To: <1511973506-65683-1-git-send-email-spopovyc@redhat.com> There is no need to pass it explicitly from the caller: struct kvm_resize_hpt already contains it. Additional benefit from this change is that BUG_ON() assertion now checks that mutex is held on kvm instance associated with resize structure we going to release. Also kill check for resize being NULL to make code simpler and we called with resize != NULL in all places except kvm_vm_ioctl_resize_hpt_commit(). Signed-off-by: Serhii Popovych <spopovyc@redhat.com> --- arch/powerpc/kvm/book3s_64_mmu_hv.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3s_64_mmu_hv.c index 690f061..a74a0ad 100644 --- a/arch/powerpc/kvm/book3s_64_mmu_hv.c +++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c @@ -1415,12 +1415,11 @@ static void resize_hpt_pivot(struct kvm_resize_hpt *resize) resize_hpt_debug(resize, "resize_hpt_pivot() done\n"); } -static void resize_hpt_release(struct kvm *kvm, struct kvm_resize_hpt *resize) +static void resize_hpt_release(struct kvm_resize_hpt *resize) { - BUG_ON(!mutex_is_locked(&kvm->lock)); + struct kvm *kvm = resize->kvm; - if (!resize) - return; + BUG_ON(!mutex_is_locked(&kvm->lock)); if (resize->error != -EBUSY) { kvmppc_free_hpt(&resize->hpt); @@ -1469,7 +1468,7 @@ static void resize_hpt_prepare_work(struct work_struct *work) resize->error = err; if (kvm->arch.resize_hpt != resize) - resize_hpt_release(kvm, resize); + resize_hpt_release(resize); mutex_unlock(&kvm->lock); } @@ -1499,13 +1498,13 @@ long kvm_vm_ioctl_resize_hpt_prepare(struct kvm *kvm, if (ret == -EBUSY) ret = 100; /* estimated time in ms */ else if (ret) - resize_hpt_release(kvm, resize); + resize_hpt_release(resize); goto out; } /* not suitable, cancel it */ - resize_hpt_release(kvm, resize); + resize_hpt_release(resize); } ret = 0; @@ -1590,7 +1589,8 @@ long kvm_vm_ioctl_resize_hpt_commit(struct kvm *kvm, kvm->arch.mmu_ready = 1; smp_mb(); out_no_hpt: - resize_hpt_release(kvm, resize); + if (resize) + resize_hpt_release(resize); mutex_unlock(&kvm->lock); return ret; } -- 1.8.3.1
WARNING: multiple messages have this Message-ID (diff)
From: Serhii Popovych <spopovyc@redhat.com> To: linux-kernel@vger.kernel.org Cc: michael@ellerman.id.au, paulus@samba.org, linuxppc-dev@lists.ozlabs.org, kvm-ppc@vger.kernel.org, david@gibson.dropbear.id.au Subject: [PATCH 4/4] KVM: PPC: Book3S HV: Remove redundant parameter from resize_hpt_release() Date: Wed, 29 Nov 2017 16:38:26 +0000 [thread overview] Message-ID: <1511973506-65683-5-git-send-email-spopovyc@redhat.com> (raw) In-Reply-To: <1511973506-65683-1-git-send-email-spopovyc@redhat.com> There is no need to pass it explicitly from the caller: struct kvm_resize_hpt already contains it. Additional benefit from this change is that BUG_ON() assertion now checks that mutex is held on kvm instance associated with resize structure we going to release. Also kill check for resize being NULL to make code simpler and we called with resize != NULL in all places except kvm_vm_ioctl_resize_hpt_commit(). Signed-off-by: Serhii Popovych <spopovyc@redhat.com> --- arch/powerpc/kvm/book3s_64_mmu_hv.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3s_64_mmu_hv.c index 690f061..a74a0ad 100644 --- a/arch/powerpc/kvm/book3s_64_mmu_hv.c +++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c @@ -1415,12 +1415,11 @@ static void resize_hpt_pivot(struct kvm_resize_hpt *resize) resize_hpt_debug(resize, "resize_hpt_pivot() done\n"); } -static void resize_hpt_release(struct kvm *kvm, struct kvm_resize_hpt *resize) +static void resize_hpt_release(struct kvm_resize_hpt *resize) { - BUG_ON(!mutex_is_locked(&kvm->lock)); + struct kvm *kvm = resize->kvm; - if (!resize) - return; + BUG_ON(!mutex_is_locked(&kvm->lock)); if (resize->error != -EBUSY) { kvmppc_free_hpt(&resize->hpt); @@ -1469,7 +1468,7 @@ static void resize_hpt_prepare_work(struct work_struct *work) resize->error = err; if (kvm->arch.resize_hpt != resize) - resize_hpt_release(kvm, resize); + resize_hpt_release(resize); mutex_unlock(&kvm->lock); } @@ -1499,13 +1498,13 @@ long kvm_vm_ioctl_resize_hpt_prepare(struct kvm *kvm, if (ret = -EBUSY) ret = 100; /* estimated time in ms */ else if (ret) - resize_hpt_release(kvm, resize); + resize_hpt_release(resize); goto out; } /* not suitable, cancel it */ - resize_hpt_release(kvm, resize); + resize_hpt_release(resize); } ret = 0; @@ -1590,7 +1589,8 @@ long kvm_vm_ioctl_resize_hpt_commit(struct kvm *kvm, kvm->arch.mmu_ready = 1; smp_mb(); out_no_hpt: - resize_hpt_release(kvm, resize); + if (resize) + resize_hpt_release(resize); mutex_unlock(&kvm->lock); return ret; } -- 1.8.3.1
next prev parent reply other threads:[~2017-11-29 16:38 UTC|newest] Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-11-29 16:38 [PATCH 0/4] Fix use after free in HPT resizing code and related minor improvements Serhii Popovych 2017-11-29 16:38 ` Serhii Popovych 2017-11-29 16:38 ` [PATCH 1/4] KVM: PPC: Book3S HV: Drop prepare_done from struct kvm_resize_hpt and cleanups Serhii Popovych 2017-11-29 16:38 ` Serhii Popovych 2017-11-30 3:40 ` David Gibson 2017-11-30 3:40 ` David Gibson 2017-11-29 16:38 ` [PATCH 2/4] KVM: PPC: Book3S HV: Improve kvmppc_allocate_hpt()/kvmppc_free_hpt() Serhii Popovych 2017-11-29 16:38 ` Serhii Popovych 2017-11-30 3:45 ` David Gibson 2017-11-30 3:45 ` David Gibson 2017-11-29 16:38 ` [PATCH 3/4] KVM: PPC: Book3S HV: Fix use after free in case of multiple resize requests Serhii Popovych 2017-11-29 16:38 ` Serhii Popovych 2017-11-30 3:51 ` David Gibson 2017-11-30 3:51 ` David Gibson 2017-11-29 16:38 ` Serhii Popovych [this message] 2017-11-29 16:38 ` [PATCH 4/4] KVM: PPC: Book3S HV: Remove redundant parameter from resize_hpt_release() Serhii Popovych 2017-11-30 3:53 ` David Gibson 2017-11-30 3:53 ` David Gibson 2017-11-30 3:54 ` [PATCH 0/4] Fix use after free in HPT resizing code and related minor improvements David Gibson 2017-11-30 3:54 ` David Gibson 2017-12-04 6:10 ` David Gibson 2017-12-04 6:10 ` David Gibson 2017-12-04 12:22 ` Michael Ellerman 2017-12-04 12:22 ` Michael Ellerman 2017-12-04 14:43 ` Serhii Popovych 2017-12-04 14:43 ` Serhii Popovych
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=1511973506-65683-5-git-send-email-spopovyc@redhat.com \ --to=spopovyc@redhat.com \ --cc=david@gibson.dropbear.id.au \ --cc=kvm-ppc@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linuxppc-dev@lists.ozlabs.org \ --cc=michael@ellerman.id.au \ --cc=paulus@samba.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: linkBe 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.