Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5046268imu; Sun, 20 Jan 2019 02:17:55 -0800 (PST) X-Google-Smtp-Source: ALg8bN7ijmJrNU6g6gEL+cO/35V0UlhXXsOZtSxiddOnM6PXw9r4yqGBpSkc9sX4P0ZjUNRm26CW X-Received: by 2002:a17:902:a6:: with SMTP id a35mr25792055pla.201.1547979475162; Sun, 20 Jan 2019 02:17:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547979475; cv=none; d=google.com; s=arc-20160816; b=GpUSmweb/YmJQVeIBnhAmIpSQLZyaYfwYcvCZWWXSeZuBdB1NndmNEpZc2L/Z8jhuM KR5flAJ13d8QLKW3XwBWmvTQcl74qeWMrbwjda1yPotHdJoj5gpujHN8Ne80+wHdMUi1 5tWDaq61t+GppCGlnj6kRZP+rttqnqOJwrDKA0D48ZU+NNKD3th1ILrhhBN/p6Wm/Kf0 CTJmvge0OXCtGoZEfdKF5IEUZ7zTfs6n79/PkqEV9qBr3JMjXw3Au1SBR9wUqjLEFZTh qHzksgujQs+pTkW0S8NPQf7WNFWckvdry9BXZMzriDOQK/3Th0SgQK4z0XsumfpDecUP Sxvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=nou3fs3Y96BAWpXHhlaYB51/JeEc54cVl/ZbMqKLQ/M=; b=0qt8B1OVWj3yMqtHauaM27BeNOTgICx7vfRAqw0y61VNEIvn8dislrLk72YXDJ/Ot/ 0194K4HU5HbThLaYPGcz1X4xYGdDNTh0yor4uxHWDPrXutL//UQNFBawIkh/qKRq4H+b 7qsoXrWvF5u7JWa5A1SAFZ7RS/Zn2peBmbnvtV0WEEZkqJjuWwSO3iys63n1sr2kPPRb +Qrcdt/AGrYNXfDSA2AmyPstr7b9blvaso0/mXMJBLxY6yBUYwiMh+TGGmxYC4HD/6ZE JIUOOZlIe1n/9ejZjMlAgzlZNjvbw948MTqU+7XPKIYahaz5Qr/DdDnR3TffBlcDHTm9 GNDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=QuvOaThZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f1si9682416pgn.502.2019.01.20.02.17.22; Sun, 20 Jan 2019 02:17:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=QuvOaThZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730456AbfATKA3 (ORCPT + 99 others); Sun, 20 Jan 2019 05:00:29 -0500 Received: from mail-lj1-f179.google.com ([209.85.208.179]:33892 "EHLO mail-lj1-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726939AbfATKA3 (ORCPT ); Sun, 20 Jan 2019 05:00:29 -0500 Received: by mail-lj1-f179.google.com with SMTP id u89-v6so15101141lje.1 for ; Sun, 20 Jan 2019 02:00:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nou3fs3Y96BAWpXHhlaYB51/JeEc54cVl/ZbMqKLQ/M=; b=QuvOaThZ03dWh7zs55B7nkf8ccCroTR+jkwqF9RrjPM3rd4nXKEbO7fCNCzXCMGqcK mQLg2/BwZXqBlTD5fDzyi0qn5VG1L7kcWExe2wS33zfUARbYDhcS9BWDcVI/02EngK7t U6U830U64fxri3kyKtSosO7d3hPbA93/ptIHk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nou3fs3Y96BAWpXHhlaYB51/JeEc54cVl/ZbMqKLQ/M=; b=G/fN+zxV428GepRUAC3fOqU8DEB/9RkD7W9dpXIR9fYj8A9uSlfk9vH7xa1J0LIbAA rWCsRFaOw+iqT0GE42tPsjxV8uxDZPxKamangXcX+YI2neAutV5tUoQwXVLw9NjzHMtS QN70li/n8GjUAMFhf1XDIsMJbobY07HQJZq8GOnVgUNZj+AW23fx3LUhpzj+/U9Yrfef j5UCKhaJkLFA58bSQwcbPJAaPFpChrsbLks0nWgMA4DxnZLtjrML3PW67XOM5tJfyoTQ E/lpdphecn5GIrGFtVEI1yCcpxGR1hP2SURPd8fGdzqy/upA1m1LceSfj8/DVRY0V616 Mr/Q== X-Gm-Message-State: AJcUukdQ9HGzqN7uO0/RJecPm/SacuURSHDAeQAvm4Cy3hWKBHLj+/JB LDLoq868GiMjGd2IsSxIsEsDrU5nQLO6Sg== X-Received: by 2002:a2e:95c6:: with SMTP id y6-v6mr15296729ljh.59.1547978426673; Sun, 20 Jan 2019 02:00:26 -0800 (PST) Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com. [209.85.208.176]) by smtp.gmail.com with ESMTPSA id h82sm1682586lfg.94.2019.01.20.02.00.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 20 Jan 2019 02:00:25 -0800 (PST) Received: by mail-lj1-f176.google.com with SMTP id n18-v6so15078064lji.7 for ; Sun, 20 Jan 2019 02:00:24 -0800 (PST) X-Received: by 2002:a2e:9983:: with SMTP id w3-v6mr16732573lji.133.1547978424135; Sun, 20 Jan 2019 02:00:24 -0800 (PST) MIME-Version: 1.0 References: <20190119151450.26879-1-Florian.LaRoche@googlemail.com> <20190120000138.GI26876@brain-police> In-Reply-To: From: Linus Torvalds Date: Sun, 20 Jan 2019 22:00:07 +1200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: fix int_sqrt() for very large numbers To: Crt Mori Cc: Will Deacon , Florian La Roche , Linux List Kernel Mailing , Joe Perches , Davidlohr Bueso , Peter Zijlstra Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jan 20, 2019 at 9:30 PM Crt Mori wrote: > > I have just re-read the patch submit discussion and a sqrt of 64bit > number can never be more than 32bit. That is why u32 return value is > enough. Right. And that's exactly why I thought it was so odd how the mlx90632.c driver - which is the only user of int_sqrt64() - does a nested one. It would be sufficient to do int_sqrt(int_sqrt64(..)) because the domain on the outer one isn't actually 64 bits, it's only 32 bits. But it's just a slight confusion and doesn't really matter much. The bug in int_sqrt64() is real, but as mentioned, the calculations done to generate the argument for that one user do seem to all be *signed*. If it overflows into the high bit of an u64 (which is where the off-by-one bug would matter), then the types in that one user are already wrong. So it would probably be a good idea to clarify the single user too while at it. Linus