Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5405745rwb; Mon, 14 Nov 2022 04:20:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf74MH5chzi/JuN2iyzBltP9QHcJsakepcgrIqZ02IpmkGxp6GHVThLe/seLE9YUWpWLQH9U X-Received: by 2002:a17:906:e241:b0:7ae:e592:6d83 with SMTP id gq1-20020a170906e24100b007aee5926d83mr5667940ejb.699.1668428441304; Mon, 14 Nov 2022 04:20:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668428441; cv=none; d=google.com; s=arc-20160816; b=d2luWA7e53TjyutDyu2IPo8nL1+TdV+AHytjEMnCL1PqHgV1bO+22VStcJfed8/BLx NbX/H65W3+qaEBHQlays6mH68pHf3/fSTyfmeGookC9sOSMkubD86n4VNvp9MO1bQZlA tLzeYxY0yLyEpNRB5QbNX1edamcabiApAODSyGXLy/GmldEZMj8/AWJIwA/K1G37rm72 qgoky4J5DdaLoh/2fBU22gCZccFskVBpeBzWKgjtqS/XnG5+qqcJ2RESXIcszj5wSFv9 ZQY9G4RKdoYKhKuTITzooCkz7AzElQ5RG2vAj8SrSumsN2h1m8MSAeoCO70VAsO47lRj alAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=F/Wr+SVV/WVwZt2osIxsvNDdmkKmeVCwtMMYAaUXH+I=; b=vNTSzH8iorI7+geyHa3S7BZDtuSQeV8wJd4MrJlpng51wc2t+H4wn5TUrr8Hg6fgpw Ja5f/EbHjUIis8e8T7+RyW0u3VwrlhfdzTLqHMjCttiSUEh8eFOV9j38vtB40TDFcta6 QpjGyGdiulcoebipgZOtXblCTIPqkmpLE7dAOCyB/aLzkAf053nXJITy6YL86gQvCQX+ 6n5KFMUzARCbjXQrf5y+jtiNLNq3at54NHIXnRHXuIr2fFWksaYWeS7QN3jlzpf6MFJj CuoDdeN5UcJRfVR1bB4owYpV/BjeXSaXpXOR0hXQUQgRjW5RFXYJPsvrSadmYN5t/h1G Rn7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=IobAelHr; 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=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sa7-20020a1709076d0700b00780636887fesi8815228ejc.797.2022.11.14.04.20.19; Mon, 14 Nov 2022 04:20:41 -0800 (PST) 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=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=IobAelHr; 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=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236890AbiKNMCW (ORCPT + 88 others); Mon, 14 Nov 2022 07:02:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237084AbiKNMBv (ORCPT ); Mon, 14 Nov 2022 07:01:51 -0500 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 992E923143 for ; Mon, 14 Nov 2022 03:59:37 -0800 (PST) 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Russell King (Oracle) 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_NONE 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 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!