Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2935681pxb; Tue, 24 Aug 2021 10:57:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjD208H7XB+ulgFDU/13iqjPSXRyAA9i+LjwUBEQG9Yk7XMx8hACte3qfys3KPS1lDnb9s X-Received: by 2002:a05:6638:328f:: with SMTP id f15mr2183231jav.111.1629827857413; Tue, 24 Aug 2021 10:57:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629827857; cv=none; d=google.com; s=arc-20160816; b=y37W7ocng6XMW2/Sa0RFWZcU5SnUyRvIjxxJ6hA0HYDZwBw7qhOqZLz+psq/x/1W3F 07hXq/qJyJPWcC9nVcRGI9rEE/oi+IlIoaVL9bjUr67clYRwNLlZyEcp+Q3TB2povf+q 5KhFlkSrLpJ6nNpL+JF7GHrd5YG1S1VuYTGbQTfWPRf1mSTD5Cs+vGJn4Ammmfz8l0Xq 4YDPEDh+9KzbjDmkXPTUJO6aVhdnmfCwfkK2JtdDemQ76RiBB+yGzsAKdkJOEQuu5pgz enssQlqplr8ATRkdzDMioEHdKWP03rJ0Ask+e9hHQSM8O/K9bWPG0CdKfyrrHGRJT46J 8WCg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=0zFauUcmSH0aDw1en5Rqu+GAPK5uC1HDUGSSFmyDLmg=; b=SKEziqpVwoY5Ulq74B0d9MycDbtbLd4pmKTTnDMMneydrVuV+x8uSatb2a+EGo5RVa WJsoEy37JECF5V9s5owGMzTLD4Vx1gsYihUC7ZW5melBXsI4/lBZwl77qFL0irJncD8z xioWSVjaOvlOlT1HvI8G23Gw6Kzd3GUhiw5NIubgKHHX88eH/sY9c9VMCL0rOQUyslhV nZsoGWE64Z2kno+IjxnappYxWqeX/IpW8v+ZflC8B1dOOYBp6Vc84y/RcjRucNncKESN hr97nTuFIlN46qNqWBEkK0w8jTaxeMoPper5fwbS0XaUTHP8GTR8CqI6AYSJ3yDOKX30 Z8qw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c26si16411208jam.74.2021.08.24.10.57.25; Tue, 24 Aug 2021 10:57:37 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240501AbhHXR51 (ORCPT + 99 others); Tue, 24 Aug 2021 13:57:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240456AbhHXR5X (ORCPT ); Tue, 24 Aug 2021 13:57:23 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E806C0C1751; Tue, 24 Aug 2021 10:31:04 -0700 (PDT) Received: from localhost.localdomain (unknown [IPv6:2600:8800:8c06:1000::c8f3]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: alyssa) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 9C5EA1F42820; Tue, 24 Aug 2021 18:30:59 +0100 (BST) From: Alyssa Rosenzweig To: dri-devel@lists.freedesktop.org Cc: Rob Herring , Tomeu Vizoso , Steven Price , Alyssa Rosenzweig , David Airlie , Daniel Vetter , linux-kernel@vger.kernel.org, Chris Morgan , stable@vger.kernel.org Subject: [PATCH v2 2/4] drm/panfrost: Use u64 for size in lock_region Date: Tue, 24 Aug 2021 13:30:26 -0400 Message-Id: <20210824173028.7528-3-alyssa.rosenzweig@collabora.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210824173028.7528-1-alyssa.rosenzweig@collabora.com> References: <20210824173028.7528-1-alyssa.rosenzweig@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Fixes: f3ba91228e8e ("drm/panfrost: Add initial panfrost driver") Cc: --- drivers/gpu/drm/panfrost/panfrost_mmu.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.c b/drivers/gpu/drm/panfrost/panfrost_mmu.c index f6e02d0392f4..3a795273e505 100644 --- a/drivers/gpu/drm/panfrost/panfrost_mmu.c +++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c @@ -58,7 +58,7 @@ static int write_cmd(struct panfrost_device *pfdev, u32 as_nr, u32 cmd) } 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; @@ -78,7 +78,7 @@ static void lock_region(struct panfrost_device *pfdev, u32 as_nr, 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; @@ -95,7 +95,7 @@ static int mmu_hw_do_operation_locked(struct panfrost_device *pfdev, int as_nr, 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; @@ -112,7 +112,7 @@ static void panfrost_mmu_enable(struct panfrost_device *pfdev, struct panfrost_m 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); @@ -128,7 +128,7 @@ static void panfrost_mmu_enable(struct panfrost_device *pfdev, struct panfrost_m 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); @@ -242,7 +242,7 @@ static size_t get_pgsize(u64 addr, size_t 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; -- 2.30.2