From nobody Sun Nov 24 06:26:09 2024 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5F682207A1A for ; Wed, 6 Nov 2024 18:58:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730919503; cv=none; b=dmkG/4ae29PdahIzNQCsTYCHkGtoAjRZwek1luklMPDi6IAm/NX2oilDvmLYJlBaY2gYME7SD/EeMgSYaGgWxbdU6IAt0n0pJNtHWcVRiLbqKLV+IrV6PxZeiHvMyQ/2TO2mkZ6ojwSav9FP3AnDS+3led67SaerLEssp13NpaY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730919503; c=relaxed/simple; bh=a790h49AtUkJxgr+O+C1kiwWl+LUuuzrKpUHyHSOc3Q=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=O5Cvw+c8h3Gfb/+tt0k1V3Eibg280HQ/tPv1kUbKROE2FaGWvUcmjSnI5lCBCSMF7Iej1z6Xmi1trm8Nd/j/SrpYL2k38qTPdWF2klcrVKWKFXNKFivQ+lvNHQCnw0Wyw2Sx9EPWN7dCAwV/zzDazTZztqhwFlhkPGudsj10QK8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 490F7497; Wed, 6 Nov 2024 10:58:48 -0800 (PST) Received: from e110455-lin.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 067FE3F528; Wed, 6 Nov 2024 10:58:16 -0800 (PST) From: Liviu Dudau To: Boris Brezillon Cc: Liviu Dudau , Steven Price , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Jann Horn Subject: [PATCH v2] drm/panthor: Lock XArray when getting entries for the VM Date: Wed, 6 Nov 2024 18:58:06 +0000 Message-ID: <20241106185806.389089-1-liviu.dudau@arm.com> X-Mailer: git-send-email 2.47.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Similar to cac075706f29 ("drm/panthor: Fix race when converting group handle to group object") we need to use the XArray's internal locking when retrieving a vm pointer from there. v2: Removed part of the patch that was trying to protect fetching the heap pointer from XArray, as that operation is protected by the @pool->lock. Fixes: 647810ec2476 ("drm/panthor: Add the MMU/VM logical block") Reported-by: Jann Horn Cc: Boris Brezillon Cc: Steven Price Signed-off-by: Liviu Dudau Reviewed-by: Boris Brezillon Reviewed-by: Steven Price --- drivers/gpu/drm/panthor/panthor_mmu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c b/drivers/gpu/drm/pantho= r/panthor_mmu.c index 8ca85526491e6..46b84a557d9cc 100644 --- a/drivers/gpu/drm/panthor/panthor_mmu.c +++ b/drivers/gpu/drm/panthor/panthor_mmu.c @@ -1580,7 +1580,9 @@ panthor_vm_pool_get_vm(struct panthor_vm_pool *pool, = u32 handle) { struct panthor_vm *vm; =20 + xa_lock(&pool->xa); vm =3D panthor_vm_get(xa_load(&pool->xa, handle)); + xa_unlock(&pool->xa); =20 return vm; } --=20 2.47.0