Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2957852imm; Mon, 28 May 2018 20:56:45 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLoJXajgdNxG0dFYeTIFg1Z9nDW0/re8vpBfytYt2H9F2tpW19/ZeeBOnZxmD0F0s+iQHr9 X-Received: by 2002:a62:4f4f:: with SMTP id d76-v6mr4613336pfb.188.1527566205792; Mon, 28 May 2018 20:56:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527566205; cv=none; d=google.com; s=arc-20160816; b=LuwqwjDYr6pSnS9jLvHEV+3FjjxJaYprBgs73kYSvNau4Bg6qZJvXiX0m44zMxrN5a hJ7PCVLbuiOnT9x/3+i7SPi4nbhbeTmlm4CyLo5l4jH2ar84h/eUaSrb107aDrVbbHe4 8Hs63I1ksoAbRFfDgHggD1h4/kQ0cUu6LvtMDw0Z36Hm3hSo/fOiFenTKz/nEF+tSXrT vexhg+ClpI77l7XGzEwzHO7qNNym68sDFQxcpuAnSnmJRxYBwWof0UtpqykuCY3t0bwi EAs4gCTlXvx6eaDLAiR8iyIe1zdgyeoKc1GCyAKBclGalSX4nraRCWf/PAqg6IcAstX6 LIYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:msip_labels :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=pRtuC/1kGm5fOYnyEPsyIz7e9it2LUmBCqGPpR+u1co=; b=R46naKMKoNvbpZgSS9tURjfBuQoG+cEJqqWsuMbikp9d4RyTRGXG9GH/SLJC4y1YaR 9TpAGPc3FVrejiPDr+9n0fBDRaOZKk+QqTirqXdx2g6vXMzppens1gK9So/PQj+f8axe U6TutjdhICEgRx+ROThrP1SW5wMvXrYTmLlE8jEYzOtPdOTOtt10BWY/z7ljmJRajjFm Rgb8Tqvy9i9/rZpoik8/iBvGlebDz0eXvf6KimrRQVryIYIF5pIUlJ0SOKolXRAoedsL BQvfjrt4tIUBjo6DMBK8Wh4oSx+hmKp83UJEM+z64fbc4sBpFJ4HmTVmTciiU6xkF2aX xbsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=ZCoDVr2O; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r4-v6si24894617pgp.103.2018.05.28.20.56.31; Mon, 28 May 2018 20:56:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=ZCoDVr2O; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935114AbeE2ATV (ORCPT + 99 others); Mon, 28 May 2018 20:19:21 -0400 Received: from mail-bl2nam02on0134.outbound.protection.outlook.com ([104.47.38.134]:57208 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932727AbeE2ATT (ORCPT ); Mon, 28 May 2018 20:19:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pRtuC/1kGm5fOYnyEPsyIz7e9it2LUmBCqGPpR+u1co=; b=ZCoDVr2Oa3mOqIJE1x2KtRj20zOYzLqKYIgHK9kUMPmpMxG6e76t3LESmndk/LoH1J44fpGSoNe1t6pWsuoUi0QXCgky+VS8e7JE4ad2UNujuZg6Y+sr3wc8b0PDZrxitgXJ0ZqVLyK3+GYi4VJIoF1S48XBgaEUeK6t6puHzWk= Received: from SN6PR2101MB1120.namprd21.prod.outlook.com (52.132.117.161) by SN6PR2101MB1007.namprd21.prod.outlook.com (52.132.117.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.820.2; Tue, 29 May 2018 00:19:16 +0000 Received: from SN6PR2101MB1120.namprd21.prod.outlook.com ([fe80::a066:fb18:6c3d:9cb]) by SN6PR2101MB1120.namprd21.prod.outlook.com ([fe80::a066:fb18:6c3d:9cb%3]) with mapi id 15.20.0820.001; Tue, 29 May 2018 00:19:16 +0000 From: "Michael Kelley (EOSG)" To: Dexuan Cui , 'Lorenzo Pieralisi' , 'Bjorn Helgaas' , "'linux-pci@vger.kernel.org'" , KY Srinivasan , Stephen Hemminger , "'olaf@aepfle.de'" , "'apw@canonical.com'" , "'jasowang@redhat.com'" CC: "'linux-kernel@vger.kernel.org'" , "'driverdev-devel@linuxdriverproject.org'" , Haiyang Zhang , "'vkuznets@redhat.com'" , "'marcelo.cerri@canonical.com'" Subject: RE: [PATCH] PCI: hv: Do not wait forever on a device that has disappeared Thread-Topic: [PATCH] PCI: hv: Do not wait forever on a device that has disappeared Thread-Index: AdPy2mt/5cq5najeS4qpn1DMFXGqNwEAQofQ Date: Tue, 29 May 2018 00:19:16 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Owner=decui@microsoft.com; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2018-05-23T21:11:58.7383302Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=General; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Application=Microsoft Azure Information Protection; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Extended_MSFT_Method=Automatic; Sensitivity=General x-originating-ip: [24.22.167.197] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;SN6PR2101MB1007;7:YT4fGATgf/NP5gsJ2opv47ZqO93ybzOtyKO0UDy6WqOgC4lun3GzOhf4mzxpyA2HQyXcu5fzI6lbNhiT7BH+9iDHnp+1ryKdiUZTDwUYNNuzx1az/pr02XQ8fCBOZUBkt5woFLmfmwAfRsvD6Ymm+TWyZSdu4bhzvMl7WNxXu1pbK1sU/0d++JuT0CMA7NJwhTsX5lm1XEtwBZsGd27m/QXNvsqT3J7ZaFSuxTmKA4YjmU8nx4SiNyo2Rzq4j5jy;20:iYMcb7wQYiLy0TYKsqeHwgH1pNey1a5W7a0kPLKrWAf/caDfYRHGQTmUuZRs8HljsBeP5fwk5KNPxXNNKxpOO6ts4rfSL0ouo7DSodmWyqXvP0IN+DjWJxwVnJj9sTdmXfOYzABSe0SkPVzp4slUBIZDU0gB+8ojM4XMqhLR4fU= x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(48565401081)(2017052603328)(7193020);SRVR:SN6PR2101MB1007; x-ms-traffictypediagnostic: SN6PR2101MB1007: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Michael.H.Kelley@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(244540007438412)(89211679590171); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3231254)(2018427008)(944501410)(52105095)(3002001)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123564045)(20161123562045)(6072148)(201708071742011)(7699016);SRVR:SN6PR2101MB1007;BCL:0;PCL:0;RULEID:;SRVR:SN6PR2101MB1007; x-forefront-prvs: 0687389FB0 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(376002)(39860400002)(346002)(396003)(39380400002)(189003)(199004)(86362001)(7736002)(97736004)(305945005)(25786009)(54906003)(316002)(22452003)(110136005)(3280700002)(8936002)(486006)(1511001)(3660700001)(72206003)(9686003)(5660300001)(102836004)(2900100001)(26005)(14454004)(6436002)(2906002)(55016002)(106356001)(7416002)(105586002)(8990500004)(6506007)(446003)(6246003)(478600001)(229853002)(86612001)(53936002)(5250100002)(3846002)(11346002)(10090500001)(76176011)(10290500003)(6116002)(7696005)(59450400001)(74316002)(4326008)(81156014)(476003)(99286004)(66066001)(8676002)(81166006)(68736007)(33656002)(491001);DIR:OUT;SFP:1102;SCL:1;SRVR:SN6PR2101MB1007;H:SN6PR2101MB1120.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 6jaDa3teLLO6yFYKFPorqXHwXTymrlAZSziZdgmitqtA7+aebZyB0D46Zlj0Zg1t3HkK+upYGBGqWETrts51KMJaAZqqfU4ZqtF/vFVwXuY+jpz1j93xxfrqCeWZjxkQM2KdCyA4shFqPmLWBFd8RUrDpxooHpZ53cVX5oOGrP6gC3QXb6QuUNuKcpoHdpPd spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 0a947828-e300-421b-795b-08d5c4f9d088 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0a947828-e300-421b-795b-08d5c4f9d088 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 May 2018 00:19:16.6205 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR2101MB1007 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >=20 > Before the guest finishes the device initialization, the device can be > removed anytime by the host, and after that the host won't respond to > the guest's request, so the guest should be prepared to handle this > case. >=20 > Signed-off-by: Dexuan Cui > Cc: Stephen Hemminger > Cc: K. Y. Srinivasan > --- > drivers/pci/host/pci-hyperv.c | 46 ++++++++++++++++++++++++++++++++-----= ------ > 1 file changed, 34 insertions(+), 12 deletions(-) >=20 While this patch solves the immediate problem of getting hung waiting for a response from Hyper-V that will never come, there's another scenario to look at that I think introduces a race. Suppose the guest VM issues a vmbus_sendpacket() request in one of the cases covered by this patch, and suppose that Hyper-V queues a response to the request, and then immediately follows with a rescind request. Processing the response will get queued to a tasklet associated with the channel, while processing the rescind will get queued to a tasklet associated with the top-level vmbus connection. From what I can see, the code doesn't impose any ordering on processing the two. If the rescind is processed first, the new wait_for_response() function may wake up, notice the rescind flag, and return an error. Its caller will return an error, and in doing so pop the completion packet off the stack. When the response is processed later, it will try to signal completion via a completion packet that no longer exists, and memory corruption will likely occur. Am I missing anything that would prevent this scenario from happening? It is admittedly low probability, and a solution seems non-trivial. I have= n't looked specifically, but a similar scenario is probably possible with the drivers for other VMbus devices. We should work on a generic solution. Michael