Skip to content

Commit

Permalink
Merge tag 'for-linus-5.13b-rc3-tag' of git://git.kernel.org/pub/scm/l…
Browse files Browse the repository at this point in the history
…inux/kernel/git/xen/tip

Pull xen fixes from Juergen Gross:

 - a fix for a boot regression when running as PV guest on hardware
   without NX support

 - a small series fixing a bug in the Xen pciback driver when
   configuring a PCI card with multiple virtual functions

* tag 'for-linus-5.13b-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
  xen-pciback: reconfigure also from backend watch handler
  xen-pciback: redo VF placement in the virtual topology
  x86/Xen: swap NX determination and GDT setup on BSP
  • Loading branch information
torvalds committed May 22, 2021
2 parents a3969ef + c81d3d2 commit 23d7292
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 15 deletions.
8 changes: 4 additions & 4 deletions arch/x86/xen/enlighten_pv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1273,16 +1273,16 @@ asmlinkage __visible void __init xen_start_kernel(void)
/* Get mfn list */
xen_build_dynamic_phys_to_machine();

/* Work out if we support NX */
get_cpu_cap(&boot_cpu_data);
x86_configure_nx();

/*
* Set up kernel GDT and segment registers, mainly so that
* -fstack-protector code can be executed.
*/
xen_setup_gdt(0);

/* Work out if we support NX */
get_cpu_cap(&boot_cpu_data);
x86_configure_nx();

/* Determine virtual and physical address sizes */
get_cpu_address_sizes(&boot_cpu_data);

Expand Down
14 changes: 8 additions & 6 deletions drivers/xen/xen-pciback/vpci.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static int __xen_pcibk_add_pci_dev(struct xen_pcibk_device *pdev,
struct pci_dev *dev, int devid,
publish_pci_dev_cb publish_cb)
{
int err = 0, slot, func = -1;
int err = 0, slot, func = PCI_FUNC(dev->devfn);
struct pci_dev_entry *t, *dev_entry;
struct vpci_dev_data *vpci_dev = pdev->pci_dev_data;

Expand All @@ -95,22 +95,25 @@ static int __xen_pcibk_add_pci_dev(struct xen_pcibk_device *pdev,

/*
* Keep multi-function devices together on the virtual PCI bus, except
* virtual functions.
* that we want to keep virtual functions at func 0 on their own. They
* aren't multi-function devices and hence their presence at func 0
* may cause guests to not scan the other functions.
*/
if (!dev->is_virtfn) {
if (!dev->is_virtfn || func) {
for (slot = 0; slot < PCI_SLOT_MAX; slot++) {
if (list_empty(&vpci_dev->dev_list[slot]))
continue;

t = list_entry(list_first(&vpci_dev->dev_list[slot]),
struct pci_dev_entry, list);
if (t->dev->is_virtfn && !PCI_FUNC(t->dev->devfn))
continue;

if (match_slot(dev, t->dev)) {
dev_info(&dev->dev, "vpci: assign to virtual slot %d func %d\n",
slot, PCI_FUNC(dev->devfn));
slot, func);
list_add_tail(&dev_entry->list,
&vpci_dev->dev_list[slot]);
func = PCI_FUNC(dev->devfn);
goto unlock;
}
}
Expand All @@ -123,7 +126,6 @@ static int __xen_pcibk_add_pci_dev(struct xen_pcibk_device *pdev,
slot);
list_add_tail(&dev_entry->list,
&vpci_dev->dev_list[slot]);
func = dev->is_virtfn ? 0 : PCI_FUNC(dev->devfn);
goto unlock;
}
}
Expand Down
22 changes: 17 additions & 5 deletions drivers/xen/xen-pciback/xenbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ static int xen_pcibk_publish_pci_root(struct xen_pcibk_device *pdev,
return err;
}

static int xen_pcibk_reconfigure(struct xen_pcibk_device *pdev)
static int xen_pcibk_reconfigure(struct xen_pcibk_device *pdev,
enum xenbus_state state)
{
int err = 0;
int num_devs;
Expand All @@ -373,9 +374,7 @@ static int xen_pcibk_reconfigure(struct xen_pcibk_device *pdev)
dev_dbg(&pdev->xdev->dev, "Reconfiguring device ...\n");

mutex_lock(&pdev->dev_lock);
/* Make sure we only reconfigure once */
if (xenbus_read_driver_state(pdev->xdev->nodename) !=
XenbusStateReconfiguring)
if (xenbus_read_driver_state(pdev->xdev->nodename) != state)
goto out;

err = xenbus_scanf(XBT_NIL, pdev->xdev->nodename, "num_devs", "%d",
Expand Down Expand Up @@ -500,6 +499,10 @@ static int xen_pcibk_reconfigure(struct xen_pcibk_device *pdev)
}
}

if (state != XenbusStateReconfiguring)
/* Make sure we only reconfigure once. */
goto out;

err = xenbus_switch_state(pdev->xdev, XenbusStateReconfigured);
if (err) {
xenbus_dev_fatal(pdev->xdev, err,
Expand All @@ -525,7 +528,7 @@ static void xen_pcibk_frontend_changed(struct xenbus_device *xdev,
break;

case XenbusStateReconfiguring:
xen_pcibk_reconfigure(pdev);
xen_pcibk_reconfigure(pdev, XenbusStateReconfiguring);
break;

case XenbusStateConnected:
Expand Down Expand Up @@ -664,6 +667,15 @@ static void xen_pcibk_be_watch(struct xenbus_watch *watch,
xen_pcibk_setup_backend(pdev);
break;

case XenbusStateInitialised:
/*
* We typically move to Initialised when the first device was
* added. Hence subsequent devices getting added may need
* reconfiguring.
*/
xen_pcibk_reconfigure(pdev, XenbusStateInitialised);
break;

default:
break;
}
Expand Down

0 comments on commit 23d7292

Please sign in to comment.