Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp310359rwi; Wed, 2 Nov 2022 12:11:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM47BfkhjbhUyuxF74ws8+RYontPOexzuXMx1DEfJD+flSop8T6KowGFomvupYz7Jmy1koBq X-Received: by 2002:a05:6a00:16c8:b0:53b:3b9f:7283 with SMTP id l8-20020a056a0016c800b0053b3b9f7283mr26412214pfc.46.1667416271878; Wed, 02 Nov 2022 12:11:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667416271; cv=none; d=google.com; s=arc-20160816; b=jp7OGwagn2NAg5ei41tbDXdyQrw1IPHzlPvpxJehIENe3bZa2073OYze8/qQnNB315 VT1e1Zgbn9Kc9HoQbe4b5cm5vvZ90YJN/ilP/FF4xyug29ravrv3amRcNePuqShzKu2b 7m1fSiuC92hBC76N7P6NTd0a5lIkt3PsE3Ps44HTagmF/Yf148M9rPqHjfM5s0mVPH7F nEEKDR4fRxEvIxrjWWg8s4932OP0Y8YfJMoPiPlRIy22L4NyP2xjGRFLX4o3xVo5NiuN UN2ow4+U7wC0euBNgEUuo7iWWBUEmb3CFMfJk3TKWzgfaQBMY5Po5CLF+SZOtB5f1/LN Llzw== 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=iOr/2V0DoRyu5jKtmDX0XiBrZE84Kn1Pob6d6OL2TAQ=; b=hi++EMIzZ4jZjloCtG0hfJDnMrbu4+/T0EGedmsVLbHXgATKUb0pbTJpaT1I+3cjCG INEstQcRo5eBwW+YyJ4UIhU+ydro8YmNIh4dQRwtOA+wkN+GN9RShagctlXMktZqWdXJ SWJ3ucKS8zdkrL73FDmPNOCimp1CvuADvFVBLyKRzln6F9a/ExITevbX9qnTTc9euGiE ndkVHjSFxqpPFLmoYlFZnZuQ0IGGu03IsdxTECa9MuG/E6OarCGsDKKLsJBUmCmMkAaF NJzeP+amOme0D70v0fmPtYUZi441jZx3YHNNqM/1glzkmPraS5Tcko83e6zl/U6rUex+ hJ+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=P8xIFXf0; 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=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b13-20020a170903228d00b001870c4c2722si16154731plh.299.2022.11.02.12.10.58; Wed, 02 Nov 2022 12:11:11 -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=@alien8.de header.s=dkim header.b=P8xIFXf0; 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=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231305AbiKBSoL (ORCPT + 98 others); Wed, 2 Nov 2022 14:44:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231262AbiKBSoI (ORCPT ); Wed, 2 Nov 2022 14:44:08 -0400 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E281E2CDC5; Wed, 2 Nov 2022 11:44:07 -0700 (PDT) Received: from zn.tnic (p200300ea9733e741329c23fffea6a903.dip0.t-ipconnect.de [IPv6:2003:ea:9733:e741:329c:23ff:fea6:a903]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 72DBB1EC0430; Wed, 2 Nov 2022 19:44:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1667414646; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=iOr/2V0DoRyu5jKtmDX0XiBrZE84Kn1Pob6d6OL2TAQ=; b=P8xIFXf059+smEe6r5YZYLEbBvKhvHMQlCDMpFuQpPIyUL+0Na11Qye0LmeFzVkyGcJ0Ue fIrCmtMkvbI9pekV7eZIq4LZ2B96yVhn3hhIe318CHOxpV0wNqptu2eHkXK4/tBD234sAI ZmyjnjRhdV4j8e7O51OrF3B1uOD5hfo= Date: Wed, 2 Nov 2022 19:44:02 +0100 From: Borislav Petkov To: Andrew Jones 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: References: <20221014155845.1986223-1-ajones@ventanamicro.com> <20221014155845.1986223-3-ajones@ventanamicro.com> <20221028074828.b66uuqqfbrnjdtab@kamzik> <20221031080604.6xei6c4e3ckhsvmy@kamzik> <20221031100327.r7tswmpszvs5ot5n@kamzik> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20221031100327.r7tswmpszvs5ot5n@kamzik> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 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. > 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)." But that thing with the revert above needs to be clarified first. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette