(V2) Map hot-plugged BAR into SPAPR processor host bus

When a device is hot-plugged into the PAPR PCI PHB, find an unmapped
memory sub-region within the geusts memory or io address space. If
successful, cause a memory subregion to be mapped into guest memory by
writing the appropriate BARs in the device's config space.

Signed-off-by: Mike Day <ncmike@ncultra.org>
Merge pull request #3 from ncultra/spapr-pci-hotplug-dev2

(V2) Map hot-plugged BAR into SPAPR processor host bus
pci: make pci_bar useable outside pci.c

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
memory: add memory_region_find_subregion

Similar to memory_region_find, but only search for overlaps among
regions that are a child of the region passed in. This is useful
for finding free ranges within a parent range to map to, in
addition to the use-cases similarly served by memory_region_find.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
*spapr_pci: rework spapr_map_BARs to use new mr func

This re-works the code a little to remove reliance on
MemoryRegionSections and instead just return a hwaddr based on the
results of the search.

We also add logic to search in increments of r->size, since the
pci code expects that and masks of any that aren't r->size-aligned.

Also, pci code has some checks against PCI_COMMAND region memory
it'll allow BARs to be programmed, so add those calls as well.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
*spapr_pci: add missing OF properties for PCI nodes

The main ones we were missing to allow discovery by kernel was
name, reg, and assigned-addresses. With these in place the device
will *in some cases* get added to /sys/devices, but there are
page fault errors present that need to be worked through. Possibly
we need to begin region allocation at higher addresses for io/mmio
regions, as that seems to be the only difference between the
hotplug assignments vs. SLOF

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
*spapr_pci: fix unused warning and remove defunct debug statement