From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755199AbcEaRgW (ORCPT ); Tue, 31 May 2016 13:36:22 -0400 Received: from mail-by2on0128.outbound.protection.outlook.com ([207.46.100.128]:26959 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751133AbcEaRgU convert rfc822-to-8bit (ORCPT ); Tue, 31 May 2016 13:36:20 -0400 From: Jake Oshins To: Vitaly Kuznetsov , "linux-pci@vger.kernel.org" CC: "linux-kernel@vger.kernel.org" , "devel@linuxdriverproject.org" , Bjorn Helgaas , Haiyang Zhang , KY Srinivasan Subject: RE: [PATCH 2/2] PCI: hv: handle all pending messages in hv_pci_onchannelcallback() Thread-Topic: [PATCH 2/2] PCI: hv: handle all pending messages in hv_pci_onchannelcallback() Thread-Index: AQHRun4Yi2s1fk51t0O0oVHDduVOsp/TUI2Q Date: Tue, 31 May 2016 17:36:17 +0000 Message-ID: References: <1464617879-19581-1-git-send-email-vkuznets@redhat.com> <1464617879-19581-3-git-send-email-vkuznets@redhat.com> In-Reply-To: <1464617879-19581-3-git-send-email-vkuznets@redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=microsoft.com; x-originating-ip: [2001:4898:80e8:9::563] x-ms-office365-filtering-correlation-id: 7b5c03a3-5de0-4460-544b-08d3897a1251 x-microsoft-exchange-diagnostics: 1;DM2PR0301MB0782;5:mEAHRRcZWPT2i+YGUp/xLMrXO0Z6Gk63tVb2NfZhuGDDQC5MD5CNCyXc5NHr4LzL4ktTDmhsx4LlcNzDWiDIsAdQpSh9cYJrye9hhL00+W2E0iLUmqXVRwLaaz4qtFimyrAxxvmpzNo+hIr5W443fQ==;24:4/zYG8aL0AV2U0DZ9S6kP3RXQEFvpDhOWt9zJzn22P1/jVPVr2xdpqCeGZUdxTGu88vx8LaB16nQwWqnP1hjYcPyooTY7hZO+OTr4rS/9m0=;7:XKBIZawlyHzR1jrL8Q+dvRgReBSz1cmFmJOcqlW0y8K7aGPCqnCZPq5ENvJ4Nbr4/yG/Tfkyq72SBDQ/HET2wf2I8bb1JBhsPyflU+QBXqCyuIHRFD8xJOmbqTzp+DhcVugroNBig0Mq0je3G5W4s97hS2tPr5e87mUPwtZkdlI= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB0782; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(9452136761055)(211936372134217); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026)(61426038)(61427038);SRVR:DM2PR0301MB0782;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB0782; x-forefront-prvs: 095972DF2F x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(377454003)(13464003)(19580405001)(107886002)(106116001)(99286002)(19580395003)(11100500001)(9686002)(5004730100002)(74316001)(189998001)(5001770100001)(5008740100001)(87936001)(33656002)(4001430100002)(10090500001)(76576001)(4326007)(5003600100002)(15650500001)(5002640100001)(5005710100001)(6116002)(77096005)(2950100001)(122556002)(2900100001)(3660700001)(86362001)(102836003)(2501003)(3280700002)(92566002)(76176999)(81166006)(8676002)(8936002)(8990500004)(54356999)(50986999)(10290500002)(586003)(10400500002)(2906002)(3826002);DIR:OUT;SFP:1102;SCL:1;SRVR:DM2PR0301MB0782;H:DM2PR0301MB1232.namprd03.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-originalarrivaltime: 31 May 2016 17:36:17.3675 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR0301MB0782 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > -----Original Message----- > From: Vitaly Kuznetsov [mailto:vkuznets@redhat.com] > Sent: Monday, May 30, 2016 7:18 AM > To: linux-pci@vger.kernel.org > Cc: linux-kernel@vger.kernel.org; devel@linuxdriverproject.org; Bjorn > Helgaas ; Haiyang Zhang > ; KY Srinivasan ; Jake > Oshins > Subject: [PATCH 2/2] PCI: hv: handle all pending messages in > hv_pci_onchannelcallback() > > When we have an interrupt from host we have a bit set in event page > indicating there are messages for the particular channel. We need to read > them all as we won't get signaled for what was on the queue before we > cleared the bit in vmbus_on_event(). This applies to all Hyper-V drivers > and the pass-through driver should do the same. > I did non meet any bugs, the issue was found by code inspection. We don't > have many events going through hv_pci_onchannelcallback(), this explains > why nobody reported the issue before. > > While on it, fix handling non-zero vmbus_recvpacket_raw() return values by > dropping out. If the return value is not zero it is wrong to inspect > buffer or bytes_recvd as these may contain invalid data. > > Signed-off-by: Vitaly Kuznetsov Acked-by: Jake Oshins > --- > drivers/pci/host/pci-hyperv.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c > index a68ec49..7de341d 100644 > --- a/drivers/pci/host/pci-hyperv.c > +++ b/drivers/pci/host/pci-hyperv.c > @@ -1657,12 +1657,16 @@ static void hv_pci_onchannelcallback(void > *context) > continue; > } > > + /* Zero length indicates there are no more packets. */ > + if (ret || !bytes_recvd) > + break; > + > /* > * All incoming packets must be at least as large as a > * response. > */ > if (bytes_recvd <= sizeof(struct pci_response)) > - break; > + continue; > desc = (struct vmpacket_descriptor *)buffer; > > switch (desc->type) { > @@ -1724,7 +1728,6 @@ static void hv_pci_onchannelcallback(void > *context) > desc->type, req_id, bytes_recvd); > break; > } > - break; > } > > kfree(buffer); > -- > 2.5.5 This is good, too. Thanks, Jake Oshins