Skip to content

Commit 23d7292

Browse files
committed
Merge tag 'for-linus-5.13b-rc3-tag' of git://git.kernel.org/pub/scm/linux/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
2 parents a3969ef + c81d3d2 commit 23d7292

3 files changed

Lines changed: 29 additions & 15 deletions

File tree

arch/x86/xen/enlighten_pv.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,16 +1273,16 @@ asmlinkage __visible void __init xen_start_kernel(void)
12731273
/* Get mfn list */
12741274
xen_build_dynamic_phys_to_machine();
12751275

1276+
/* Work out if we support NX */
1277+
get_cpu_cap(&boot_cpu_data);
1278+
x86_configure_nx();
1279+
12761280
/*
12771281
* Set up kernel GDT and segment registers, mainly so that
12781282
* -fstack-protector code can be executed.
12791283
*/
12801284
xen_setup_gdt(0);
12811285

1282-
/* Work out if we support NX */
1283-
get_cpu_cap(&boot_cpu_data);
1284-
x86_configure_nx();
1285-
12861286
/* Determine virtual and physical address sizes */
12871287
get_cpu_address_sizes(&boot_cpu_data);
12881288

drivers/xen/xen-pciback/vpci.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static int __xen_pcibk_add_pci_dev(struct xen_pcibk_device *pdev,
7070
struct pci_dev *dev, int devid,
7171
publish_pci_dev_cb publish_cb)
7272
{
73-
int err = 0, slot, func = -1;
73+
int err = 0, slot, func = PCI_FUNC(dev->devfn);
7474
struct pci_dev_entry *t, *dev_entry;
7575
struct vpci_dev_data *vpci_dev = pdev->pci_dev_data;
7676

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

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

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

108112
if (match_slot(dev, t->dev)) {
109113
dev_info(&dev->dev, "vpci: assign to virtual slot %d func %d\n",
110-
slot, PCI_FUNC(dev->devfn));
114+
slot, func);
111115
list_add_tail(&dev_entry->list,
112116
&vpci_dev->dev_list[slot]);
113-
func = PCI_FUNC(dev->devfn);
114117
goto unlock;
115118
}
116119
}
@@ -123,7 +126,6 @@ static int __xen_pcibk_add_pci_dev(struct xen_pcibk_device *pdev,
123126
slot);
124127
list_add_tail(&dev_entry->list,
125128
&vpci_dev->dev_list[slot]);
126-
func = dev->is_virtfn ? 0 : PCI_FUNC(dev->devfn);
127129
goto unlock;
128130
}
129131
}

drivers/xen/xen-pciback/xenbus.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,8 @@ static int xen_pcibk_publish_pci_root(struct xen_pcibk_device *pdev,
359359
return err;
360360
}
361361

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

375376
mutex_lock(&pdev->dev_lock);
376-
/* Make sure we only reconfigure once */
377-
if (xenbus_read_driver_state(pdev->xdev->nodename) !=
378-
XenbusStateReconfiguring)
377+
if (xenbus_read_driver_state(pdev->xdev->nodename) != state)
379378
goto out;
380379

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

502+
if (state != XenbusStateReconfiguring)
503+
/* Make sure we only reconfigure once. */
504+
goto out;
505+
503506
err = xenbus_switch_state(pdev->xdev, XenbusStateReconfigured);
504507
if (err) {
505508
xenbus_dev_fatal(pdev->xdev, err,
@@ -525,7 +528,7 @@ static void xen_pcibk_frontend_changed(struct xenbus_device *xdev,
525528
break;
526529

527530
case XenbusStateReconfiguring:
528-
xen_pcibk_reconfigure(pdev);
531+
xen_pcibk_reconfigure(pdev, XenbusStateReconfiguring);
529532
break;
530533

531534
case XenbusStateConnected:
@@ -664,6 +667,15 @@ static void xen_pcibk_be_watch(struct xenbus_watch *watch,
664667
xen_pcibk_setup_backend(pdev);
665668
break;
666669

670+
case XenbusStateInitialised:
671+
/*
672+
* We typically move to Initialised when the first device was
673+
* added. Hence subsequent devices getting added may need
674+
* reconfiguring.
675+
*/
676+
xen_pcibk_reconfigure(pdev, XenbusStateInitialised);
677+
break;
678+
667679
default:
668680
break;
669681
}

0 commit comments

Comments
 (0)