Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2350587pxb; Mon, 20 Sep 2021 19:45:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxfAyV2wNBwzoSJjTS79H4hIHZywhUGsbbNrp/AibXx2VcaZuXfn4BpQfvJz7RmzFHpOqM X-Received: by 2002:a50:ab18:: with SMTP id s24mr33215466edc.88.1632192347677; Mon, 20 Sep 2021 19:45:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632192347; cv=none; d=google.com; s=arc-20160816; b=VQmV/B5EKZ3axvLg7J4QeSbUmTnCy/Egeg/AXnJU+7s7RqlIlzDL/MkpYMXeNyD1ow 9uRL087PK9wtji9ZRikWrh/bAEa1x6zx3GVcc/KwFyWBjQ9jlywC7a1TvVwujS6IDDNA 0/4iPnPIE8A4+/Qxpo8haLAgkUzF2GTE2mVRRxIp51Dq2PpfoI/dPiecvCgUsxwCZUYk R1R+blVjECTEgrF2Loj/nV1glZLz+yJom9CCQ+xBXoNHLf3UowrCOQFgrKKTKoVOEWUK Jaiw+6dtWZqhADBD8BL6oZkL0MWADyIzS9E/fmESFxDcAcUm73r+v4AOhnRZ0Jizlhpx 5iew== 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=eUx5qrV6Nzhi6Xcy/Tnd6RUENDD5Dla/rLUgJl4JhSc=; b=Vs7RzsetMFLlid4H3ONok3E8V6FeFh3xV4CE35LeHakJEWocjYlFl7PmMa5NoENo0c bw8Ld8+1s0xM+41n/fzlWRPX8bImo8ybQW+2FzPL8RuospY8Ik1BMRcrCqfTBba3Okkd lZhiQnNSeAcLcLZNSijuzG7rqoKsra9aW9Ge+fA1XCuLLp4JfCLr2A5zKMS1k50x4550 XuoM0FCcdxOwI0GQy/ilQterwL2KipNI0ZotYShP0swZhe1YyZhAOP6+cwxpt4SKvvWK GhVVLzo7ISB8J41RVuNtncyHy5GXKg0LXcLIlEOIKAn7N3FlGwCO5fiExmfa01QH6zgU RHdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=108iwMJ1; 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 b4si17807543eds.333.2021.09.20.19.45.23; Mon, 20 Sep 2021 19:45:47 -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=108iwMJ1; 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 S1378104AbhITSZU (ORCPT + 99 others); Mon, 20 Sep 2021 14:25:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:40564 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351130AbhITSSZ (ORCPT ); Mon, 20 Sep 2021 14:18:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C8AC6632A4; Mon, 20 Sep 2021 17:23:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632158582; bh=8zDodHJLPgbqBeip+e9adDHm4bqMx8kaLgkABP1/fi4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=108iwMJ1EmRn4nAo7lyl17S6LVDBlVKnqdWrynekSWKIbDiQvGYOB2bHP2BLk6Tc/ axpMYLiZqh2LYki+KaPYqZI8sXQ03JWuyBsraaWU+D70qBmylT3g7XNvzPH/gTzDb4 jr92/XAXStJNsaoyurIEQ+gdgFsX486yd80hrk9U= 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.4 190/260] drm/panfrost: Use u64 for size in lock_region Date: Mon, 20 Sep 2021 18:43:28 +0200 Message-Id: <20210920163937.574266894@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163931.123590023@linuxfoundation.org> References: <20210920163931.123590023@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 @@ -52,7 +52,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; @@ -72,7 +72,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; @@ -89,7 +89,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; @@ -106,7 +106,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); @@ -122,7 +122,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); @@ -222,7 +222,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;