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 A2779C433FE for ; Mon, 14 Nov 2022 12:02:54 +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=7HIP3uhysAgQIVfC2ZzfU4ofnKIcnlNwBPDWQNQUY0Y=; b=Wi+lHeQ9zbxoK2 m5gtqNhIxqtrS3NkMeKjbAan1kYPes+y+vWYWy/pd5ybjPcwlYsVuxaPHpX0UCdJymIZBvSGzFMzk NK1TfEc7FpEHlUrHAZa+9jzp8t6k3XTXQGMO/UYbmw3IYb2khvwfRd9PEr0JTTTAsAZ/F3z3sVDdf +szB2YavcKgcxjKFXNk2OS6zpfPW84lW60lww1+EbEDmHqzZGM7s4D51zP1DhBzU02bNm+ZL6CFTb IlzUvCFG/b7UpALcz2VogHEA7JdbuOqppQiHtksr69l7iXe13L+xfco5zSFwZqBD3Dg24aXHiYUDR uMMrQxPm/SOPIph8CsnA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ouY9p-000e8X-IZ; Mon, 14 Nov 2022 12:01:45 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ouY9m-000d62-8Q for linux-arm-kernel@lists.infradead.org; Mon, 14 Nov 2022 12:01:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=F/Wr+SVV/WVwZt2osIxsvNDdmkKmeVCwtMMYAaUXH+I=; b=IobAelHrlC9OmYTjrWvY8TZyco FHukHDGF3YCUiw/2E2zcXGj//gKXRt0D5OBPh7zifr0oC2XYlUOYZ1oVss/oBV/E8IBvwGhDEdWvU zUxdXK81AhbB+jGu0zYHZqWmTxeLVseHHtnDDdm2Q2Z+uKrLi+Xz64u5l+johTbgxX9rzW5WltnPs Kh1p90LT+r9IvIqp7iGQXJLPB3TkOl3+p0xRNhor2qVb65uPSwAhVZWcyPbIq1SlDoT/IkYdHhvU4 szcDUsOSiruckNDrGS9+wxuP288Gd3uVs6d5KkTu3LhdaMvLqmaH4Xay8R9uJb+rQa5S5zAoTcb55 f4y+PY5A==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:35258) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ouY7e-0000kO-J4; Mon, 14 Nov 2022 11:59:30 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1ouY7b-0003n5-FQ; Mon, 14 Nov 2022 11:59:27 +0000 Date: Mon, 14 Nov 2022 11:59:27 +0000 From: "Russell King (Oracle)" To: Linus Torvalds Cc: Yury Norov , Catalin Marinas , Mark Rutland , Will Deacon , linux-arm-kernel@lists.infradead.org, Linux Kernel Mailing List , Alexey Klimov , Andy Shevchenko , Andy Whitcroft , Dennis Zhou , Geert Uytterhoeven , Guenter Roeck , Kees Cook , Rasmus Villemoes Subject: Re: [PATCH 1/2] bitmap: add sanity check function for find_bit() Message-ID: References: <20221020032024.1804535-1-yury.norov@gmail.com> <20221020032024.1804535-2-yury.norov@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221114_040142_341930_6AB13300 X-CRM114-Status: GOOD ( 23.84 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Oct 25, 2022 at 11:38:31AM -0700, Linus Torvalds wrote: > On Tue, Oct 25, 2022 at 11:26 AM Russell King (Oracle) > wrote: > > > > However, we still support ARMv5 and ARMv4, both of which _trap_ every > > unaligned access, which will make a findbit call with an unaligned > > pointer using word loads painfully expensive. This is the main reason > > we haven't used word loads in the findbit ops. > > The findbit ops really shouldn't be a special case, and bitmaps can > never be unaligned. > > Just look at what 'test_bit()' does: the non-constant non-instrumented > version ends up as generic_test_bit(), which uses a "const volatile > unsigned long *" access to do the bitmap load. > > So there is absolutely no way that bitmaps can ever be unaligned, > because that would trap. > > And test_bit() is a lot more fundamental than one of the "find bits" functions. > > Have we had bugs in this area before? Sure. People have used "unsigned > int" for flags and mised the bitmap ops on it, and it has worked on > x86. > > But then it fails *miserably* on big-endian machines and on machines > that require more alignment (and even on x86 we have KASAN failures > etc these days and obviously without casts it will warn), so we've > hopefully fixed all those cases up long long ago. > > So I really think it's pointless to worry about alignment for > "find_bit()" and friends, when much more fundamental bitop functions > don't worry about it. Yes, which is what my series does by converting to use word operations and not caring anymore whether the pointer is aligned or not. My reply was more a correction of the apparent "we don't have to worry about unaligned accesses because version 6 of the architecture has a feature that means we don't have to worry" which I regard as broken thinking, broken as long as we continue to support previous versions of the architecture. I'm planning to queue up my series of five patches today, so it should be in tonight's linux-next. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel