From patchwork Thu Jan 25 07:25:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10183717 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0F12B60383 for ; Thu, 25 Jan 2018 07:25:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA8F828A1B for ; Thu, 25 Jan 2018 07:25:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DE57A28A1D; Thu, 25 Jan 2018 07:25:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 151F728A1B for ; Thu, 25 Jan 2018 07:25:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751045AbeAYHZV (ORCPT ); Thu, 25 Jan 2018 02:25:21 -0500 Received: from mail-bn3nam01on0046.outbound.protection.outlook.com ([104.47.33.46]:37190 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750763AbeAYHZU (ORCPT ); Thu, 25 Jan 2018 02:25:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=pH0FDvduXA7uBeoPVAh+03GM25YhZ+pTN6sb+lnpA2k=; b=X/ZnUSxw+zG9mQFpODoGrqUKld3J32aFXHagmKERLVJcfxDDo2CyzzbxVzim+KWZREbovK8znP42u9oYx9Aqi6nYyqOheHBLnFIF+uF8Of6sBD0vGAVsC+Ky1DbN4bjvNqtMT9pl1Xv47wNMVxBQuA0FTqqDZCtrOOKddjAztEw= Received: from SN4PR0701MB3632.namprd07.prod.outlook.com (10.167.142.138) by SN4PR0701MB3631.namprd07.prod.outlook.com (10.167.142.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.428.17; Thu, 25 Jan 2018 07:25:18 +0000 Received: from SN4PR0701MB3632.namprd07.prod.outlook.com ([fe80::189e:bfe3:5ff1:9e9a]) by SN4PR0701MB3632.namprd07.prod.outlook.com ([fe80::189e:bfe3:5ff1:9e9a%13]) with mapi id 15.20.0428.024; Thu, 25 Jan 2018 07:25:18 +0000 From: "Madhani, Himanshu" To: Meelis Roos CC: Bart Van Assche , Dept-Eng QLA2xxx Upstream , "linux-scsi@vger.kernel.org" Subject: Re: qla2xxx UBSAN warning in 4.14-rc1 Thread-Topic: qla2xxx UBSAN warning in 4.14-rc1 Thread-Index: AQHTMGvbD7Xbp93jHESmFpO2/kKKdqOET5EAgAASDoCAAJjVgA== Date: Thu, 25 Jan 2018 07:25:18 +0000 Message-ID: References: <1516828413.3987.18.camel@wdc.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Himanshu.Madhani@cavium.com; x-originating-ip: [173.186.134.106] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; SN4PR0701MB3631; 6:pZnmhomCWCSDiDud5xN3ieNuris4zub9SUAQqmQuE1G3GB9RnKnEnn7S3+FVK9YXfDXKh/gTmbMjtOcKAwRtmPc/SzeNSZ1Z7cA9zV65/V7st+vKW3KGEkbWapWGxZ8PQ+ZIijTJqRcGDy/mYbeWN3cZPr9eYxQ1rDq6UHfeG2Dz1JWnfi7vC6fjpSDoOi2G7ZHV/KYJykLyRUZqB7ctEw448pAu0+rm7tF+PoM2X2/fVDQJmAmBhPrSjAdqMY7VNgGGFQdixFgTT38J9vfyA0UJk5bo57179m9ulDdHu8UWSrYGhN5OyU2G/8Xat7SAKHkOyV8sCfV9GbWjGUGCVGB+tTQSVTkCqgx6BZen82ymKoPQWVI98UNWxNM/NFDf; 5:jzYZdbTS4eMS+iFCmvo76iVWpS3bdR6/M17OHlAQMvNrN+0yjmwA0P/0Cl7mNRE1j9Ub7QSfdBGwh4fqvBCzZJqVX/VA8ngtPCcAsoIeAtTDvjU394UPabEuzcvU69M+M1Ssy4K7DiQ+kxEcOxyEtp/Fr8uxiqaYT2XsM/3O8WQ=; 24:mQuYquB2KE2wobB6vNboLzSMrXDxk6El8x0ccJGMz8JERayIFi6lUL/TrRDEx+8tP/E32aOJKrSILfCxDZ61d5++mBSkDcYGY6cgKz6vPhM=; 7:Hcz8rrxm2TGvc7MdbyTD0uKaNbl1lqvqKgjwV56m/e3Ksub5S0Ag+rreT4gcVeZhiDTE6sY/eN3YYki18tXvg4Wa671bzRVwybA4x7E+uq2UP79rsNMb/kmtokDQSYG9R2N3DexcazXTcgDsxtQk4A0yf55KnOqP/v92VYf7tXUcGQmQh519UEDPofH1gZx3SoP5F9UDY5slNR2qcYWPCyn4tL1+JR2U9EPnj90cFS3aa8ftdfkmCvVWyqHsUt/d x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: e2bd779a-90a0-418e-0e1d-08d563c4c96f x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(2017052603307)(7153060)(7193020); SRVR:SN4PR0701MB3631; x-ms-traffictypediagnostic: SN4PR0701MB3631: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(5005006)(8121501046)(3231023)(2400081)(944501161)(3002001)(10201501046)(93006095)(93001095)(6041288)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(20161123560045)(6072148)(201708071742011); SRVR:SN4PR0701MB3631; BCL:0; PCL:0; RULEID:; SRVR:SN4PR0701MB3631; x-forefront-prvs: 0563F2E8B7 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(346002)(376002)(396003)(39380400002)(366004)(69224002)(189003)(199004)(6436002)(6512007)(6486002)(3846002)(6116002)(6246003)(33656002)(53936002)(106356001)(82746002)(5250100002)(14454004)(72206003)(66066001)(6916009)(102836004)(76176011)(53546011)(6506007)(59450400001)(478600001)(8676002)(2950100002)(81166006)(81156014)(2900100001)(8936002)(99286004)(186003)(36756003)(97736004)(105586002)(26005)(54906003)(316002)(25786009)(86362001)(5660300001)(68736007)(2906002)(4326008)(229853002)(305945005)(83716003)(3280700002)(3660700001)(7736002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN4PR0701MB3631; H:SN4PR0701MB3632.namprd07.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 2fjGmRCOKbl6Y6gEIJMvMLKA/zXRcd4/COJ9Zi5LfXbjV4NnEfD49UAeQdrsZdCYtWdjW83LxUjtMkih3tUoaQ== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-ID: <0702E2E31FFBA24DBCC1369265C8F8CA@namprd07.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-Network-Message-Id: e2bd779a-90a0-418e-0e1d-08d563c4c96f X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Jan 2018 07:25:18.5937 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR0701MB3631 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Meelis, > On Jan 24, 2018, at 2:18 PM, Meelis Roos wrote: > >>> Hello, I decided to widen the coverage of my kernel testbed and put some >>> FC cards into servers. This one is a PCI-X QLA2340 in HP Proliant DL 380 >>> G4 (first 64-bit generation of Proliants). I got a UBSAN warning from >>> qla2xxx before probing for the firmware. >> >> Would it be possible for you to test the (completely untested) patch below? > > It compiles without warnings and the driver loads without warnings. > > Meanwhile I tried the following patch, also successfully. > > However, the same problem is present in qla24xx_mbx_completion (and can > also be trivially patched over). > > I did not understand the logic of what's goind on with mailboxes - there > seem to be up to 32 of them and for some reason, a bitmask is used for > iterating over them, with mboxes = ha->mcp->in_mb filtering out some > mailboxes, and in_mb bitmap value comes from firmware? > > diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c > index 2fd79129bb2a..7868930ae1c8 100644 > --- a/drivers/scsi/qla2xxx/qla_isr.c > +++ b/drivers/scsi/qla2xxx/qla_isr.c > @@ -272,7 +272,7 @@ qla2x00_mbx_completion(scsi_qla_host_t *vha, uint16_t mb0) > struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; > > /* Read all mbox registers? */ > - mboxes = (1 << ha->mbx_count) - 1; > + mboxes = (1ULL << ha->mbx_count) - 1; > if (!ha->mcp) > ql_dbg(ql_dbg_async, vha, 0x5001, "MBX pointer ERROR.\n"); > else > > -- > Meelis Roos (mroos@linux.ee) Since I did could not get hold of 4G adapter for testing, i was not able to get to this one fixed in time. Bart’s change looks good and with your testing should be good to include. I also noticed qla24xx_mbx_completion() will need this fix. I was able to confirm it on my setup with 16/32G adapter. Would you care to send formal patch and add my ACK to it? Thanks for all the effort on getting this tested on your setup. Thanks, - Himanshu diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c index d1e7fd905f16..b97b14a89ac3 100644 --- a/drivers/scsi/qla2xxx/qla_isr.c +++ b/drivers/scsi/qla2xxx/qla_isr.c @@ -272,7 +272,7 @@ qla2x00_mbx_completion(scsi_qla_host_t *vha, uint16_t mb0) struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; /* Read all mbox registers? */ - mboxes = (1 << ha->mbx_count) - 1; + mboxes = (ha->mbx_count != 32 ? 1U << ha->mbx_count : 0) - 1U; if (!ha->mcp) ql_dbg(ql_dbg_async, vha, 0x5001, "MBX pointer ERROR.\n"); else @@ -2881,7 +2881,7 @@ qla24xx_mbx_completion(scsi_qla_host_t *vha, uint16_t mb0) struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; /* Read all mbox registers? */ - mboxes = (1 << ha->mbx_count) - 1; + mboxes = (ha->mbx_count != 32 ? 1U << ha->mbx_count : 0) - 1U; if (!ha->mcp) ql_dbg(ql_dbg_async, vha, 0x504e, "MBX pointer ERROR.\n”);