From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97BDBC4332F for ; Wed, 2 Nov 2022 18:44:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231347AbiKBSoM (ORCPT ); Wed, 2 Nov 2022 14:44:12 -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> 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 97408C4332F for ; Wed, 2 Nov 2022 18:44:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0mSLIRJw9va6Anjr/LAY/0ZT5zzOmzAdFS8CToTfsQo=; b=aQOYjVlLMVLFzl KwOcnvcEi2rMmq5P5G5Lsy8VQret/7CEVeG6nhjVnYgKAwk9ktasJdQqb1RteHreJmOuhkr+oAoWA ERYgfpyTr4HfX/VviVsVSPrcKtmvGjyi62dMOwp35pH07z8qrTUXam9iJW/lHwiB9e9UYrwEiA0iC e24c3tPVrknh+98qRHmCESN6/VsWWY7sXv9ml60n8ssEj7xvDecdGa1XPwOE66VHg9YtUgFxiveQl G5nlBMDjEYdoIqmJ2dGty3QrWvDuAw8+A+i8WA5numr8gsv0vaLSsrEONp3jjr71jxt3Bc8AJDw2T TfMc1NC5pM3oU0cUtcMg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqIii-00DDVP-6c; Wed, 02 Nov 2022 18:44:12 +0000 Received: from mail.skyhub.de ([5.9.137.197]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqIie-00DDSy-6s for linux-riscv@lists.infradead.org; Wed, 02 Nov 2022 18:44:10 +0000 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-Disposition: inline In-Reply-To: <20221031100327.r7tswmpszvs5ot5n@kamzik> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221102_114408_448502_4C35D814 X-CRM114-Status: GOOD ( 16.14 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B59AEC4332F for ; Wed, 2 Nov 2022 18:45:27 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4N2bRp1cr4z3cTk for ; Thu, 3 Nov 2022 05:45:26 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=alien8.de header.i=@alien8.de header.a=rsa-sha256 header.s=dkim header.b=P8xIFXf0; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=alien8.de (client-ip=2a01:4f8:190:11c2::b:1457; helo=mail.skyhub.de; envelope-from=bp@alien8.de; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=alien8.de header.i=@alien8.de header.a=rsa-sha256 header.s=dkim header.b=P8xIFXf0; dkim-atps=neutral Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4N2bQf65GSz2xH6 for ; Thu, 3 Nov 2022 05:44:26 +1100 (AEDT) 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 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-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jonas Bonn , linux-s390@vger.kernel.org, Alexander Gordeev , Dave Hansen , Vasily Gorbik , Yury Norov , Heiko Carstens , x86@kernel.org, Linux Kernel Mailing List , Stefan Kristiansson , openrisc@lists.librecores.org, Ingo Molnar , Palmer Dabbelt , Paul Walmsley , Stafford Horne , linux-riscv , "open list:LINUX FOR POWERPC PA SEMI PWRFICIENT" , Thomas Gleixner , Albert Ou Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.librecores.org (lists.librecores.org [88.198.125.70]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED153C43219 for ; Sun, 6 Nov 2022 21:06:00 +0000 (UTC) Received: from [172.31.1.100] (localhost.localdomain [127.0.0.1]) by mail.librecores.org (Postfix) with ESMTP id 08C4324929; Sun, 6 Nov 2022 22:05:58 +0100 (CET) Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by mail.librecores.org (Postfix) with ESMTPS id 028B924C42 for ; Wed, 2 Nov 2022 19:44:06 +0100 (CET) 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 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-Mailman-Approved-At: Sun, 06 Nov 2022 22:05:55 +0100 X-BeenThere: openrisc@lists.librecores.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Discussion around the OpenRISC processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jonas Bonn , linux-s390@vger.kernel.org, Alexander Gordeev , Dave Hansen , Vasily Gorbik , Yury Norov , Michael Ellerman , Heiko Carstens , x86@kernel.org, Linux Kernel Mailing List , openrisc@lists.librecores.org, Ingo Molnar , Palmer Dabbelt , Paul Walmsley , linux-riscv , "open list:LINUX FOR POWERPC PA SEMI PWRFICIENT" , Thomas Gleixner , Albert Ou Errors-To: openrisc-bounces@lists.librecores.org Sender: "OpenRISC" 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