Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp10766177rwd; Thu, 22 Jun 2023 04:43:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6DZVKRcfRvlyBygmcsn/jEwn8+Z+1W+su4JN3WCcz61DBMBbo1L2SE/yAu+YE6cFKQ5F/r X-Received: by 2002:a05:6808:21a6:b0:3a0:5a0f:493b with SMTP id be38-20020a05680821a600b003a05a0f493bmr3123180oib.0.1687434198881; Thu, 22 Jun 2023 04:43:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687434198; cv=none; d=google.com; s=arc-20160816; b=bkQFze6lzRjt8ERlOmccXbkMs0WVGlmh4fHDt9qAxCx9ZIycQKz7uXB3drMkeMOpEU WoqAjPVsfG30lIzLwCztC03an1JoZNi7qaM4iYqzKglERVjrIDb2KDRIglwAz5vGAqB3 olWEJQ4/5KDE2NP0Zg6woiqPr04AJv7Ru2SxEiagc8eanEQABfnlmHpCUQvQUAwljrHM LKtGUGxyvtTDW+ydd3y/qnzhWFlFHno/LOPKF6aQfHdePC+4X6CU6r2Jb4CbTgUJpYZi 4Y7kpZsA5qIItc2HLH2bGF27K+YVKHSfo5HXRFE5VmoZLdQ8tJ1/utWd4f2V6Y/Z63Nl QsDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=4UocAtdDWcFQBDQbyMRTlVN+OJ+gn9xShV1KG/UJtLY=; b=MTxEHGOzs/mqMAwpo4nkw5btIzubWM6uMgUcZvLX5BLiHyrM7w5d4d15rP3YQ/XDKj Ju8JihNJ9WjRsfU9xziKYKl5nOHVqjIvqKtS5PWZEWcK3rFkaGU3BHtOxiCzixm6gFLd z0kJK4u4Tl7z1mTsFL8vxys0FF/Swclz5dVFSFuXhgUrgzBHSCkz5cSRcUqIFWG2/v5W T3iPZMfLC6Cy4rBsTWvcnpnB7oy8OJCPWYU4mTDphUXi0Sy20NdORcE+VA6H8q1dhWGQ Hw4VvfxH1J/C8HonwNh+6XxIsjSiegIrYxh9uCgKrS6ELcVS4PZd9xh4QgwV81gRXQbM HcQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=rN2btcZT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y19-20020a63b513000000b005538a669b5fsi1165301pge.212.2023.06.22.04.43.06; Thu, 22 Jun 2023 04:43:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=rN2btcZT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230010AbjFVLXY (ORCPT + 99 others); Thu, 22 Jun 2023 07:23:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229628AbjFVLXW (ORCPT ); Thu, 22 Jun 2023 07:23:22 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C0FD10C1; Thu, 22 Jun 2023 04:23:21 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-98d34f1e54fso53090766b.2; Thu, 22 Jun 2023 04:23:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687433000; x=1690025000; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=4UocAtdDWcFQBDQbyMRTlVN+OJ+gn9xShV1KG/UJtLY=; b=rN2btcZTRGffzs30pcg7ygyRKMBqDI/BwxntPxdDURMQnIf6Vmp6s9TY7fBuFJ0+t2 saPDH6X3kBpMxPo8mt1Cj6nMFXWeYuR0qPiLezKRrYPeR4NA3tVfugkPoztw2O5O4A/p rkOdAh4PzAAHVoF0kASmBqHmyPCzddMiR8IHZtb8ruafeZYGhvLy42xNPPPvguh7WhtI tr+Qz3OMtcHafMAuzoOFOOtTwuEjhjbm2QTlBfWB+6L0fenh2xs9FSHd4FcS3f6rFDAq r8Ss10UeHNWGzMZJcSa4D+YS6aerXMS760IDUiIm1de/s8NfxM/AF2FMqq7ZoeXV2R06 F0TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687433000; x=1690025000; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=4UocAtdDWcFQBDQbyMRTlVN+OJ+gn9xShV1KG/UJtLY=; b=aUt30Ri+dB8lOAAOXQCUGfLrqdCoKzxvoJPZnFenmxGWOahmmja3HZVIOOSdwzkGuN mMAMlZ0CaA0HcMJk32/DGQmb3A8tewg7OEkq4XLXvSKnfoAYu2H9WfR0nF/3wT04/PDZ 8Iw04ZlkYkSAovpxojGgbG4Gis3gdXGFf58zNb5ZYISQmpSORwQNYzvqVAqZktb1bGVw 3m2g6Ofg4iQTEwV0Fk5XI+5ZCQcMtBr3vbIS1C/QQrgd9KGv7ZJ2ibSw/Sm1k5Yu/pUe 8tZtbddN7GSBfVUuMWfDEYAyLklXHRhQYg1k2Ytl7mcfPKsXHU8tsG4S4gavxUKnXetJ 05VQ== X-Gm-Message-State: AC+VfDzFbIukChTr677Htg+wANWtw23ssXS0ywDA4L8QAxmt3F7GXQxr muBpU7BDQhazafAf2ahP/EY= X-Received: by 2002:a17:907:3684:b0:969:e95e:e4f3 with SMTP id bi4-20020a170907368400b00969e95ee4f3mr14767392ejc.55.1687432999409; Thu, 22 Jun 2023 04:23:19 -0700 (PDT) Received: from localhost ([45.139.122.241]) by smtp.gmail.com with ESMTPSA id kk10-20020a170907766a00b00988a6421831sm4502765ejc.93.2023.06.22.04.23.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jun 2023 04:23:18 -0700 (PDT) Date: Thu, 22 Jun 2023 14:23:17 +0300 From: Maxim Mikityanskiy To: Arnd Bergmann Cc: Saeed Mahameed , Leon Romanovsky , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Arnd Bergmann , Nathan Chancellor , Nick Desaulniers , Tom Rix , Tariq Toukan , Adham Faris , netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: Re: [PATCH] mlx5: avoid integer overflow warning for large page size Message-ID: References: <20230622101525.3321642-1-arnd@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230622101525.3321642-1-arnd@kernel.org> X-Spam-Status: No, score=2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_BL_SPAMCOP_NET,RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 22 Jun 2023 at 12:15:02 +0200, Arnd Bergmann wrote: > From: Arnd Bergmann > > Build testing with 'make LLVM=1 W=1' shows a warning about a > condition that is always true on configurations with 64KB > pages: > > drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c:32:22: error: result of comparison of constant 65536 with expression of type 'u16' (aka 'unsigned short') is always false [-Werror,-Wtautological-constant-out-of-range-compare] > > Change the condition in a way that lets clang know this > is intentional. > > Signed-off-by: Arnd Bergmann > --- > drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c > index 36826b5824847..b9f62e531bd4c 100644 > --- a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c > @@ -29,7 +29,8 @@ bool mlx5e_validate_xsk_param(struct mlx5e_params *params, > struct mlx5_core_dev *mdev) > { > /* AF_XDP doesn't support frames larger than PAGE_SIZE. */ > - if (xsk->chunk_size > PAGE_SIZE || xsk->chunk_size < MLX5E_MIN_XSK_CHUNK_SIZE) { > + if ((PAGE_SIZE < U16_MAX && xsk->chunk_size > PAGE_SIZE) > + || xsk->chunk_size < MLX5E_MIN_XSK_CHUNK_SIZE) { I recall you already sent a fix to silence this warning before: https://lore.kernel.org/netdev/20211015152056.2434853-1-arnd@kernel.org/ I prefer that old one, as it's more future-proof to cast to size_t here in place (chunk_size won't be bigger than size_t for sure). With your new patch, if chunk_size is ever changed from u16 to u32, it's likely that this place will be unnoticed, and a bug will be introduced. > mlx5_core_err(mdev, "XSK chunk size %u out of bounds [%u, %lu]\n", xsk->chunk_size, > MLX5E_MIN_XSK_CHUNK_SIZE, PAGE_SIZE); > return false; > -- > 2.39.2 >