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 E1739C32774 for ; Tue, 23 Aug 2022 10:43:50 +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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=UK991amC/hjE0JLOQJFKGJksX5+BWEkGBayLjR7T4AA=; b=xKVECyoxfiWpNp JrwAsqk+z7TD93XimT36e5hbKoZ0nuCnYrHM10KlphJ2YOgI9aaREc2ycVwEvsVFuoi3niQzNNm9z yjnwnEUTjTKdsDHeAqr7kU5vK4RXpVj7+4USYo3wV+1K90C5DAWSBtoidkMSbrRuCE7beaM4POjFA b4L4U7IvXV6dqMu9HG5Jo4bOI48CCiu/+jFAniwFCUSSOZ0mZJlz6TzREqkJCE8Wsy1OuzIcrxvfi iPdghoP8WfRhwa5U0oA7lRp50Eb82HcpJvpKKtlwJCbtllSMWteZJgKFcjsYcIuKVVnAddTeOU/q+ w1oiOHolWFXPUSrFZJ6g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oQRMw-0052cD-0b; Tue, 23 Aug 2022 10:42:50 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oQRMs-0052Ye-Oo for linux-arm-kernel@lists.infradead.org; Tue, 23 Aug 2022 10:42:48 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 60F04113E; Tue, 23 Aug 2022 03:42:44 -0700 (PDT) Received: from [10.57.15.51] (unknown [10.57.15.51]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 58A543F70D; Tue, 23 Aug 2022 03:42:39 -0700 (PDT) Message-ID: Date: Tue, 23 Aug 2022 11:42:33 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101 Thunderbird/102.1.2 Subject: Re: [PATCH] drm/panfrost: Update io-pgtable API Content-Language: en-GB To: Alyssa Rosenzweig Cc: robh@kernel.org, tomeu.vizoso@collabora.com, steven.price@arm.com, alyssa.rosenzweig@collabora.com, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org References: From: Robin Murphy In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220823_034246_912095_19FBB126 X-CRM114-Status: UNSURE ( 6.03 ) X-CRM114-Notice: Please train this message. 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2022-08-23 03:51, Alyssa Rosenzweig wrote: >> -static size_t get_pgsize(u64 addr, size_t size) >> +static size_t get_pgsize(u64 addr, size_t size, size_t *count) >> { >> - if (addr & (SZ_2M - 1) || size < SZ_2M) >> - return SZ_4K; >> + size_t blk_offset = -addr % SZ_2M; > > addr is unsigned. if this is correct, it's magic. Eh, it's just well-defined unsigned integer overflow. Take "SZ_2M - (addr % SZ_2M)", realise the first term can be anything that's zero modulo SZ_2M, including zero, then also that the operations can be done in either order to give the same result, and there you go. Cheers, Robin. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel