From: Deborah Brouwer <deborah.brouwer@collabora.com>
To: Liviu Dudau <liviu.dudau@arm.com>
Cc: igt-dev@lists.freedesktop.org, boris.brezillon@collabora.com,
adrian.larumbe@collabora.com, steven.price@arm.com,
daniel.almeida@collabora.com, kamil.konieczny@linux.intel.com
Subject: Re: [PATCH i-g-t 2/2] panthor: test dev_query buffer size variations
Date: Fri, 16 Oct 2026 15:10:23 -0700 [thread overview]
Message-ID: <atKgz-gMO1x10uhx@um790> (raw)
In-Reply-To: <atHpLtAzeOw8042v@e142607>
On Fri, Oct 16, 2026 at 10:06:54AM +0100, Liviu Dudau wrote:
> On Thu, Oct 15, 2026 at 04:44:58PM -0700, Deborah Brouwer wrote:
> > Add tests to check that the kernel driver will gracefully handle userspace
> > buffers that are smaller or larger than the kernel driver expected.
> >
> > Also, add a test to ensure that the kernel driver is enforcing the
> > minimum buffer size and that the kernel driver will provide the size
> > when the userpointer is null.
> >
> > This ensures UAPI compliance for DRM_IOCTL_PANTHOR_DEV_QUERY.
> >
> > Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
> > ---
> > tests/panthor/panthor_query.c | 64 +++++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 64 insertions(+)
> >
> > diff --git a/tests/panthor/panthor_query.c b/tests/panthor/panthor_query.c
> > index afd58a5bd..8ff2e9652 100644
> > --- a/tests/panthor/panthor_query.c
> > +++ b/tests/panthor/panthor_query.c
> > @@ -7,6 +7,10 @@
> > #include "panthor_drm.h"
> > #include <stdint.h>
> >
> > +#define GPU_INFO_MIN_SIZE \
> > + (offsetof(struct drm_panthor_gpu_info, tiler_present) + \
> > + sizeof(((struct drm_panthor_gpu_info *)0)->tiler_present))
> > +
> > int igt_main() {
> > int fd = -1;
> >
> > @@ -20,10 +24,70 @@ int igt_main() {
> > struct drm_panthor_gpu_info gpu = {};
> >
> > igt_panthor_query(fd, DRM_PANTHOR_DEV_QUERY_GPU_INFO, &gpu, sizeof(gpu), 0);
> > + igt_assert_neq(gpu.gpu_id, 0);
> > + }
> > +
> > + igt_describe("Ensure kernel returns a GPU_INFO size.");
> > + igt_subtest("query-size-null-pointer") {
> > + uint32_t size;
> > +
> > + size = igt_panthor_query(fd, DRM_PANTHOR_DEV_QUERY_GPU_INFO, NULL, 0, 0);
> > +
> > + /*
> > + * The kernel returns its output structure size, which may be out
> > + * of sync with the header used to build these tests, so don't expect
> > + * that the sizes will match necessarily.
> > + */
> > + igt_assert(size >= GPU_INFO_MIN_SIZE);
> > + }
> > +
> > + igt_describe("Ensure kernel enforces GPU_INFO minimum size.");
> > + igt_subtest("query-size-too-small") {
> > + struct drm_panthor_gpu_info gpu = {};
> > +
> > + igt_panthor_query(fd, DRM_PANTHOR_DEV_QUERY_GPU_INFO,
> > + &gpu, GPU_INFO_MIN_SIZE - 1, EINVAL);
> > + }
> > +
> > + igt_describe("Ensure kernel accepts GPU_INFO minimum size.");
> > + igt_subtest("query-min-size") {
> > + struct drm_panthor_gpu_info gpu = {};
> > +
> > + igt_panthor_query(fd, DRM_PANTHOR_DEV_QUERY_GPU_INFO,
> > + &gpu, GPU_INFO_MIN_SIZE, 0);
>
> This last test feels redundant. We've checked that the kernel expects a struct of
> at least GPU_INFO_MIN_SIZE and we've checked that smaller sizes are rejected. If
> GPU_INFO_MIN_SIZE is rejected that means we are no longer supporting that size
> and user space should be upgraded, not necessarily that the kernel has a bug.
Ok, yes that makes sense, I'll drop this test in v2.
Thanks for reviewing this.
>
>
> Best regards,
> Liviu
>
> >
> > igt_assert_neq(gpu.gpu_id, 0);
> > }
> >
> > + igt_describe("Ensure kernel zeros out unused part of buffer.");
> > + igt_subtest("query-too-big") {
> > + uint32_t size;
> > + size_t buf_size;
> > + uint8_t *buf;
> > +
> > + /*
> > + * Create a buffer that is larger than necessary.
> > + * Start with the size returned by the kernel in case it is out of
> > + * sync with these tests. Then add an extra 16 bytes and initialize
> > + * the entire buffer to non-zero values.
> > + */
> > + size = igt_panthor_query(fd, DRM_PANTHOR_DEV_QUERY_GPU_INFO,
> > + NULL, 0, 0);
> > + buf_size = (size_t)size + 16;
> > + buf = malloc(buf_size);
> > + igt_assert(buf);
> > + memset(buf, 0xff, buf_size);
> > +
> > + igt_panthor_query(fd, DRM_PANTHOR_DEV_QUERY_GPU_INFO,
> > + buf, buf_size, 0);
> > +
> > + /* Check that the extra bytes were zeroed. */
> > + for (size_t i = size; i < buf_size; i++)
> > + igt_assert_eq(buf[i], 0);
> > +
> > + free(buf);
> > + }
> > +
> > igt_fixture() {
> > drm_close_driver(fd);
> > }
> >
> > --
> > 2.56.0
> >
>
> --
> ====================
> | I would like to |
> | fix the world, |
> | but they're not |
> | giving me the |
> \ source code! /
> ---------------
> ¯\_(ツ)_/¯
next prev parent reply other threads:[~2026-10-16 22:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 23:44 [PATCH i-g-t 0/2] panthor: add dev_query tests for userspace buffer Deborah Brouwer
2026-10-15 23:44 ` [PATCH i-g-t 1/2] panthor: Return size from PANTHOR_DEV_QUERY Deborah Brouwer
2026-10-16 9:00 ` Liviu Dudau
2026-10-15 23:44 ` [PATCH i-g-t 2/2] panthor: test dev_query buffer size variations Deborah Brouwer
2026-10-16 9:06 ` Liviu Dudau
2026-10-16 22:10 ` Deborah Brouwer [this message]
2026-10-16 0:25 ` ✗ Xe.CI.BAT: failure for panthor: add dev_query tests for userspace buffer Patchwork
2026-10-16 0:37 ` ✓ i915.CI.BAT: success " Patchwork
2026-10-16 10:56 ` ✗ Xe.CI.FULL: failure " Patchwork
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=atKgz-gMO1x10uhx@um790 \
--to=deborah.brouwer@collabora.com \
--cc=adrian.larumbe@collabora.com \
--cc=boris.brezillon@collabora.com \
--cc=daniel.almeida@collabora.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=kamil.konieczny@linux.intel.com \
--cc=liviu.dudau@arm.com \
--cc=steven.price@arm.com \
/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