From patchwork Sun Apr 26 20:42:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 1277229 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 499Kbl5FDvz9sSW; Mon, 27 Apr 2020 06:42:43 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1jSo6p-0003D8-GG; Sun, 26 Apr 2020 20:42:39 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jSo6n-0003Cp-WC for kernel-team@lists.ubuntu.com; Sun, 26 Apr 2020 20:42:37 +0000 Received: from mail-qk1-f199.google.com ([209.85.222.199]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jSo6n-0001Mz-L2 for kernel-team@lists.ubuntu.com; Sun, 26 Apr 2020 20:42:37 +0000 Received: by mail-qk1-f199.google.com with SMTP id d15so17354091qkg.1 for ; Sun, 26 Apr 2020 13:42:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YMA3b1MbDt/cCGPSnNNp+A2x00JVmiNExF35swX+P6w=; b=hh6AUn9+xwoYMAdNLs6ZXvwHor00a9cSb6XqS6ym5TR5hZ9P1Eb4rrI8rp0N2RZE/1 jdjMyQ6SzQrTs/Mbfy3TVxDCvTCp21kTgGc1k5cOKY29aV11B7LoNOh+yXt1Yf+O8ZFq tVuTPeYPmFnwmXB3oUqS4KcDvI0uSKSubkX4SOktMmHuZl9Zbyhxv2Ewz5z76n/nBU/m Dh45sBt6iejW73795iNc2jh/rhRGQzGwFAhzYnkGs1h35wPs5NRb3PohXOkr/rQH4vBk lPYkdKkmpYUUUe3ZIVSmkExAKBLeNjqAoRYhbWVYeV6otZ2/cvyDQ7vzTTtvtPT8nltP SWQw== X-Gm-Message-State: AGi0PuYY2uuE0Vk5P4ER9ojaZEqXVWRkW77Z1xQCebGMFHwQVWpG5tmT sBB5S3ALUCKoB9vtp047/JE0LN5UUZDxY1cPLZija2ZERl/1f1rQAvjBpXK3QNFV/w37EcO3EgP vxD4bE/1g00fEsbH7aNeK5MUDSx8rkVCDDKGhXrgY X-Received: by 2002:a37:a4d2:: with SMTP id n201mr18974084qke.121.1587933756352; Sun, 26 Apr 2020 13:42:36 -0700 (PDT) X-Google-Smtp-Source: APiQypLOk6VCPK/FqtudgftJ9GJ6jJ2C1gH9JOCpKhDv6iJPXBpTIAaddkwU/nKnZR6D2F0inaF81A== X-Received: by 2002:a37:a4d2:: with SMTP id n201mr18974077qke.121.1587933756049; Sun, 26 Apr 2020 13:42:36 -0700 (PDT) Received: from gallifrey.lan ([201.82.186.200]) by smtp.gmail.com with ESMTPSA id m7sm8321858qke.124.2020.04.26.13.42.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Apr 2020 13:42:35 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [bionic:linux-azure-4.15][PATCH 1/5] Revert "Revert "PCI: hv: Make sure the bus domain is really unique"" Date: Sun, 26 Apr 2020 17:42:25 -0300 Message-Id: <20200426204229.119093-2-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200426204229.119093-1-marcelo.cerri@canonical.com> References: <20200426203646.115503-1-marcelo.cerri@canonical.com> <20200426204229.119093-1-marcelo.cerri@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" BugLink: https://bugs.launchpad.net/bugs/1867220 This reverts commit f784c428da66621df751e6856be17f85e8b19b0e. Signed-off-by: Marcelo Henrique Cerri --- drivers/pci/host/pci-hyperv.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c index 59b5a07019bc..f14eb17972b6 100644 --- a/drivers/pci/host/pci-hyperv.c +++ b/drivers/pci/host/pci-hyperv.c @@ -1657,19 +1657,6 @@ static struct hv_pci_dev *new_pcichild_device(struct hv_pcibus_device *hbus, get_pcichild(hpdev, hv_pcidev_ref_childlist); spin_lock_irqsave(&hbus->device_list_lock, flags); - /* - * When a device is being added to the bus, we set the PCI domain - * number to be the device serial number, which is non-zero and - * unique on the same VM. The serial numbers start with 1, and - * increase by 1 for each device. So device names including this - * can have shorter names than based on the bus instance UUID. - * Only the first device serial number is used for domain, so the - * domain number will not change after the first device is added. - * The lower 16 bits of the serial number is used, otherwise some - * drivers may not be able to handle it. - */ - if (list_empty(&hbus->children)) - hbus->sysdata.domain = desc->ser & 0xFFFF; list_add_tail(&hpdev->list_entry, &hbus->children); spin_unlock_irqrestore(&hbus->device_list_lock, flags); return hpdev; From patchwork Sun Apr 26 20:42:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 1277230 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 499Kbq14xXz9sSk; Mon, 27 Apr 2020 06:42:47 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1jSo6t-0003Ex-MZ; Sun, 26 Apr 2020 20:42:43 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jSo6q-0003DW-1t for kernel-team@lists.ubuntu.com; Sun, 26 Apr 2020 20:42:40 +0000 Received: from mail-qv1-f70.google.com ([209.85.219.70]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jSo6p-0001N8-Ml for kernel-team@lists.ubuntu.com; Sun, 26 Apr 2020 20:42:39 +0000 Received: by mail-qv1-f70.google.com with SMTP id f4so16326486qvu.19 for ; Sun, 26 Apr 2020 13:42:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=w4FIyCLtxcWc3Dzp2bMDG0sKsEUbfSpTfVevzUFiR68=; b=jY/PM5vvCO9/6pX4hov9QNVkxENsfBsT+2KVBm1jLbuqgh5FhL/BFKmkwfr1bwSRl5 735JYNaUtbamrbzKp+OYVQq+MB7pqWLrU9Tri+Ed2lAhwFjHwLhO4kfp8gbHtMzbO4of b1LfJR10tsxn/7LA8rsFtrvFw8QQ9ykYQStTmW2RSo9f4qdy7pGBgiVcIfuz6q00ir4O BhZ3oLqr/q5btx/zFfqpQI3zF2R5viFODmZjBomgKCQOsb0liKgVI8L1YqsDi0Udnmv5 MJNS18TfVStxOt9altvszAS0jtAJpfctUmW5QapfRbw4rbSB6Jp2uJ3JddYJQUvlQ786 nD+w== X-Gm-Message-State: AGi0PuamGEEGLvWHYa2MhaeVr+OB4JqILSkAxq8M0JyBGLICqOBbqZK8 0DoXpBhEUy8Hy/0lnr23PBvLYVs5RqWV0Wa7UxvS51aIYkfBn7SlbPf0mNDq6aDWIvsBq/5V/hN xfGAbH+J5tEP/V0CrSgBX1kFW6e4YWaXDVAOezBwC X-Received: by 2002:a05:620a:158a:: with SMTP id d10mr18989385qkk.259.1587933758428; Sun, 26 Apr 2020 13:42:38 -0700 (PDT) X-Google-Smtp-Source: APiQypKnHVkK+n5Utw5UYAHQ9WjMC5xoh5UR2sJP4u7eS6D3i5Tjthi8Jgn1rULnbjEpgw0lusLBKA== X-Received: by 2002:a05:620a:158a:: with SMTP id d10mr18989374qkk.259.1587933758116; Sun, 26 Apr 2020 13:42:38 -0700 (PDT) Received: from gallifrey.lan ([201.82.186.200]) by smtp.gmail.com with ESMTPSA id m7sm8321858qke.124.2020.04.26.13.42.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Apr 2020 13:42:37 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [bionic:linux-azure-4.15][PATCH 2/5] Revert "PCI: hv: Use bytes 4 and 5 from instance ID as the PCI domain numbers" Date: Sun, 26 Apr 2020 17:42:26 -0300 Message-Id: <20200426204229.119093-3-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200426204229.119093-1-marcelo.cerri@canonical.com> References: <20200426203646.115503-1-marcelo.cerri@canonical.com> <20200426204229.119093-1-marcelo.cerri@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" BugLink: https://bugs.launchpad.net/bugs/1867220 This reverts commit ee4ee1df60eacc03ea478a7155269a3836ec4324. Signed-off-by: Marcelo Henrique Cerri --- drivers/pci/host/pci-hyperv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c index f14eb17972b6..d7df3aa1860e 100644 --- a/drivers/pci/host/pci-hyperv.c +++ b/drivers/pci/host/pci-hyperv.c @@ -2588,8 +2588,8 @@ static int hv_pci_probe(struct hv_device *hdev, * between domains derived from these instance IDs in the same * VM. */ - hbus->sysdata.domain = hdev->dev_instance.b[4] | - hdev->dev_instance.b[5] << 8; + hbus->sysdata.domain = hdev->dev_instance.b[9] | + hdev->dev_instance.b[8] << 8; hbus->hdev = hdev; atomic_inc(&hbus->remove_lock); From patchwork Sun Apr 26 20:42:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 1277231 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 499Kbq6FgZz9sSq; Mon, 27 Apr 2020 06:42:47 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1jSo6t-0003FG-U7; Sun, 26 Apr 2020 20:42:43 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jSo6s-0003EA-3z for kernel-team@lists.ubuntu.com; Sun, 26 Apr 2020 20:42:42 +0000 Received: from mail-qk1-f200.google.com ([209.85.222.200]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jSo6r-0001NK-Pa for kernel-team@lists.ubuntu.com; Sun, 26 Apr 2020 20:42:41 +0000 Received: by mail-qk1-f200.google.com with SMTP id a187so17228835qkg.18 for ; Sun, 26 Apr 2020 13:42:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tVZ/JRiqyNTGQk3TXoD9Clzu0fHcsx0FfP97BX1uJuQ=; b=eBw8LMcdZl75YXiOsG3PBX8TA3Dt1L39fLyPQw7HINO6LoYW1I8FtQ9y17u8NcdX/3 aTmL5dUEVQ3/MjBvzTtPBN8t8RsbcyWRyGLOMYPk7Xd89whsqA0iGj4SPGgGy+XMEaAk t4GxlVhFl2TI7WZ8PLctRc2CuVBokKLm69ytwDfZ/IUstiin7/0DRnm2tIbZqFJaIsge aE66Qz1pf1FeeXm/0YAVmWAmMgs+groBa6Gh6SfRPRNm/xc6rBgZkEvS55w4DTH/+2oi LPo90B/YVqDxLIWCYjUjG8Jmk91dlM1rABU94/58lIkXkTPuuiuScRh0L6QdF3a2bmz2 0i1w== X-Gm-Message-State: AGi0PuZ2cL2ruilY0KZoqWJlxXrIQSsxfmMjyFhSs6+svoOYEh4Zehwu TtCqQmYCqaOManAA3aovrzuTqUhe6zAKqRGYyGKzbz9XsOe+cgJncWlKoMdZwPLFO7EHUt1YQD9 jgvOr9ZDCc8wUG7DIZrIe1bBEzY409ssoRmG/CftA X-Received: by 2002:ac8:5513:: with SMTP id j19mr20324365qtq.319.1587933760482; Sun, 26 Apr 2020 13:42:40 -0700 (PDT) X-Google-Smtp-Source: APiQypJ+QYYk9r/I5cz+jTXA2+kOQiKni4URvhC6NTnxwllxXRh4U0GIWL+c36T40M9sZ5i2rHW0IQ== X-Received: by 2002:ac8:5513:: with SMTP id j19mr20324354qtq.319.1587933760163; Sun, 26 Apr 2020 13:42:40 -0700 (PDT) Received: from gallifrey.lan ([201.82.186.200]) by smtp.gmail.com with ESMTPSA id m7sm8321858qke.124.2020.04.26.13.42.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Apr 2020 13:42:39 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [bionic:linux-azure-4.15][PATCH 3/5] PCI: hv: Add __aligned(8) to struct retarget_msi_interrupt Date: Sun, 26 Apr 2020 17:42:27 -0300 Message-Id: <20200426204229.119093-4-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200426204229.119093-1-marcelo.cerri@canonical.com> References: <20200426203646.115503-1-marcelo.cerri@canonical.com> <20200426204229.119093-1-marcelo.cerri@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Maya Nakamura BugLink: https://bugs.launchpad.net/bugs/1867220 Because Hyper-V requires that hypercall arguments be aligned on an 8 byte boundary, add __aligned(8) to struct retarget_msi_interrupt. Link: https://lore.kernel.org/lkml/87k1hlqlby.fsf@vitty.brq.redhat.com/ Signed-off-by: Maya Nakamura Signed-off-by: Lorenzo Pieralisi (backported from commit 6ae91579061c25f70e4301619ffd16e1b6b5defb) [marcelo.cerri@canonical.com: basically a clean cherry-pick, but the changes from drivers/pci/controller/pci-hyperv.c had to be applied to drivers/pci/host/pci-hyperv.c instead] Signed-off-by: Marcelo Henrique Cerri --- drivers/pci/host/pci-hyperv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c index d7df3aa1860e..a592b029fe34 100644 --- a/drivers/pci/host/pci-hyperv.c +++ b/drivers/pci/host/pci-hyperv.c @@ -430,7 +430,7 @@ struct retarget_msi_interrupt { struct hv_interrupt_entry int_entry; u64 reserved2; struct hv_device_interrupt_target int_target; -} __packed; +} __packed __aligned(8); /* * Driver specific state. From patchwork Sun Apr 26 20:42:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 1277232 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 499Kbw2xwYz9sSb; Mon, 27 Apr 2020 06:42:52 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1jSo6y-0003I8-7b; Sun, 26 Apr 2020 20:42:48 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jSo6u-0003Fd-F4 for kernel-team@lists.ubuntu.com; Sun, 26 Apr 2020 20:42:44 +0000 Received: from mail-qv1-f71.google.com ([209.85.219.71]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jSo6t-0001NQ-UL for kernel-team@lists.ubuntu.com; Sun, 26 Apr 2020 20:42:44 +0000 Received: by mail-qv1-f71.google.com with SMTP id x26so11737909qvd.20 for ; Sun, 26 Apr 2020 13:42:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1HzBNLIG5mHSbFngbR78I5h6L5VAtEQ3v3MNRWXhuR0=; b=DRMgg6XlyVOFjnfwNLPITDPykGeEN9r7N0PWxiW6qzEP5l6949HgFREL7pemLk+hoO zvq9oBxNcqfiZLnbytnI8Ih2z9qt2eDS1a0hyoRuGxsPzcTLIh/gp2dqqdYUoHAa9fNw edRq4PTkWDMZew73w17DlaglGKyRuSuk1PkZd5VNcv4zZrr1ONoAlCy73mDvgJ/3yNNU hwZr9PgKrde1kuiSDMVQrg+OjYXpi0FZLh8PN/tbLHQyuA7fCVLgPun5pn1GfQvy5/w/ UB6Utw6nVyavS/u8ydcTvSA15VK6tb6DVzS8bTQECa3xQOozR4LQ8QeFNaOHTey29NRJ BWAQ== X-Gm-Message-State: AGi0PuZVQtSl4MHJESV0TKmJ3jEAwtNndFRrwdCJ0Z11ehL9mdgmQa3O Rq1fJ/1yEndMB31eZqM+Oprsam18FSBCE5CYDh5phMBu+jaRAFnoujjK7LFMhXD0h5MWAfTh1Ct p1nuEPz1TN9+mFZbjLUBwG6YkHTWCTBdA85B8OCAk X-Received: by 2002:ac8:7419:: with SMTP id p25mr1287755qtq.241.1587933762510; Sun, 26 Apr 2020 13:42:42 -0700 (PDT) X-Google-Smtp-Source: APiQypKHKbWZW+RSOXEz6fEeH/s+AheVEE4PwExNCA4KOuT/04CAMupXBEi6JW1uJtz/JrOK5wTw3Q== X-Received: by 2002:ac8:7419:: with SMTP id p25mr1287735qtq.241.1587933762144; Sun, 26 Apr 2020 13:42:42 -0700 (PDT) Received: from gallifrey.lan ([201.82.186.200]) by smtp.gmail.com with ESMTPSA id m7sm8321858qke.124.2020.04.26.13.42.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Apr 2020 13:42:41 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [bionic:linux-azure-4.15][PATCH 4/5] PCI: hv: Detect and fix Hyper-V PCI domain number collision Date: Sun, 26 Apr 2020 17:42:28 -0300 Message-Id: <20200426204229.119093-5-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200426204229.119093-1-marcelo.cerri@canonical.com> References: <20200426203646.115503-1-marcelo.cerri@canonical.com> <20200426204229.119093-1-marcelo.cerri@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Haiyang Zhang BugLink: https://bugs.launchpad.net/bugs/1867220 Currently in Azure cloud, for passthrough devices, the host sets the device instance ID's bytes 8 - 15 to a value derived from the host HWID, which is the same on all devices in a VM. So, the device instance ID's bytes 8 and 9 provided by the host are no longer unique. This affects all Azure hosts since July 2018, and can cause device passthrough to VMs to fail because the bytes 8 and 9 are used as PCI domain number. Collision of domain numbers will cause the second device with the same domain number fail to load. In the cases of collision, we will detect and find another number that is not in use. Suggested-by: Michael Kelley Signed-off-by: Haiyang Zhang Signed-off-by: Lorenzo Pieralisi Acked-by: Sasha Levin (backported from commit be700103efd1050808db1cf00e52c3a2837bf802) [marcelo.cerri@canonical.com: basically a clean cherry-pick, but the changes from drivers/pci/controller/pci-hyperv.c had to be applied to drivers/pci/host/pci-hyperv.c instead] Signed-off-by: Marcelo Henrique Cerri --- drivers/pci/host/pci-hyperv.c | 92 ++++++++++++++++++++++++++++++----- 1 file changed, 79 insertions(+), 13 deletions(-) diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c index a592b029fe34..c414255d2ae6 100644 --- a/drivers/pci/host/pci-hyperv.c +++ b/drivers/pci/host/pci-hyperv.c @@ -2552,6 +2552,48 @@ static void put_hvpcibus(struct hv_pcibus_device *hbus) complete(&hbus->remove_event); } +#define HVPCI_DOM_MAP_SIZE (64 * 1024) +static DECLARE_BITMAP(hvpci_dom_map, HVPCI_DOM_MAP_SIZE); + +/* + * PCI domain number 0 is used by emulated devices on Gen1 VMs, so define 0 + * as invalid for passthrough PCI devices of this driver. + */ +#define HVPCI_DOM_INVALID 0 + +/** + * hv_get_dom_num() - Get a valid PCI domain number + * Check if the PCI domain number is in use, and return another number if + * it is in use. + * + * @dom: Requested domain number + * + * return: domain number on success, HVPCI_DOM_INVALID on failure + */ +static u16 hv_get_dom_num(u16 dom) +{ + unsigned int i; + + if (test_and_set_bit(dom, hvpci_dom_map) == 0) + return dom; + + for_each_clear_bit(i, hvpci_dom_map, HVPCI_DOM_MAP_SIZE) { + if (test_and_set_bit(i, hvpci_dom_map) == 0) + return i; + } + + return HVPCI_DOM_INVALID; +} + +/** + * hv_put_dom_num() - Mark the PCI domain number as free + * @dom: Domain number to be freed + */ +static void hv_put_dom_num(u16 dom) +{ + clear_bit(dom, hvpci_dom_map); +} + /** * hv_pci_probe() - New VMBus channel probe, for a root PCI bus * @hdev: VMBus's tracking struct for this root PCI bus @@ -2563,6 +2605,7 @@ static int hv_pci_probe(struct hv_device *hdev, const struct hv_vmbus_device_id *dev_id) { struct hv_pcibus_device *hbus; + u16 dom_req, dom; int ret; /* @@ -2577,19 +2620,34 @@ static int hv_pci_probe(struct hv_device *hdev, hbus->state = hv_pcibus_init; /* - * The PCI bus "domain" is what is called "segment" in ACPI and - * other specs. Pull it from the instance ID, to get something - * unique. Bytes 8 and 9 are what is used in Windows guests, so - * do the same thing for consistency. Note that, since this code - * only runs in a Hyper-V VM, Hyper-V can (and does) guarantee - * that (1) the only domain in use for something that looks like - * a physical PCI bus (which is actually emulated by the - * hypervisor) is domain 0 and (2) there will be no overlap - * between domains derived from these instance IDs in the same - * VM. + * The PCI bus "domain" is what is called "segment" in ACPI and other + * specs. Pull it from the instance ID, to get something usually + * unique. In rare cases of collision, we will find out another number + * not in use. + * + * Note that, since this code only runs in a Hyper-V VM, Hyper-V + * together with this guest driver can guarantee that (1) The only + * domain used by Gen1 VMs for something that looks like a physical + * PCI bus (which is actually emulated by the hypervisor) is domain 0. + * (2) There will be no overlap between domains (after fixing possible + * collisions) in the same VM. */ - hbus->sysdata.domain = hdev->dev_instance.b[9] | - hdev->dev_instance.b[8] << 8; + dom_req = hdev->dev_instance.b[8] << 8 | hdev->dev_instance.b[9]; + dom = hv_get_dom_num(dom_req); + + if (dom == HVPCI_DOM_INVALID) { + dev_err(&hdev->device, + "Unable to use dom# 0x%hx or other numbers", dom_req); + ret = -EINVAL; + goto free_bus; + } + + if (dom != dom_req) + dev_info(&hdev->device, + "PCI dom# 0x%hx has collision, using 0x%hx", + dom_req, dom); + + hbus->sysdata.domain = dom; hbus->hdev = hdev; atomic_inc(&hbus->remove_lock); @@ -2604,7 +2662,7 @@ static int hv_pci_probe(struct hv_device *hdev, hbus->sysdata.domain); if (!hbus->wq) { ret = -ENOMEM; - goto free_bus; + goto free_dom; } ret = vmbus_open(hdev->channel, pci_ring_size, pci_ring_size, NULL, 0, @@ -2681,6 +2739,8 @@ static int hv_pci_probe(struct hv_device *hdev, vmbus_close(hdev->channel); destroy_wq: destroy_workqueue(hbus->wq); +free_dom: + hv_put_dom_num(hbus->sysdata.domain); free_bus: free_page((unsigned long)hbus); return ret; @@ -2762,6 +2822,9 @@ static int hv_pci_remove(struct hv_device *hdev) put_hvpcibus(hbus); wait_for_completion(&hbus->remove_event); destroy_workqueue(hbus->wq); + + hv_put_dom_num(hbus->sysdata.domain); + free_page((unsigned long)hbus); return 0; } @@ -2789,6 +2852,9 @@ static void __exit exit_hv_pci_drv(void) static int __init init_hv_pci_drv(void) { + /* Set the invalid domain number's bit, so it will not be used */ + set_bit(HVPCI_DOM_INVALID, hvpci_dom_map); + return vmbus_driver_register(&hv_pci_drv); } From patchwork Sun Apr 26 20:42:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 1277233 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 499Kbx3rwMz9sSc; Mon, 27 Apr 2020 06:42:53 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1jSo6y-0003Ie-SY; Sun, 26 Apr 2020 20:42:48 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jSo6w-0003Gf-81 for kernel-team@lists.ubuntu.com; Sun, 26 Apr 2020 20:42:46 +0000 Received: from mail-qk1-f197.google.com ([209.85.222.197]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jSo6v-0001NY-Hx for kernel-team@lists.ubuntu.com; Sun, 26 Apr 2020 20:42:45 +0000 Received: by mail-qk1-f197.google.com with SMTP id f11so17254605qkk.16 for ; Sun, 26 Apr 2020 13:42:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=v+eClUxWUPM64j0TOye4xQ6soeAUP+PAf85Ddgl3VmQ=; b=oM9YS/NWMem0qczAVl1pRM72hoSTKGzPixRIk3skLtjAJwkrHWrrpBk0JWM1uDMCQP O3low/uZjB8SFkydwiUbS+NNxoAsn43AMTZ9Ku/i5d3zgCKp9pdXdDwujNke3EGI0Huo UopBxDLqgF6WxPhdh9bSiEmUfal6OYj8PYui2YS7ZzWuVllVoMyZaB/I/NrvNzeFDz7X 93hpXtDiK8UzHVhr/Hgx71Vfqzoqmi8SOFaRspzOf/HYGopGROV9uqck1H8SgjfDMh0v xikDhxVoYhdl3GAmtan+2vOzJBcclxH8u7uE1ELuiduR/aIdLmW1YsRiLI1vlproxo4n ek8w== X-Gm-Message-State: AGi0PuaBsmuOIhlVhdMDd+P9aonn1jETDmZYQo05O0OPUGcyg8AxQHoi 6OYezybiYhq2tsxFmYIpOC7YA2GUiFDTHxP7OSCnHCMUwvaHEF0D/fi8maM6WuAbUUCzOuad75l /at9/7w1OhVN+co0qZoujkdLHa8QUJW6qEDONTDzZ X-Received: by 2002:a37:508:: with SMTP id 8mr19844953qkf.265.1587933764283; Sun, 26 Apr 2020 13:42:44 -0700 (PDT) X-Google-Smtp-Source: APiQypImEUcK41lm/QyggwObTUV9BBXeBGbRRra+/wBfGDsPXanxUGOMO0ukKw1AzUbMNtNLsMwtpw== X-Received: by 2002:a37:508:: with SMTP id 8mr19844940qkf.265.1587933763946; Sun, 26 Apr 2020 13:42:43 -0700 (PDT) Received: from gallifrey.lan ([201.82.186.200]) by smtp.gmail.com with ESMTPSA id m7sm8321858qke.124.2020.04.26.13.42.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Apr 2020 13:42:43 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [bionic:linux-azure-4.15][PATCH 5/5] PCI: hv: Use bytes 4 and 5 from instance ID as the PCI domain numbers Date: Sun, 26 Apr 2020 17:42:29 -0300 Message-Id: <20200426204229.119093-6-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200426204229.119093-1-marcelo.cerri@canonical.com> References: <20200426203646.115503-1-marcelo.cerri@canonical.com> <20200426204229.119093-1-marcelo.cerri@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Haiyang Zhang BugLink: https://bugs.launchpad.net/bugs/1867220 As recommended by Azure host team, the bytes 4, 5 have more uniqueness (info entropy) than bytes 8, 9 so use them as the PCI domain numbers. On older hosts, bytes 4, 5 can also be used -- no backward compatibility issues are introduced and the chance of collision is greatly reduced. In the rare cases of collision, the driver code detects and finds another number that is not in use. Suggested-by: Michael Kelley Signed-off-by: Haiyang Zhang Signed-off-by: Lorenzo Pieralisi Acked-by: Sasha Levin (backported from commit f73f8a504e27959576a2f4d85182202561e426f2) [marcelo.cerri@canonical.com: basically a clean cherry-pick, but the changes from drivers/pci/controller/pci-hyperv.c had to be applied to drivers/pci/host/pci-hyperv.c instead] Signed-off-by: Marcelo Henrique Cerri --- drivers/pci/host/pci-hyperv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c index c414255d2ae6..81da709aa757 100644 --- a/drivers/pci/host/pci-hyperv.c +++ b/drivers/pci/host/pci-hyperv.c @@ -2632,7 +2632,7 @@ static int hv_pci_probe(struct hv_device *hdev, * (2) There will be no overlap between domains (after fixing possible * collisions) in the same VM. */ - dom_req = hdev->dev_instance.b[8] << 8 | hdev->dev_instance.b[9]; + dom_req = hdev->dev_instance.b[5] << 8 | hdev->dev_instance.b[4]; dom = hv_get_dom_num(dom_req); if (dom == HVPCI_DOM_INVALID) {