]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
s390/pci: Improve handling of unset UID
authorNiklas Schnelle <schnelle@linux.ibm.com>
Mon, 18 May 2020 18:24:27 +0000 (20:24 +0200)
committerMarcelo Henrique Cerri <marcelo.cerri@canonical.com>
Mon, 22 Jun 2020 20:21:10 +0000 (17:21 -0300)
BugLink: https://bugs.launchpad.net/bugs/1874056
When UID checking is enabled a UID value of 0 is invalid and can not be
set by the user. On z/VM it is however used to indicate an unset UID.
Until now, this lead to the behavior that one PCI function could be
attached with UID 0 after which z/VM would prohibit further attachment.

Now if the user then turns off UID checking in z/VM the user could
seemingly attach additional PCI functions that would however not show up
in Linux as that would not be informed of the change in UID checking
mode. This is unexpected and confusing and lead to bug reports against
Linux.

Instead now, if we encounter an unset UID value of 0 treat it as
indicating that UID checking was turned off, switch to automatic domain
allocation, and warn the user of the possible misconfiguration.

Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
(backported from commit 7a11c67a1ff9b0231eaaaa6a28294776d55b569a)
Signed-off-by: Frank Heimes <frank.heimes@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
arch/s390/include/asm/pci.h
arch/s390/pci/pci.c
arch/s390/pci/pci_clp.c

index 7850e8c8c79a11ace14d5a62c5e254c49b10fad1..abce7aa6c8cbc1a699205cc3f01e782260c51270 100644 (file)
@@ -190,6 +190,9 @@ int clp_enable_fh(struct zpci_dev *, u8);
 int clp_disable_fh(struct zpci_dev *);
 int clp_get_state(u32 fid, enum zpci_state *state);
 
+/* UID */
+void update_uid_checking(bool new);
+
 /* IOMMU Interface */
 int zpci_init_iommu(struct zpci_dev *zdev);
 void zpci_destroy_iommu(struct zpci_dev *zdev);
index 0af46683dd669eed249ea4888fde622d22a214fa..c0f80e896d7bc7407975e726a82de7aa923af108 100644 (file)
@@ -662,6 +662,13 @@ static int zpci_alloc_domain(struct zpci_dev *zdev)
 
        if (zpci_unique_uid) {
                zdev->domain = (u16) zdev->uid;
+               if (zdev->domain == 0) {
+                       pr_warn("UID checking is active but no UID is set for PCI function %08x, so automatic domain allocation is used instead\n",
+                               zdev->fid);
+                       update_uid_checking(false);
+                       goto auto_allocate;
+               }
+
                if (test_bit(zdev->domain, zpci_domain)) {
                        spin_unlock(&zpci_domain_lock);
                        pr_err("Adding PCI function %08x failed because domain %04x is already assigned\n",
@@ -673,6 +680,7 @@ static int zpci_alloc_domain(struct zpci_dev *zdev)
                spin_unlock(&zpci_domain_lock);
                return 0;
        }
+auto_allocate:
        /*
         * We can always auto allocate domains below ZPCI_NR_DEVICES.
         * There is either a free domain or we have reached the maximum in
index 281e0dd4c614ecfa0fbac050bdcef626cac76f6c..cfc9ae9df85dcfb5288cad482af28f0009d61c95 100644 (file)
@@ -24,7 +24,7 @@
 
 bool zpci_unique_uid;
 
-static void update_uid_checking(bool new)
+void update_uid_checking(bool new)
 {
        if (zpci_unique_uid != new)
                zpci_dbg(1, "uid checking:%d\n", new);