Received: by 2002:a05:622a:1442:b0:3a5:28ea:c4b9 with SMTP id v2csp549567qtx; Thu, 3 Nov 2022 06:42:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6tjyTrThM/ZJMbMbbXTAdgZ/FJFR4b0u4KPocSBCd6XeppKz2mSSDYBg6HaVqAT3MO3HLW X-Received: by 2002:a05:6402:42d0:b0:457:d16e:283d with SMTP id i16-20020a05640242d000b00457d16e283dmr29886519edc.395.1667482966842; Thu, 03 Nov 2022 06:42:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667482966; cv=none; d=google.com; s=arc-20160816; b=VewQebmKmRW0MXNJYlBNlgv1GwQrnV0SaHSVWCal8gDq+4vwZYHUtNLY8XLd0vmTAT /X3vkFJAYtZFgIQk4caAOylqgi/oz0z55BXo2esbbJCnK00UgnlKkPMxSU872kOsJ45p pYZfT1/pwRWd+TmpQpvVn9pOB3KqcJnl3tb7a4h7CGN4DIBdN5dIPBT4NrW1R4J+eMJg pEGgWEeDfzXDwuOzfLFzE5+v7f/FSWV8zrDRF+ytMqR+NBk1sTk5RmF6t3xbdO5SfOAo 2BOwpuPyyIukKUyTtpVj8Kp52L3zeuYVpYGnzak5Rson1WaqD1ngnhdTlrgntwsuywpN aKCA== 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=IxRwrgpGcbayuw2J5RAtTHB/3ysPD12k+PHRaeFxlKQ=; b=S+kwZldOYvr/HMNdUvsFKFdYjLPaPYJsxgb8x9J2+/wa6J2hKmCvpQbSuTmKlr5NJz dGChcMxD231Bs0YQFjVk7vB7ccgJqah2VhtTKTaR0DZBEY6z1SZYi3qN+iAuD86epL5V XedYV2x10DBH+T+Lf/KU78yLiCZrZbFH3JYh+kreHDMGeL+7pZLhS5bWI/oPTJrBP4o9 ikj1MJqtKL76F61C/V+WPQyg3Ut7vmS6NskL05YnYI+x5uK+lyq4NNp3jTdTRzS9yNTL 0iP5MQe8VZP2t1sxFxySlPmF/nVjfxu0eHagO5X+cbElNV+QK7o525P4xchOniOtCrlf CjMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=GwwrRjkk; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i5-20020a1709064fc500b0078e11e9286csi1668489ejw.195.2022.11.03.06.42.22; Thu, 03 Nov 2022 06:42:46 -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=@ventanamicro.com header.s=google header.b=GwwrRjkk; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229764AbiKCM7w (ORCPT + 97 others); Thu, 3 Nov 2022 08:59:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230089AbiKCM7t (ORCPT ); Thu, 3 Nov 2022 08:59:49 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5667912760 for ; Thu, 3 Nov 2022 05:59:48 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id ay14-20020a05600c1e0e00b003cf6ab34b61so3308643wmb.2 for ; Thu, 03 Nov 2022 05:59:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; 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=IxRwrgpGcbayuw2J5RAtTHB/3ysPD12k+PHRaeFxlKQ=; b=GwwrRjkkygx3kA4xo0QuwS+Ne2RINsFO3eCQp6cQ9Ourq60bUc4Bt5AgAPDbQAon6l gYwG/q+U+4m65imNxHxEtv/wguv7zVx1FdM6bBSupRiKHQqcJvzgQCj/pXBAzObzeey2 eIWJHLQuwXCd9OYAJulehF09iAhGGabS+GZ77jdsbOlVSgmaGBS8wMdeEM0HU+61DYEc XSM998DKTGw19ogYfqk8LePf/GDY1Q9OaYCfMoPhWyy6X91NirqfboJUiqUVN8Bntsr0 J4JjRNE0fAbRqdAi3Z8tdryQsJpUsCFo5O3S6BnzL7FXthHoIBTqW543UoTxkVoKFyC9 j5SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=IxRwrgpGcbayuw2J5RAtTHB/3ysPD12k+PHRaeFxlKQ=; b=EfZn28Id2S+RfDI1pELyWFXpxFfbZQKr50Y1HNZl0zkEZBnmqPZUvnOwBVezEHi4Id KdbwNHgsBD9/it1xdHEqOK6rkN5qZOY4r3t1+GNWp4+qfScer08AfYixNSvGvoXAhb0F rw9VFQoMRkTs4SofQs/sg8LQv1FzR6DMe/ddPuGVgnAZ1DQhRCFv8Xy8hwY9e+8nk5Ou 5K+aWzcrpKSy2zmYuhbm/JTeyniUtqwBJ4bcdLdspg+B6AsWEpum2X9qFF27ZOiw+oT7 2LB+6u1e8Q2SSTbnKNJZFQqolAfhnoPDl8pLAIfJIwa4KAwQRFyeTOLeBi08RfFOmI5P yBtQ== X-Gm-Message-State: ACrzQf0TZmdsRPq1C61WepzcmukFof+cr4EsdOdbOdlbFK9VCx7Grbm7 rjFLwOFBy3/1g4icUmHtu6UWCw== X-Received: by 2002:a05:600c:3b1d:b0:3c6:ff0d:6a60 with SMTP id m29-20020a05600c3b1d00b003c6ff0d6a60mr19364166wms.183.1667480386818; Thu, 03 Nov 2022 05:59:46 -0700 (PDT) Received: from localhost (2001-1ae9-1c2-4c00-748-2a9a-a2a6-1362.ip6.tmcz.cz. [2001:1ae9:1c2:4c00:748:2a9a:a2a6:1362]) by smtp.gmail.com with ESMTPSA id bg36-20020a05600c3ca400b003cf774c31a0sm5977531wmb.16.2022.11.03.05.59.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 05:59:46 -0700 (PDT) Date: Thu, 3 Nov 2022 13:59:45 +0100 From: Andrew Jones To: Borislav Petkov Cc: Yury Norov , x86@kernel.org, linux-riscv , Linux Kernel Mailing List , Thomas Gleixner , Ingo Molnar , Dave Hansen , Palmer Dabbelt , Paul Walmsley , Albert Ou , Jonas Bonn , Stefan Kristiansson , Stafford Horne , openrisc@lists.librecores.org, Michael Ellerman , "open list:LINUX FOR POWERPC PA SEMI PWRFICIENT" , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , linux-s390@vger.kernel.org Subject: Re: [PATCH v3 2/2] x86: Fix /proc/cpuinfo cpumask warning Message-ID: <20221103125945.lrr5oxxmylwpam53@kamzik> References: <20221014155845.1986223-3-ajones@ventanamicro.com> <20221028074828.b66uuqqfbrnjdtab@kamzik> <20221031080604.6xei6c4e3ckhsvmy@kamzik> <20221031100327.r7tswmpszvs5ot5n@kamzik> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 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 Wed, Nov 02, 2022 at 07:44:02PM +0100, Borislav Petkov wrote: > On Mon, Oct 31, 2022 at 11:03:27AM +0100, Andrew Jones wrote: > > Currently (after the revert of 78e5a3399421) > > After the revert? > > That commit is still in the latest Linus tree. The revert commit is 80493877d7d0 ("Revert "cpumask: fix checking valid cpu range".") > > > with DEBUG_PER_CPU_MAPS we'll get a warning splat when the cpu is > > outside the range [-1, nr_cpu_ids) > > Yah, that range makes sense. > > > and cpumask_next() will call find_next_bit() with the input plus one anyway. > > find_next_bit() doesn't explicity document what happens when an input is > > outside the range, but it currently returns the bitmap size without any > > side effects, which means cpumask_next() will return nr_cpu_ids. > > That is good to have in the commit message. > > > show_cpuinfo() doesn't try to show anything in that case and stops its > > loop, or, IOW, things work fine now with an input of nr_cpu_ids - 1. But, > > show_cpuinfo() is just getting away with a violated cpumask_next() > > contract, which 78e5a3399421 exposed. How about a new commit message like > > this > > You're making it sound more complex than it is. All you wanna say is: > > "Filter out invalid cpumask_next() inputs by checking its first argument > against nr_cpu_ids because cpumask_next() will call find_next_bit() with > the input plus one but the valid range for n is [-1, nr_cpu_ids)." The patch I'm proposing ensures cpumask_next()'s range, which is actually [-1, nr_cpus_ids - 1), isn't violated. Violating that range will generate the warning for kernels which have commit 78e5a3399421 ("cpumask: fix checking valid cpu range"), but not its revert. Since 78e5a3399421 has been reverted, the value of this proposed fix is less, and indeed the warning may even go away completely for these types of cpumask calls[1]. However, it seems reasonable for callers to implement their own checks until the cpumask API has documented what they should expect. [1] https://lore.kernel.org/all/CAHk-=wihz-GXx66MmEyaADgS1fQE_LDcB9wrHAmkvXkd8nx9tA@mail.gmail.com/ > > But that thing with the revert above needs to be clarified first. I'll send a v4 with another stab at the commit message. Thanks, drew > > Thx. > > -- > Regards/Gruss, > Boris. > > https://people.kernel.org/tglx/notes-about-netiquette