From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 095F3387343; Tue, 10 Mar 2026 11:20:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773141640; cv=none; b=bN7U5tluspQqVD3OcHtWfUnTCZWMFjcNSVVL5usacjCUfFKPM9B130/wmCQLQcSjdmXc7ygTl7rsO21UvuUKCO3gXVPPJnAV/Xqdcp3XOnGzC/wPou3u1BbRqn+bGlN+1jJWYJRpuzhXA32CNXOR+NGyegtZU1OKwgs/+nIf7L0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773141640; c=relaxed/simple; bh=xGjVBeTYpyjTZwX3gFYF54w9+q8HTHPh6xi2cya8jck=; h=Mime-Version:Content-Type:Date:Message-Id:Subject:Cc:To:From: References:In-Reply-To; b=eEnzULGdGWf28h6HsGtneTqYjTWbPjo+BaGddtm31Ik7e56QP3jPeZT8rHuNGzbVbc3teMl3XqSgpuD7Eq5qh4j9ycUUOjaJ7OOg8Q0Z7DPI7vwBFq7qWGRBvDxoHftv6Io5NTqsdFz2sM1yYqIcyNqf1weP4dR7qg6WgWlndD8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fkJHucYB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fkJHucYB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CB06C2BC86; Tue, 10 Mar 2026 11:20:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773141639; bh=xGjVBeTYpyjTZwX3gFYF54w9+q8HTHPh6xi2cya8jck=; h=Date:Subject:Cc:To:From:References:In-Reply-To:From; b=fkJHucYBWZLi6X7ajADYfz3hex8bL9zwxxf+Qg3QdznH8ruuShORbyaf9dUBWKX/k 6IMV9Es4zvdNSfxvDlqIMwT7zIdwOLAuxhMhzKIsfgLA6HLecsylVuJDKzGC8cuNkf LgqHol1mk5uZmDxj7FqcxlgCxi3W5AVSAWd7ykXP9sHcykWOuPx5SbDsfELXrF9BHS HmU4OEXbmHGyc37rBbdTcH9za6VVEoNQCk/3piTjjK02V307rPoqT7DWwRSDv7JVAP 0V0VL5KLuTW/tKbUB6bq3SmsOuOZ8oIUH2Ct9ebL0+m/iaoiZam6FXuUeTSZYs0enq 4owbJQt4gDS8Q== Precedence: bulk X-Mailing-List: rust-for-linux@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 Date: Tue, 10 Mar 2026 12:20:33 +0100 Message-Id: Subject: Re: [PATCH v4 4/4] gpu: nova-core: fix stack overflow in GSP memory allocation Cc: "Gary Guo" , "Tim Kovalenko via B4 Relay" , , "Alice Ryhl" , "David Airlie" , "Simona Vetter" , "Miguel Ojeda" , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , "Benno Lossin" , "Andreas Hindborg" , "Trevor Gross" , "Boqun Feng" , "Nathan Chancellor" , "Nicolas Schier" , "Abdiel Janulgue" , "Daniel Almeida" , "Robin Murphy" , , , , , , To: "Alexandre Courbot" From: "Danilo Krummrich" References: <20260309-drm-rust-next-v4-0-4ef485b19a4c@proton.me> <20260309-drm-rust-next-v4-4-4ef485b19a4c@proton.me> In-Reply-To: On Tue Mar 10, 2026 at 3:28 AM CET, Alexandre Courbot wrote: > On Tue Mar 10, 2026 at 10:51 AM JST, Gary Guo wrote: >> On Tue Mar 10, 2026 at 1:40 AM GMT, Alexandre Courbot wrote: >>> On Tue Mar 10, 2026 at 1:34 AM JST, Tim Kovalenko via B4 Relay wrote: >>>> diff --git a/drivers/gpu/nova-core/gsp/cmdq.rs b/drivers/gpu/nova-core= /gsp/cmdq.rs >>>> index 0056bfbf0a44cfbc5a0ca08d069f881b877e1edc..c8327d3098f73f9b880eee= 99038ad10a16e1e32d 100644 >>>> --- a/drivers/gpu/nova-core/gsp/cmdq.rs >>>> +++ b/drivers/gpu/nova-core/gsp/cmdq.rs >>>> @@ -202,7 +202,20 @@ fn new(dev: &device::Device) -> Re= sult { >>>> =20 >>>> let gsp_mem =3D >>>> CoherentAllocation::::alloc_coherent(dev, 1, GFP_= KERNEL | __GFP_ZERO)?; >>>> - dma_write!(gsp_mem, [0]?.ptes, PteArray::new(gsp_mem.dma_hand= le())?); >>>> + >>>> + const NUM_PTES: usize =3D GSP_PAGE_SIZE / size_of::(); >>>> + >>>> + let start =3D gsp_mem.dma_handle(); >>>> + // One by one GSP Page write to the memory to avoid stack ove= rflow when allocating >>>> + // the whole array at once. >>>> + for i in 0..NUM_PTES { >>>> + dma_write!( >>>> + gsp_mem, >>>> + [0]?.ptes.0[i], >>>> + PteArray::::entry(start, i)? >>> >>> Does `::` need to be mentioned here, or is the compiler able >>> to infer it? >> >> The function signature doesn't mention NUM_PTES at all, so no. In fact, = perhaps >> the `entry` shouldn't be an associated method at all (even if is, it pro= bably >> should be of `PteArray::<0>` or something. I think <0> is probably the best choice for this fix for now. > I had that thought as well - this calls for a redesign of the `PteArray` > business - but also didn't want to interfere too much as this fix is > very much (and quickly) needed. We will probably re-write this once we > have access to the new I/O code anyway. Not sure it actually needs a redesign, as I think this just goes away with = I/O projections. That's also why I would add the following TODO comment on entr= y(). // TODO: Replace with `IoView` projections once available. I.e. it is just a workaround for now.