From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 02DDCA00C2; Sun, 17 May 2020 11:18:44 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 66B1C1D5E7; Sun, 17 May 2020 11:18:44 +0200 (CEST) Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10078.outbound.protection.outlook.com [40.107.1.78]) by dpdk.org (Postfix) with ESMTP id 2C8ED1D5E4; Sun, 17 May 2020 11:18:43 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O1EnQTQUk0Q+6RSIAcT10b1S2eWt4r+N55NFVJN/1pjmqwCKW/Ti9MPITmwN7NHjM88piF+XQN1hykboIMkAr6r7Y8iMEpT2rV2NG9RfNtoAECZOaQ+8M4mLV/uL00Sb/G5tF1/724mtvlPjqFEi4SWuc8BtCCVRM5G6/8LuuicuU6XCz673mlxgHReWkC6JP+qYeVYMET1zeqsbOBh1HYypNmr7Bwga4D+xFT6pfU/pNYukXcjIW8/brPUNMeFd7tmt3ahWR3MU63F/OtWTpXhyYUrz83TemABkWIRA3++VoqgaWmOkOmu7nbH1eQddpqVfMsPqI3f0akXUzjgJcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OLJeMP4H88aeerp4eICLn0eADP6pNMs2TGrbex5/NRA=; b=boVbI1v2aw9OtdzQZZTCv/xrjqr1HxJAE2dRLoKXqAj3TsAayKRw0l6zR1wCwZWATK1pmtHqaPdKeJVXcYvnpZO3OfDAyn7Rq8P/+aoQ4u2Puo+8zP43cSWUurROSDjTr4GZHOje+6ZpxGKMD9fnVmzjUOehiGUPzW67juGl90vhbdIHT2vWHJoqMsuSv0RWK9iYMWp99jCnWU7PSDkUiT6tRPRlBtBQccMMDlxoxFObcsoo+YdRnCZA/Np5pxUklvbYje3SP4H7hxp5qo91kkoYe1MdSXUejiB9tCKhsVEjjGiq7N99h93P9Cno29ieGKhf02Ut7qAPzU9NClTHBA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OLJeMP4H88aeerp4eICLn0eADP6pNMs2TGrbex5/NRA=; b=jel8CqFNKiGYo5EXthKuImyDP5S9Y1O17tRzRknKYYzx3+ZXOUOrOf17qOwfdD214lrbasvNf/h5/J8BnW6nnsCnOxwKv+mEQtNVoZCiMd3hdN90+ghbZvsPtSPxOf8pLnPw386KEvnj3CybCEYCqWn8DmeTybS5S5YLYMWvOZE= Received: from AM0PR05MB6707.eurprd05.prod.outlook.com (2603:10a6:20b:15b::17) by AM0PR05MB5700.eurprd05.prod.outlook.com (2603:10a6:208:11e::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.25; Sun, 17 May 2020 09:18:41 +0000 Received: from AM0PR05MB6707.eurprd05.prod.outlook.com ([fe80::508:747b:cc12:5f6e]) by AM0PR05MB6707.eurprd05.prod.outlook.com ([fe80::508:747b:cc12:5f6e%6]) with mapi id 15.20.3000.022; Sun, 17 May 2020 09:18:41 +0000 From: Raslan Darawsheh To: Bing Zhao , Slava Ovsiienko CC: Ori Kam , Matan Azrad , "dev@dpdk.org" , "stable@dpdk.org" , Dekel Peled Thread-Topic: [PATCH] net/mlx5: fix left shift extension of doorbell bitmap Thread-Index: AQHWKpDQ4BAxSLmgn0epGm9waWzf8aisAwEg Date: Sun, 17 May 2020 09:18:41 +0000 Message-ID: References: <1589530438-437604-1-git-send-email-bingz@mellanox.com> In-Reply-To: <1589530438-437604-1-git-send-email-bingz@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: mellanox.com; dkim=none (message not signed) header.d=none;mellanox.com; dmarc=none action=none header.from=mellanox.com; x-originating-ip: [188.161.229.217] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 12c0e03c-ba31-40c3-27ae-08d7fa434ab5 x-ms-traffictypediagnostic: AM0PR05MB5700: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3044; x-forefront-prvs: 040655413E x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: oZuqtu4+tmgFNL8qcjv9vlnfonhfow+bE7yMBUUTGiGT9K8Xb8kNNyhj5gwtDTUBnTY2iKMTS7pnWoX48SNuVJ8rI/JSL7b5S6XvP0SWCy/B3ARLpbRHZHxF5AIDNL/0PjGqU1lxlwaG7vk9UmSyiVKu5tMXTRmRiaQlsjuzBSErpK56jKHPn2gXexDA3Eqez+dJiNqv8Q4rwoD6QeuYXdMXV7au1ssHEhLw31UBpgfPK+09GXXbtlrslOuBTfLJukNBDPtTZpk5n13ulOnaGfr4y2yIevlyUWsduTIM21W2wXShIgMDK4TnybgrWSmRBTH5VqkGVkMUfNidpXtXlpP09cM20yeq3lXjJxkrRNVSx4xxWhuB6M00NRxThob8gVkFdGxx89842BwGkoc5HgpOrBUEXLFEMvUyjpKRTuRRilLB4gViV8EmYnF+0P0c x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR05MB6707.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(346002)(136003)(366004)(376002)(396003)(39860400002)(110136005)(54906003)(64756008)(53546011)(26005)(186003)(7696005)(66446008)(66476007)(66556008)(52536014)(6506007)(2906002)(86362001)(9686003)(55016002)(107886003)(6636002)(66946007)(5660300002)(76116006)(450100002)(33656002)(316002)(4326008)(8676002)(8936002)(478600001)(71200400001); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: Zr4J3efIjTCyQorEFlfjDYa3jZlQb61n+gGAeJOdkoZyXDF2YALRWJcDz6UJLQzJTrHl7DphZe070lEPOGNNyTr8PnCSN5VFIiOYAtt7Vi++rfuitMHpQ6DjudmkHKssCbIr/Sf1w6wyTt2OYnBUrQAeww62yBxpbPtpg2D/MdlCi7FD20y8dLFXs26oME8bRTnNFKCQXTm1kmb3wh8RDjGtg2UWNcJRruioVs4h5mWvwYFQMSVTrR64xqpOeePbayMhnhbGYfQf2q3DBl6eQWT/IWucflqDGUOHzzsu2P8dpUq2ee/h2dQOjMWklVyxjTif91JTq7Lvmw9MYVPStHmN1ESa82S4dmusnBdNINEfZ5s2NvKPqm/61FGN79wTYX0kMOCkP0nqcKgJHcphZZVDdkifzDn0hkQ6YNrTdv8xInvJFFGrL+AVEohJVU+omzgukNmO948pCAmJs0NluDOcx2IuAHd5WiGgdjmxbzgIsTbIMli6mHV6CwSYKztM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 12c0e03c-ba31-40c3-27ae-08d7fa434ab5 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 May 2020 09:18:41.8318 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 1iAwaWmX4dY1csdTi+ieTiFqypsIybZ/xcElU/rv+FRgyNgtqdOaoQHzEqQtOg9SSqT4HXG4cmkne+vxvXODag== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB5700 Subject: Re: [dpdk-dev] [PATCH] net/mlx5: fix left shift extension of doorbell bitmap X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi, > -----Original Message----- > From: Bing Zhao > Sent: Friday, May 15, 2020 11:14 AM > To: Slava Ovsiienko ; Raslan Darawsheh > > Cc: Ori Kam ; Matan Azrad ; > dev@dpdk.org; stable@dpdk.org; Dekel Peled > Subject: [PATCH] net/mlx5: fix left shift extension of doorbell bitmap >=20 > The doorbell record is organized with page and bitmap. When some new > doorbell needs to be associated with a queue, the bit will be set > in the bitmap to indicate the corresponding doorbell occupied. A > counter is used to record the number of doorbell occupied to speed > up the searching. > If the number reachs the maximal value of a pre-defined number of a > page, a new page will be allocated. If not, then the bitmap will be > checked to find a free one. > The LSHIFT and OR (AND NOT) operations are used to update the bitmap > of a page. But 1 will be treated as a signed integer when compiling. > When the shift number is 31, the shifted value will be considered as > negative. Then a wrong extension will be done when setting it to a > 64-bits variable. All the upper 32-bits will be set to 1 by such > extension. > Then a wrong offset value will be calculated because of this. The > next 64 bits will be also treated as the bitmap and get corrupted > through the bit set operation. > The immediate value 1 needs to be used as 64 bits width explicitly. >=20 > Fixes: 21cae8580fd0 ("net/mlx5: allocate door-bells via DevX") > Cc: dekelp@mellanox.com > Cc: stable@dpdk.org >=20 > Signed-off-by: Bing Zhao > Acked-by: Viacheslav Ovsiienko > --- > drivers/net/mlx5/mlx5.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) >=20 > diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c > index 1445809..ab4adec 100644 > --- a/drivers/net/mlx5/mlx5.c > +++ b/drivers/net/mlx5/mlx5.c > @@ -2174,7 +2174,7 @@ struct mlx5_flow_id_pool * > /* Find the first clear bit. */ > MLX5_ASSERT(i < MLX5_DBR_BITMAP_SIZE); > j =3D rte_bsf64(~page->dbr_bitmap[i]); > - page->dbr_bitmap[i] |=3D (1 << j); > + page->dbr_bitmap[i] |=3D (UINT64_C(1) << j); > page->dbr_count++; > *dbr_page =3D page; > return (((i * 64) + j) * sizeof(uint64_t)); > @@ -2219,7 +2219,7 @@ struct mlx5_flow_id_pool * > int i =3D offset / 64; > int j =3D offset % 64; >=20 > - page->dbr_bitmap[i] &=3D ~(1 << j); > + page->dbr_bitmap[i] &=3D ~(UINT64_C(1) << j); > } > return ret; > } > -- > 1.8.3.1 Commit title changed to: net/mlx5: fix left shift extension of doorbell bitmap Patch applied to next-net-mlx, Kindest regards Raslan Darawsheh