Skip to content

Commit 4c70ac7

Browse files
committed
drm/vc4: Add a pad field to align drm_vc4_submit_cl to 64 bits.
I had originally asked Stefan Schake to drop the pad field from the syncobj changes that just landed, because I couldn't come up with a reason to align to 64 bits. Talking with Dave Airlie about the new v3d driver's submit ioctl, we came up with a reason: sizeof() on 64-bit platforms may align to 64 bits, in which case the userspace will be submitting the aligned size and the final 32 bits won't be zero-padded by the kernel. If userspace doesn't zero-fill, then a future ABI change adding a 32-bit field at the end could potentially cause the kernel to read undefined data from old userspace (our userspace happens to use structure initialization that zero-fills, but as a general rule we try not to rely on that in the kernel). Signed-off-by: Eric Anholt <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Reviewed-by: Stefan Schake <[email protected]>
1 parent 0a4587a commit 4c70ac7

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

drivers/gpu/drm/vc4/vc4_gem.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,6 +1132,11 @@ vc4_submit_cl_ioctl(struct drm_device *dev, void *data,
11321132
return -EINVAL;
11331133
}
11341134

1135+
if (args->pad2 != 0) {
1136+
DRM_DEBUG("Invalid pad: 0x%08x\n", args->pad2);
1137+
return -EINVAL;
1138+
}
1139+
11351140
exec = kcalloc(1, sizeof(*exec), GFP_KERNEL);
11361141
if (!exec) {
11371142
DRM_ERROR("malloc failure on exec struct\n");

include/uapi/drm/vc4_drm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ struct drm_vc4_submit_cl {
193193
* render job. 0 means ignore.
194194
*/
195195
__u32 out_sync;
196+
197+
__u32 pad2;
196198
};
197199

198200
/**

0 commit comments

Comments
 (0)