All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] KVM: PPC: Book3S HV: Outline of KVM-HV HPT resizing implementation
@ 2017-02-11  5:14 Dan Carpenter
  2017-02-15  3:45 ` David Gibson
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2017-02-11  5:14 UTC (permalink / raw)
  To: kvm-ppc

Hello David Gibson,

The patch 5e9859699aba: "KVM: PPC: Book3S HV: Outline of KVM-HV HPT
resizing implementation" from Dec 20, 2016, leads to the following
static checker warning:

	arch/powerpc/kvm/book3s_64_mmu_hv.c:1554 kvm_vm_ioctl_resize_hpt_commit()
	error: we previously assumed 'resize' could be null (see line 1532)

arch/powerpc/kvm/book3s_64_mmu_hv.c
  1514          mutex_lock(&kvm->lock);
  1515  
  1516          resize = kvm->arch.resize_hpt;
  1517  
  1518          /* This shouldn't be possible */
  1519          ret = -EIO;
  1520          if (WARN_ON(!kvm->arch.hpte_setup_done))
  1521                  goto out_no_hpt;
  1522  
  1523          /* Stop VCPUs from running while we mess with the HPT */
  1524          kvm->arch.hpte_setup_done = 0;
  1525          smp_mb();
  1526  
  1527          /* Boot all CPUs out of the guest so they re-read
  1528           * hpte_setup_done */
  1529          on_each_cpu(resize_hpt_boot_vcpu, NULL, 1);
  1530  
  1531          ret = -ENXIO;
  1532          if (!resize || (resize->order != shift))
                     ^^^^^^
Check.

  1533                  goto out;
  1534  
  1535          ret = -EBUSY;
  1536          if (!resize->prepare_done)
  1537                  goto out;
  1538  
  1539          ret = resize->error;
  1540          if (ret != 0)
  1541                  goto out;
  1542  
  1543          ret = resize_hpt_rehash(resize);
  1544          if (ret != 0)
  1545                  goto out;
  1546  
  1547          resize_hpt_pivot(resize);
  1548  
  1549  out:
  1550          /* Let VCPUs run again */
  1551          kvm->arch.hpte_setup_done = 1;
  1552          smp_mb();
  1553  out_no_hpt:
  1554          resize_hpt_release(kvm, resize);
                                        ^^^^^^
Oops.

  1555          mutex_unlock(&kvm->lock);
  1556          return ret;
  1557  }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [bug report] KVM: PPC: Book3S HV: Outline of KVM-HV HPT resizing implementation
  2017-02-11  5:14 [bug report] KVM: PPC: Book3S HV: Outline of KVM-HV HPT resizing implementation Dan Carpenter
@ 2017-02-15  3:45 ` David Gibson
  0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2017-02-15  3:45 UTC (permalink / raw)
  To: kvm-ppc

[-- Attachment #1: Type: text/plain, Size: 2410 bytes --]

On Sat, Feb 11, 2017 at 08:14:25AM +0300, Dan Carpenter wrote:
> Hello David Gibson,
> 
> The patch 5e9859699aba: "KVM: PPC: Book3S HV: Outline of KVM-HV HPT
> resizing implementation" from Dec 20, 2016, leads to the following
> static checker warning:
> 
> 	arch/powerpc/kvm/book3s_64_mmu_hv.c:1554 kvm_vm_ioctl_resize_hpt_commit()
> 	error: we previously assumed 'resize' could be null (see line
> 	1532)

Nice catch, thanks.  I've sent a patch for this.

> 
> arch/powerpc/kvm/book3s_64_mmu_hv.c
>   1514          mutex_lock(&kvm->lock);
>   1515  
>   1516          resize = kvm->arch.resize_hpt;
>   1517  
>   1518          /* This shouldn't be possible */
>   1519          ret = -EIO;
>   1520          if (WARN_ON(!kvm->arch.hpte_setup_done))
>   1521                  goto out_no_hpt;
>   1522  
>   1523          /* Stop VCPUs from running while we mess with the HPT */
>   1524          kvm->arch.hpte_setup_done = 0;
>   1525          smp_mb();
>   1526  
>   1527          /* Boot all CPUs out of the guest so they re-read
>   1528           * hpte_setup_done */
>   1529          on_each_cpu(resize_hpt_boot_vcpu, NULL, 1);
>   1530  
>   1531          ret = -ENXIO;
>   1532          if (!resize || (resize->order != shift))
>                      ^^^^^^
> Check.
> 
>   1533                  goto out;
>   1534  
>   1535          ret = -EBUSY;
>   1536          if (!resize->prepare_done)
>   1537                  goto out;
>   1538  
>   1539          ret = resize->error;
>   1540          if (ret != 0)
>   1541                  goto out;
>   1542  
>   1543          ret = resize_hpt_rehash(resize);
>   1544          if (ret != 0)
>   1545                  goto out;
>   1546  
>   1547          resize_hpt_pivot(resize);
>   1548  
>   1549  out:
>   1550          /* Let VCPUs run again */
>   1551          kvm->arch.hpte_setup_done = 1;
>   1552          smp_mb();
>   1553  out_no_hpt:
>   1554          resize_hpt_release(kvm, resize);
>                                         ^^^^^^
> Oops.
> 
>   1555          mutex_unlock(&kvm->lock);
>   1556          return ret;
>   1557  }
> 
> regards,
> dan carpenter
> 

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-02-15  3:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-11  5:14 [bug report] KVM: PPC: Book3S HV: Outline of KVM-HV HPT resizing implementation Dan Carpenter
2017-02-15  3:45 ` David Gibson

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.