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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 5FC8CCA0FF2 for ; Wed, 3 Sep 2025 11:29:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C49E410E7A8; Wed, 3 Sep 2025 11:29:45 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by gabe.freedesktop.org (Postfix) with ESMTP id 9F8D510E7C3 for ; Wed, 3 Sep 2025 11:29:43 +0000 (UTC) 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 B8E351688; Wed, 3 Sep 2025 04:29:34 -0700 (PDT) Received: from [10.1.39.32] (e122027.cambridge.arm.com [10.1.39.32]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 326913F694; Wed, 3 Sep 2025 04:29:40 -0700 (PDT) Message-ID: <87b5f17b-db1f-4acd-a8bd-1ac773c13224@arm.com> Date: Wed, 3 Sep 2025 12:29:39 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] drm/panthor: check bo offset alignment in vm bind To: Chia-I Wu , Boris Brezillon , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20250828200116.3532255-1-olvaffe@gmail.com> From: Steven Price Content-Language: en-GB In-Reply-To: <20250828200116.3532255-1-olvaffe@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On 28/08/2025 21:01, Chia-I Wu wrote: > Fail early from panthor_vm_bind_prepare_op_ctx instead of late from > ops->map_pages. > > Signed-off-by: Chia-I Wu > Reviewed-by: Boris Brezillon Reviewed-by: Steven Price I'll push this to drm-misc-next. Thanks, Steve > --- > drivers/gpu/drm/panthor/panthor_mmu.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c b/drivers/gpu/drm/panthor/panthor_mmu.c > index bad720f23eb70..6dec4354e3789 100644 > --- a/drivers/gpu/drm/panthor/panthor_mmu.c > +++ b/drivers/gpu/drm/panthor/panthor_mmu.c > @@ -1222,7 +1222,7 @@ static int panthor_vm_prepare_map_op_ctx(struct panthor_vm_op_ctx *op_ctx, > (flags & DRM_PANTHOR_VM_BIND_OP_TYPE_MASK) != DRM_PANTHOR_VM_BIND_OP_TYPE_MAP) > return -EINVAL; > > - /* Make sure the VA and size are aligned and in-bounds. */ > + /* Make sure the VA and size are in-bounds. */ > if (size > bo->base.base.size || offset > bo->base.base.size - size) > return -EINVAL; > > @@ -2447,7 +2447,7 @@ panthor_vm_bind_prepare_op_ctx(struct drm_file *file, > int ret; > > /* Aligned on page size. */ > - if (!IS_ALIGNED(op->va | op->size, vm_pgsz)) > + if (!IS_ALIGNED(op->va | op->size | op->bo_offset, vm_pgsz)) > return -EINVAL; > > switch (op->flags & DRM_PANTHOR_VM_BIND_OP_TYPE_MASK) {