Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1726412pxb; Thu, 16 Sep 2021 14:06:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxA8mw7x6vkGeqSFBDfEn3oVgFtapc9vq/U9jhw/0PHVdal28o6NfO62CQi2rmOgCcvaP7 X-Received: by 2002:a05:6602:3404:: with SMTP id n4mr5830741ioz.45.1631826366686; Thu, 16 Sep 2021 14:06:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631826366; cv=none; d=google.com; s=arc-20160816; b=WEr9LPmEf7H8qbEVYpACShX6l/DFcBIhGRDAlaAvtFkkwDwbs2zjQ+Gzq8mHhHdxkn 17BVmo2rsNv5C2foWtDUQctVdUUB5fjCciAKI+SgcI2CchPTM38GIY/ainZZc0ZUaHFi ctJhp1fjZ9w/NCXuLqvKOb1x4WBJ6FuRaR773lg/wHnA1imW4GPyaSX8AvFcVxZ7x+dk aQojw20xiJ1VU/p4wWKyGSAlOctL0GJltn3QRRn+4J+aFpgChZYbt6X//sbtcHI3THTz 5+1K0Iszp6FrykhlB9iSm8W4c7VNYeJyFs4CQYzTAp8OUYSdPPrEB7oHf+E8M8GML1WY xL7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jMrjXWmnc9TAZirNoi/biffeRexm78bXf5inXcofgCI=; b=Iykxb5Wv36ltBdJekpATDUglkUEgHljbv5O+EUhOXwNIE/FI+kUQMLUe7lYh6sVCon y9c5Avi7gnlIRaj7lJ8yxWT6BdNh0DxUOQynlLZHYS2qXL/PiA+/NsKJhyfUrnXmFmXl JONZahAiH0wGdDKosdqiyrcsphgw/qdnctS+RX+q2f4NC9nUe6xB991e31Ido/3L9Ri+ 3qBxTT87qpq3H7B+YqcNfZLmLa1ZY//vB01GwE0SVXEIdacFsEV0596TIHT34UpDS6WH f2v2U0dbByRqks9xSAn0gBAtoGxJU3L6hCcR3a8wchm2nn5plFyfN/za/EenMsX/gL2d Yo8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Ux7qvW1/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q14si3356016iot.14.2021.09.16.14.05.42; Thu, 16 Sep 2021 14:06:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Ux7qvW1/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241518AbhIPQd7 (ORCPT + 99 others); Thu, 16 Sep 2021 12:33:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:38206 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241696AbhIPQZo (ORCPT ); Thu, 16 Sep 2021 12:25:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5A76A61504; Thu, 16 Sep 2021 16:16:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631809010; bh=LCat9Mk5HO2lAs3ESj+TNKkPWvP3d1nWE8Pr9v+E410=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ux7qvW1/wpg8GupcMaPMHWo6p5M/4NrrCx/TvBSMPZvShDLFjJlc0UflaUCZkrfGg B+F0kTEnlsAPDav6VW+ZdeA6f8JMcFPIFWEV4oc0YGT9OX8IhdDANRvpEn4W3yLhaM B84pp4lUNo+BbmwMDB4qlcwCvx3IsT9zQ+10nOdI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alyssa Rosenzweig , Rob Herring , Chris Morgan , Steven Price Subject: [PATCH 5.10 304/306] drm/panfrost: Use u64 for size in lock_region Date: Thu, 16 Sep 2021 18:00:49 +0200 Message-Id: <20210916155804.450789353@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155753.903069397@linuxfoundation.org> References: <20210916155753.903069397@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alyssa Rosenzweig commit a77b58825d7221d4a45c47881c35a47ba003aa73 upstream. Mali virtual addresses are 48-bit. Use a u64 instead of size_t to ensure we can express the "lock everything" condition as ~0ULL without overflow. This code was silently broken on any platform where a size_t is less than 48-bits; in particular, it was broken on 32-bit armv7 platforms which remain in use with panfrost. (Mainly RK3288) Signed-off-by: Alyssa Rosenzweig Suggested-by: Rob Herring Tested-by: Chris Morgan Reviewed-by: Steven Price Reviewed-by: Rob Herring Fixes: f3ba91228e8e ("drm/panfrost: Add initial panfrost driver") Cc: Signed-off-by: Steven Price Link: https://patchwork.freedesktop.org/patch/msgid/20210824173028.7528-3-alyssa.rosenzweig@collabora.com Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/panfrost/panfrost_mmu.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) --- a/drivers/gpu/drm/panfrost/panfrost_mmu.c +++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c @@ -55,7 +55,7 @@ static int write_cmd(struct panfrost_dev } static void lock_region(struct panfrost_device *pfdev, u32 as_nr, - u64 iova, size_t size) + u64 iova, u64 size) { u8 region_width; u64 region = iova & PAGE_MASK; @@ -75,7 +75,7 @@ static void lock_region(struct panfrost_ static int mmu_hw_do_operation_locked(struct panfrost_device *pfdev, int as_nr, - u64 iova, size_t size, u32 op) + u64 iova, u64 size, u32 op) { if (as_nr < 0) return 0; @@ -92,7 +92,7 @@ static int mmu_hw_do_operation_locked(st static int mmu_hw_do_operation(struct panfrost_device *pfdev, struct panfrost_mmu *mmu, - u64 iova, size_t size, u32 op) + u64 iova, u64 size, u32 op) { int ret; @@ -109,7 +109,7 @@ static void panfrost_mmu_enable(struct p u64 transtab = cfg->arm_mali_lpae_cfg.transtab; u64 memattr = cfg->arm_mali_lpae_cfg.memattr; - mmu_hw_do_operation_locked(pfdev, as_nr, 0, ~0UL, AS_COMMAND_FLUSH_MEM); + mmu_hw_do_operation_locked(pfdev, as_nr, 0, ~0ULL, AS_COMMAND_FLUSH_MEM); mmu_write(pfdev, AS_TRANSTAB_LO(as_nr), transtab & 0xffffffffUL); mmu_write(pfdev, AS_TRANSTAB_HI(as_nr), transtab >> 32); @@ -125,7 +125,7 @@ static void panfrost_mmu_enable(struct p static void panfrost_mmu_disable(struct panfrost_device *pfdev, u32 as_nr) { - mmu_hw_do_operation_locked(pfdev, as_nr, 0, ~0UL, AS_COMMAND_FLUSH_MEM); + mmu_hw_do_operation_locked(pfdev, as_nr, 0, ~0ULL, AS_COMMAND_FLUSH_MEM); mmu_write(pfdev, AS_TRANSTAB_LO(as_nr), 0); mmu_write(pfdev, AS_TRANSTAB_HI(as_nr), 0); @@ -225,7 +225,7 @@ static size_t get_pgsize(u64 addr, size_ static void panfrost_mmu_flush_range(struct panfrost_device *pfdev, struct panfrost_mmu *mmu, - u64 iova, size_t size) + u64 iova, u64 size) { if (mmu->as < 0) return;