From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (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 CC7312594B9 for ; Wed, 24 Jun 2026 10:33:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.251.105.195 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782297201; cv=none; b=HI2LAYfhxIRj58J/g+ssHyIAVopCc3ailgQCz9dwdrWM2ugmx81485ASUbdsfFRLpGgD/M2sooEtylyo0D/kP3FQ8T7OWWDsm0POkqOMVUZSF1huptHf7eJ55s1EmS7EV4dGnhaX/67nynErBX5YPn0n2FAxVximTQ6IeaK0JV8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782297201; c=relaxed/simple; bh=qSYOHFLFwGgYk8Qfxz13gyyEZHuOKB7DCcv5vxPHQZE=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lVz+JPono8IZ/KzyqB13oYe8xPeiEh6LiD0biKBcSseaen4NCQr9UbN0+r+aL4D7s+aaddZviewAuM2O/oxw3pxLyWLXAXq2X7k6BWI9gQEowFYP5IpS/EQgnrc/kA2RhNU5lttudOe8A+jeEh1puiT64ic53H3du3DcDEM92EY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=En9T6wV6; arc=none smtp.client-ip=148.251.105.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="En9T6wV6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1782297198; bh=qSYOHFLFwGgYk8Qfxz13gyyEZHuOKB7DCcv5vxPHQZE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=En9T6wV6Cbm93LIQPD8jr0gw7ajIbYL2bXy7UK5//Xx3r/bJY5PZdqy/rOP3uYlPa uEDerbvgOmyB4Qgabl5iSZEBHabp7vxLEJsJb13Y2KiAeaXiz+EmjlFdOTXBSIXU4Q uwpSSUAtPx1vCzBvjFAtlKEPp/In6X9It89/ac7kBV+W61aeN+BfEY89qaHF4CJk+i 6jCd3/KZHi5OIzn1zrrybUmwhCyFZnOR4TRwCQCgtkB0QK04sHxMXD3w5ABwWz3L8r /AUnXD9y24quNm/8h0TB6G8IQcVu+NIZdoYmCqbjWaG2VSBFhyEpqWetCePjV5/QKW UK/IUJUWdZdxw== Received: from fedora-2.home (unknown [100.64.0.11]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bbrezillon) by bali.collaboradmins.com (Postfix) with ESMTPSA id 9AAB617E091C; Wed, 24 Jun 2026 12:33:17 +0200 (CEST) Date: Wed, 24 Jun 2026 12:33:13 +0200 From: Boris Brezillon To: "Christian A. Ehrhardt" Cc: dri-devel@lists.freedesktop.org, 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: Re: [PATCH] drm/panthor: Check VMA boundaries for PMD mappings Message-ID: <20260624123313.3dcd8b8b@fedora-2.home> In-Reply-To: <20260624122636.22d34274@fedora-2.home> References: <20260623181942.1536598-1-lk@c--e.de> <20260624122636.22d34274@fedora-2.home> Organization: Collabora X-Mailer: Claws Mail 4.4.0 (GTK 3.24.52; x86_64-redhat-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 24 Jun 2026 12:26:36 +0200 Boris Brezillon wrote: > On Tue, 23 Jun 2026 20:19:42 +0200 > "Christian A. Ehrhardt" wrote: > > > 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 > > I know the discussion is ongoing to decide what we should do about > these huge_fault() handlers, but I think it's worth getting this fix in > in the meantime. > > Reviewed-by: Boris Brezillon BTW, I saw shashiko complain about our page_offset calculation which should look something like page_offset = vmf->pgoff - drm_vma_node_start(&bo->base.vma_node); to be immune to the vma->vm_{start,pgoff} adjustments done when the VMA is split. > > > --- > > 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); >