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 17AE4C433FE for ; Wed, 13 Apr 2022 13:41:51 +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=1aEsFw+i8rCe7LzF3a5eR98GBTd9fg7RQA0N4DuXp2c=; b=r07xKa8X1bb5xx /p6bqhDZsqLAwu11K7Ng5OwzFjNb79yJw8F0N7k7G7O3zrlRe0Jn6kBiyAxjGlWR7iiiJOJGURNB+ TgMU0te68ObkdGnh+XrOhUqsXODAM2mvrVpVObp8uTwTiPPObM0ladj0F0PqN+O+EuaX+5Kvxl461 CVSnQNHEKPsT9m03R+/WiMGqTZViw4qQCS7Y11ltmMrEKBkCIpLnYozp3Dyqx4Hcl3LpL2/66S/2p CgkVl1hcVOUU5v46YL7AtJz0DCL6XGDn/BKpZbTOoRRetiofTDl3jS+AwVn2+dDK/6xvrop0ucNK4 YxnEjgDqJfyyzhdYjeUg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nedEp-001Dq5-U4; Wed, 13 Apr 2022 13:40:52 +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 1nedEd-001DjP-Ir for linux-arm-kernel@lists.infradead.org; Wed, 13 Apr 2022 13:40:41 +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 EAB2C1596; Wed, 13 Apr 2022 06:40:37 -0700 (PDT) Received: from [10.57.41.19] (unknown [10.57.41.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 15A933F73B; Wed, 13 Apr 2022 06:40:35 -0700 (PDT) Message-ID: <37c02fc4-d793-b003-f612-206c987a8a42@arm.com> Date: Wed, 13 Apr 2022 14:40:31 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH] iommu/arm-smmu-v3: Align size in __arm_smmu_tlb_inv_range Content-Language: en-GB To: Nicolin Chen , will@kernel.org, joro@8bytes.org Cc: thunder.leizhen@huawei.com, jgg@ziepe.ca, tglx@linutronix.de, john.garry@huawei.com, jean-philippe@linaro.org, christophe.jaillet@wanadoo.fr, linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org References: <20220413041745.35174-1-nicolinc@nvidia.com> From: Robin Murphy In-Reply-To: <20220413041745.35174-1-nicolinc@nvidia.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220413_064039_733730_A3616987 X-CRM114-Status: GOOD ( 13.81 ) 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-04-13 05:17, Nicolin Chen wrote: > To calculate num_pages, the size should be aligned with > "page size", determined by the tg value. Otherwise, its > following "while (iova < end)" might become an infinite > loop if unaligned size is slightly greater than 1 << tg. Hmm, how does a non-page-aligned invalidation request get generated in the first place? Robin. > Signed-off-by: Nicolin Chen > --- > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > index 627a3ed5ee8f..8249dad5ae44 100644 > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > @@ -1879,7 +1879,7 @@ static void __arm_smmu_tlb_inv_range(struct arm_smmu_cmdq_ent *cmd, > /* Determine what level the granule is at */ > cmd->tlbi.ttl = 4 - ((ilog2(granule) - 3) / (tg - 3)); > > - num_pages = size >> tg; > + num_pages = ALIGN(size, 1 << tg) >> tg; > } > > cmds.num = 0; _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel