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 BF1BCC43458 for ; Mon, 6 Jul 2026 10:57:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3489710E13C; Mon, 6 Jul 2026 10:57:57 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=arm.com header.i=@arm.com header.b="gtRXUzJl"; dkim-atps=neutral Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by gabe.freedesktop.org (Postfix) with ESMTP id 8F3B010E13C for ; Mon, 6 Jul 2026 10:57:56 +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 CD4A432C7 for ; Mon, 6 Jul 2026 03:57:51 -0700 (PDT) Received: from [192.168.0.1] (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id F269F3F85F for ; Mon, 6 Jul 2026 03:57:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1783335476; bh=bRHd/dTPazO61cnkNoD2dOdp95aZDc+DylqAFQVHz7A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=gtRXUzJla//mqpMAYur5ZP8ypIkE3Rk+iifG29/lgwI/w8XiXVjARUecOZmIp1LXA fuYgGWQzaIg37gZiL3tDTVD9NENZZ2saVi1wL+jKutoe9Yzbs+UQKFdDTZGO2Tk4MW LsVcww/KTe9ewGRwvLkUN7DqMMdlhKb2pyIxTxc0= Date: Mon, 6 Jul 2026 11:57:45 +0100 From: Liviu Dudau To: =?utf-8?Q?Adri=C3=A1n?= Larumbe Cc: Boris Brezillon , Steven Price , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Heiko Stuebner , Grant Likely , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 2/3] drm/panthor: Add vm_bind region with kbo range overlap check Message-ID: References: <20260704-vm_bind_checks-v4-0-4705b6ca9f8a@collabora.com> <20260704-vm_bind_checks-v4-2-4705b6ca9f8a@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20260704-vm_bind_checks-v4-2-4705b6ca9f8a@collabora.com> 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 Sat, Jul 04, 2026 at 05:46:45AM +0100, Adrián Larumbe wrote: > When a VM is created, caller has to specify the range of the address space > carve-out set aside for mapping kernel BO's. That means vm_bind mappings of > UM-exposed BO's should not intersect with that region, but at the moment > we're not checking this. > > At first, I thought of giving these values to drm_gpuvm_init() through its > reserve_{offset, range} arguments, but it turns out that is meant for VM > address spans that are not managed through the usual drm_gpuvm split/merge > circuit, so storing the end of the user VA range at VM creation time and > doing a quick check in the vm_bind ioctl path was the simplest workaround. > > Fixes: tag and reference the relevant sparse binding support commit. > Fixes: 647810ec2476 ("drm/panthor: Add the MMU/VM logical block") > Reviewed-by: Boris Brezillon > Signed-off-by: Adrián Larumbe Reviewed-by: Liviu Dudau Best regards, Liviu > --- > drivers/gpu/drm/panthor/panthor_mmu.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c b/drivers/gpu/drm/panthor/panthor_mmu.c > index 163231c1703d..662a2c13b467 100644 > --- a/drivers/gpu/drm/panthor/panthor_mmu.c > +++ b/drivers/gpu/drm/panthor/panthor_mmu.c > @@ -310,6 +310,9 @@ struct panthor_vm { > u64 end; > } kernel_auto_va; > > + /** @user_va_range: Upper boundary of VAs VM users can map objects against. */ > + u64 user_va_range; > + > /** @as: Address space related fields. */ > struct { > /** > @@ -2893,6 +2896,8 @@ panthor_vm_create(struct panthor_device *ptdev, bool for_mcu, > va_range = full_va_range; > } > > + vm->user_va_range = kernel_va_start; > + > mutex_init(&vm->mm_lock); > drm_mm_init(&vm->mm, kernel_va_start, kernel_va_size); > vm->kernel_auto_va.start = auto_kernel_va_start; > @@ -2985,6 +2990,10 @@ panthor_vm_bind_prepare_op_ctx(struct drm_file *file, > if (check_add_overflow(op->va, op->size, &end)) > return -EINVAL; > > + /* We don't allow mappings that overlap with kbo's reserved range */ > + if (end > vm->user_va_range) > + return -EINVAL; > + > switch (op->flags & DRM_PANTHOR_VM_BIND_OP_TYPE_MASK) { > case DRM_PANTHOR_VM_BIND_OP_TYPE_MAP: > if (!(op->flags & DRM_PANTHOR_VM_BIND_OP_MAP_SPARSE)) { > > -- > 2.55.0 > -- ==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯