Received: from cae.in-ulm.de (cae.in-ulm.de [217.10.14.231]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0AB73845DA for ; Tue, 23 Jun 2026 18:20:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.10.14.231 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782238831; cv=none; b=RvjVDCdSYze6irhZm+BNb6xAey20ohCbSXFIf6pknvOy7EytaLzNujZ6xu8kf62HfBK7P6q5CF/MmJgWymTmf9qs1gSD8KdrfvI75hP9JCmaSmWbDVYZ67kAcP/2fmqFBRjcodKmrS8+j627ejQUGzomvXNDNhJb1Q62Os40CPM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782238831; c=relaxed/simple; bh=jZ+IZLL/CnJ49Sfn3XnxIClyoO9qEdVPGP1etJxjIi8=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=psFOsrhd00ozzEMj7lI+2nNgU2h6NJOcWlwsdJqSDbrQX9p3ZfptT6MvPvCcaXl9te7vZ0HDYnN9CFmghV+mm2HhLza5i/9+jE7Gwaoduu4yShFyG+NSFytQC65qLiBppEmFOnTmUOUdv965yR2kNC6Z4SfGKQBPm9cwzULW4+Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c--e.de; spf=pass smtp.mailfrom=c--e.de; arc=none smtp.client-ip=217.10.14.231 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c--e.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=c--e.de Received: by cae.in-ulm.de (Postfix, from userid 1000) id B3C15140033; Tue, 23 Jun 2026 20:20:25 +0200 (CEST) From: "Christian A. Ehrhardt" To: Boris Brezillon , dri-devel@lists.freedesktop.org Cc: "Christian A. Ehrhardt" , Steven Price , Liviu Dudau , Andrew Morton , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm/panthor: Check VMA boundaries for PMD mappings Date: Tue, 23 Jun 2026 20:19:42 +0200 Message-Id: <20260623181942.1536598-1-lk@c--e.de> X-Mailer: git-send-email 2.39.5 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit When checking a different patch[1] sashiko AI pointed out that panthor needs the same fix[2]: In the ->huge_fault handler do not install a PMD huge page mapping if the huge page exceeds the boundaries of the VMA. [1] https://lore.kernel.org/lkml/20260622215718.1532689-1-lk@c--e.de/ [2] https://sashiko.dev/#/patchset/20260622215718.1532689-1-lk%40c--e.de Cc: Boris Brezillon Cc: Steven Price Cc: Liviu Dudau Fixes: 68cbf96b1e9b ("drm/panthor: Part ways with drm_gem_shmem_object") Signed-off-by: Christian A. Ehrhardt --- drivers/gpu/drm/panthor/panthor_gem.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) NOTE: The panthor version is only compile tested because I don't have the hardware. However, the code is identical to that fixed in [1] and I have a reproducer for that. No need for for stable backports. The code is new in 7.1. diff --git a/drivers/gpu/drm/panthor/panthor_gem.c b/drivers/gpu/drm/panthor/panthor_gem.c index a1e2eb1ca7bb..54535bae2b0c 100644 --- a/drivers/gpu/drm/panthor/panthor_gem.c +++ b/drivers/gpu/drm/panthor/panthor_gem.c @@ -802,9 +802,13 @@ static vm_fault_t insert_page(struct vm_fault *vmf, unsigned int order, struct p } else if (order == PMD_ORDER) { unsigned long pfn = page_to_pfn(page); unsigned long paddr = pfn << PAGE_SHIFT; + struct vm_area_struct *vma = vmf->vma; + unsigned long start = ALIGN_DOWN(vmf->address, PMD_SIZE); + unsigned long end = start + PMD_SIZE; + bool in_range = vma->vm_start <= start && end <= vma->vm_end; bool aligned = (vmf->address & ~PMD_MASK) == (paddr & ~PMD_MASK); - if (aligned && + if (aligned && in_range && folio_test_pmd_mappable(page_folio(page))) { pfn &= PMD_MASK >> PAGE_SHIFT; return vmf_insert_pfn_pmd(vmf, pfn, vmf->flags & FAULT_FLAG_WRITE); -- 2.43.0