From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 844B1C433FF for ; Tue, 13 Aug 2019 14:25:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 62B5E20844 for ; Tue, 13 Aug 2019 14:25:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729438AbfHMOZr (ORCPT ); Tue, 13 Aug 2019 10:25:47 -0400 Received: from foss.arm.com ([217.140.110.172]:37942 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729344AbfHMOZr (ORCPT ); Tue, 13 Aug 2019 10:25:47 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 088F8344; Tue, 13 Aug 2019 07:25:46 -0700 (PDT) Received: from e121166-lin.cambridge.arm.com (unknown [10.1.196.255]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A971F3F706; Tue, 13 Aug 2019 07:25:44 -0700 (PDT) Date: Tue, 13 Aug 2019 15:25:40 +0100 From: Lorenzo Pieralisi To: Haiyang Zhang Cc: "sashal@kernel.org" , "bhelgaas@google.com" , "linux-hyperv@vger.kernel.org" , "linux-pci@vger.kernel.org" , KY Srinivasan , Stephen Hemminger , "olaf@aepfle.de" , vkuznets , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v3] PCI: hv: Detect and fix Hyper-V PCI domain number collision Message-ID: <20190813142540.GA5070@e121166-lin.cambridge.arm.com> References: <1565634013-19404-1-git-send-email-haiyangz@microsoft.com> <20190813101417.GA14977@e121166-lin.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On Tue, Aug 13, 2019 at 12:55:59PM +0000, Haiyang Zhang wrote: > > > > -----Original Message----- > > From: Lorenzo Pieralisi > > Sent: Tuesday, August 13, 2019 6:14 AM > > To: Haiyang Zhang > > Cc: sashal@kernel.org; bhelgaas@google.com; linux- > > hyperv@vger.kernel.org; linux-pci@vger.kernel.org; KY Srinivasan > > ; Stephen Hemminger ; > > olaf@aepfle.de; vkuznets ; linux- > > kernel@vger.kernel.org > > Subject: Re: [PATCH v3] PCI: hv: Detect and fix Hyper-V PCI domain number > > collision > > > > On Mon, Aug 12, 2019 at 06:20:53PM +0000, Haiyang Zhang wrote: > > > Currently in Azure cloud, for passthrough devices including GPU, 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 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. > > > > > > As recommended by Azure host team, the bytes 4, 5 have more uniqueness > > > (info entropy) than bytes 8, 9. So now we use bytes 4, 5 as the PCI domain > > > numbers. On older hosts, bytes 4, 5 can also be used -- no backward > > > compatibility issues here. The chance of collision is greatly reduced. In > > > the rare cases of collision, we will detect and find another number that is > > > not in use. > > > > I have not explained what I meant correctly. This patch fixes an > > issue and the "find another number" fallback can be also applied > > to the current kernel without changing the bytes you use for > > domain numbers. > > > > This patch would leave old kernels susceptible to breakage. > > > > Again, I have no Azure knowledge but it seems better to me to > > add a fallback "find another number" allocation on top of mainline > > and send it to stable kernels. Then we can add another patch to > > change the bytes you use to reduce the number of collision. > > > > Please let me know what you think, thanks. > > Thanks for your clarification. > Actually, I hope the stable kernel will be patched to use bytes 4,5 too, > because host provided numbers are persistent across reboots, we like > to use them if possible. > > I think we can either -- > 1) Apply this patch for mainline and stable kernels as well. > 2) Or, break this patch into two patches, and apply both of them for > Mainline and stable kernels. (2) since one patch is a fix and the other one an (optional - however important it is) change. This way if the optional change needs reverting we still have a working kernel. In the end it is up to you - I am just expressing what I think is the most sensible way forward. Lorenzo