Skip to contentSkip to conversation

tests/gem_gtt_hog: Clear the parameters for GEM_CREATE ioctl

PATCH In review Sagar Arun Kamble 2 participants 5 messages Mar 20, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/gem_gtt_hog: Clear the parameters for GEM_CREATE ioctl

Due to garbage data seen by i915, gem_create_ioctl failed for gem obj created with drmIoctl(GEM_CREATE) without properly initialized parameters. Can be fixed by calling gem_create helper too.

Cc Chris Wilson <[email protected]>
Cc Lukasz Kalamarz <[email protected]>
Cc Radoslaw Szwichtenberg <[email protected]>
---
 tests/gem_gtt_hog.c | 1 +
 1 file changed, 1 insertion(+)
tests/gem_gtt_hog.c +1 -0
index a3dbfad..0696bdc 100644
@@ -93,6 +93,7 @@ static void busy(data_t *data, uint32_t handle, int size, int loops)
 	gem_exec[0].handle = handle;
 	gem_exec[0].flags = EXEC_OBJECT_NEEDS_FENCE;
 
+	memset(&create, 0, sizeof(create));
 	create.handle = 0;
 	create.size = 4096;
 	drmIoctl(data->fd, DRM_IOCTL_I915_GEM_CREATE, &create);
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw
Quoted 3 lines · Sagar Arun Kamble

Due to garbage data seen by i915, gem_create_ioctl failed for gem obj created with drmIoctl(GEM_CREATE) without properly initialized parameters. Can be fixed by calling gem_create helper too.

Whose bug are you working around?
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw
Quoted 6 lines · Chris Wilson
Quoted 3 lines · Sagar Arun Kamble

Due to garbage data seen by i915, gem_create_ioctl failed for gem obj created with drmIoctl(GEM_CREATE) without properly initialized parameters. Can be fixed by calling gem_create helper too.

Whose bug are you working around?
-Chris

Found out now that this is happening due to mismatch in the libdrm headers 32bit/64bit flags for GEM_CREATE. Able to resolve by properly using the proper definitions.
Will this fix be still applicable as flags would stay uninitialized with current call to drmIoctl?

Quoted 1 line

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw
Quoted 7 lines · Sagar A
Quoted 4 lines · Chris Wilson
Quoted 3 lines · Sagar Arun Kamble

Due to garbage data seen by i915, gem_create_ioctl failed for gem obj created with drmIoctl(GEM_CREATE) without properly initialized parameters. Can be fixed by calling gem_create helper too.

Quoted 6 lines
Quoted 2 lines

Whose bug are you working around?
-Chris

Found out now that this is happening due to mismatch in the libdrm headers 32bit/64bit flags for GEM_CREATE. Able to resolve by properly using the proper definitions.
Will this fix be still applicable as flags would stay uninitialized with current call to drmIoctl?

At the moment, create.pad is never tested ergo it is valid to contain garbage and as demonstrated that behaviour is already relied upon by userspace.

How did the headers vary? The defintion is

struct drm_i915_gem_create {
        /**
         * Requested size for the object.
         *
         * The (page-aligned) allocated size for the object will be returned.
         */
        __u64 size;
        /**
         * Returned handle for the object.
         *
         * Object handles are nonzero.
         */
        __u32 handle;
        __u32 pad;
};

which should be 32/64bit safe. Otherwise we need a compat ioctl for the same reason as not breaking 32bit userspace on 64bit kernel. -Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw
Quoted 32 lines · Chris Wilson
Quoted 11 lines · Sagar A
Quoted 6 lines · Chris Wilson
Quoted 3 lines · Sagar Arun Kamble

Due to garbage data seen by i915, gem_create_ioctl failed for gem obj created with drmIoctl(GEM_CREATE) without properly initialized parameters. Can be fixed by calling gem_create helper too.

Whose bug are you working around?
-Chris

Found out now that this is happening due to mismatch in the libdrm headers 32bit/64bit flags for GEM_CREATE. Able to resolve by properly using the proper definitions.
Will this fix be still applicable as flags would stay uninitialized with current call to drmIoctl?

At the moment, create.pad is never tested ergo it is valid to contain garbage and as demonstrated that behaviour is already relied upon by userspace.

How did the headers vary? The defintion is

struct drm_i915_gem_create {
         /**
          * Requested size for the object.
          *
          * The (page-aligned) allocated size for the object will be returned.
          */
         __u64 size;
         /**
          * Returned handle for the object.
          *
          * Object handles are nonzero.
          */
         __u32 handle;
         __u32 pad;
};
Quoted 3 lines

which should be 32/64bit safe. Otherwise we need a compat ioctl for the same reason as not breaking 32bit userspace on 64bit kernel. -Chris

This behavior is with internal Android kernel where gem_create has extra member as "__u64 flags" added for stolen objects.
With pad value exception and size, handle set properly this patch does not apply then.

Quoted 1 line

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx