From: Alessio Belle <Alessio.Belle@imgtec.com>
To: "pengpeng@iscas.ac.cn" <pengpeng@iscas.ac.cn>
Cc: Luigi Santivetti <Luigi.Santivetti@imgtec.com>,
"tzimmermann@suse.de" <tzimmermann@suse.de>,
"simona@ffwll.ch" <simona@ffwll.ch>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"airlied@gmail.com" <airlied@gmail.com>,
"boris.brezillon@collabora.com" <boris.brezillon@collabora.com>,
"maarten.lankhorst@linux.intel.com"
<maarten.lankhorst@linux.intel.com>,
Frank Binns <Frank.Binns@imgtec.com>,
"mripard@kernel.org" <mripard@kernel.org>,
Brajesh Gupta <Brajesh.Gupta@imgtec.com>
Subject: Re: [RFC] drm/pvr: define oversized freelist reconstruction handling
Date: Mon, 3 Aug 2026 14:54:10 +0000 [thread overview]
Message-ID: <72193a4ddde9f7ba66cf12a3ed68c22e917b1cbd.camel@imgtec.com> (raw)
In-Reply-To: <20260722040942.85459-1-pengpeng@iscas.ac.cn>
Hi Pengpeng,
Sorry for the delay and thanks for raising this. A few comments below.
On Wed, 2026-07-22 at 12:09 +0800, Pengpeng Hou wrote:
> pvr_free_list_process_reconstruct_req() receives a reconstruction count
> from firmware and uses it to iterate the request ID array and populate the
> response ID array. Both arrays have
> ROGUE_FWIF_MAX_FREELISTS_TO_RECONSTRUCT entries, but the count is not
> checked against that limit.
ROGUE_FWIF_MAX_FREELISTS_TO_RECONSTRUCT is meant to be the maximum number of
freelists in use at any time plus the ones being setup. If the firmware did send
a count above the maximum, it should be considered a bug.
>
> An oversized count would therefore make the loop and memcpy() access past
> the fixed protocol objects. The bounds issue is clear, but I could not find
> an ABI-defined completion for a malformed whole request.
>
> In particular, clamping does not appear justified. It changes the response
> count and silently omits IDs that firmware claims to have supplied. Dropping
> the request may leave firmware waiting for the reconstruction update, while
> echoing the original count cannot be represented safely in the fixed
> response.
You are right that sending a response that is too long is not safe, in fact
reading a request that is too long or malformed is also not safe in general.
Sending an incomplete reconstruction update (i.e. clamping to the expected
maximum), where each freelist has been marked as reconstructed, will still allow
the firmware to at least attempt to resume work; that might fail again, but
assuming the firmware won't keep sending oversized requests forever, it should
eventually recover.
>
> For comparison, the older Imagination host implementation also assumes a
> valid count, processes that many entries and echoes the count in the update:
>
> https://android.googlesource.com/kernel/mediatek/+/android-mtk-3.18/drivers/staging/imgtec/rogue/rgxta3d.c#710
FYI this driver is very old (> 10 years). Newer versions of the consumer DDK
clamp the length of the response in RGXProcessRequestFreelistsReconstruction()
and additionally initialise each element of the clamped list to invalid,
ignoring anything above the limit.
>
> The current ABI provides a per-freelist reconstruction-failed flag, but no
> whole-request error value for an invalid count.
>
> What is the intended recovery when firmware supplies a count above the
> protocol maximum? Should the driver treat it as a firmware-fatal condition,
> complete a bounded subset, or use another firmware-defined response? Once
> that contract is clear, I can prepare a narrow patch without inventing new
> firmware semantics.
>
In this case, (at least) clamping is fine for the reasons above.
Thanks,
Alessio
prev parent reply other threads:[~2026-08-03 14:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 4:09 Pengpeng Hou
2026-08-03 14:54 ` Alessio Belle [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=72193a4ddde9f7ba66cf12a3ed68c22e917b1cbd.camel@imgtec.com \
--to=alessio.belle@imgtec.com \
--cc=Brajesh.Gupta@imgtec.com \
--cc=Frank.Binns@imgtec.com \
--cc=Luigi.Santivetti@imgtec.com \
--cc=airlied@gmail.com \
--cc=boris.brezillon@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=pengpeng@iscas.ac.cn \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®