From patchwork Fri Sep 28 05:29:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: KVM: PPC: Book3S HV: Allow DTL to be unregistered through KVM_SET_ONE_REG interface Date: Thu, 27 Sep 2012 19:29:11 -0000 From: Paul Mackerras X-Patchwork-Id: 187718 Message-Id: <20120928052911.GA4852@bloggs.ozlabs.ibm.com> To: Alexander Graf Cc: kvm-ppc@vger.kernel.org, kvm@vger.kernel.org >From 0912ff6f7d95aa559af75ba69aa7f661357f5dce Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Fri, 28 Sep 2012 15:26:07 +1000 Subject: [PATCH] KVM: PPC: Book3S HV: Allow DTL to be set to address 0, length 0 Recently-added code to allow the dispatch trace log buffer address to be set with the KVM_SET_ONE_REG interface includes a check on the length to make sure the buffer is at least one entry long. This is appropriate when registering a buffer, but the interface also allows for any existing buffer to be unregistered by specifying a zero address. In this case the length check is not appropriate, so this makes the check conditional on the address being non-zero. Signed-off-by: Paul Mackerras --- arch/powerpc/kvm/book3s_hv.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 350b038..1eda13d 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -854,9 +854,8 @@ int kvmppc_set_one_reg(struct kvm_vcpu *vcpu, u64 id, union kvmppc_one_reg *val) addr = val->vpaval.addr; len = val->vpaval.length; r = -EINVAL; - if (len < sizeof(struct dtl_entry)) - break; - if (addr && !vcpu->arch.vpa.next_gpa) + if (addr && (len < sizeof(struct dtl_entry) || + !vcpu->arch.vpa.next_gpa)) break; len -= len % sizeof(struct dtl_entry); r = set_vpa(vcpu, &vcpu->arch.dtl, addr, len);