Skip to contentSkip to conversation

KVM: PPC: Book3S HV: Outline of KVM-HV HPT resizing implementation

bug report Dan Carpenter 2 participants 2 messages Feb 11, 2017 – Feb 15, 2017

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw
Quoted 9 lines · Dan Carpenter

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.

Quoted 56 lines

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

Signature · 4 lines
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