video: adf: ensure consistent alignment on userspace facing structs
authorGreg Hackmann <ghackmann@google.com>
Wed, 26 Mar 2014 23:43:23 +0000 (16:43 -0700)
committerJohn Stultz <john.stultz@linaro.org>
Tue, 16 Feb 2016 21:53:19 +0000 (13:53 -0800)
64-bit types in structs create alignment problems when a 32-bit x86
userspace talks to an x86_64 kernel.  In most cases the 64-bit types can
be replaced with 32-bit ones, since they're being used for fds and
should have been __s32 in the first place.  For adf_vsync_event,
alignment can be enforced by making the timestamp an __aligned_u64.

Change-Id: I87cf73d8f57730bd7bb43ffce6b7b411eb0ff198
Signed-off-by: Greg Hackmann <ghackmann@google.com>
drivers/video/adf/adf_fops.c
drivers/video/adf/adf_fops32.h
include/uapi/video/adf.h

index abec58ea2ed8c7570368346bdfcabddf86ad1964..7fbf33e1cb39f8dc95fe9587b6de1d7755aa1a8f 100644 (file)
@@ -187,7 +187,7 @@ static int adf_buffer_import(struct adf_device *dev,
                buf->dma_bufs[i] = dma_buf_get(user_buf.fd[i]);
                if (IS_ERR(buf->dma_bufs[i])) {
                        ret = PTR_ERR(buf->dma_bufs[i]);
-                       dev_err(&dev->base.dev, "importing dma_buf fd %llu failed: %d\n",
+                       dev_err(&dev->base.dev, "importing dma_buf fd %d failed: %d\n",
                                        user_buf.fd[i], ret);
                        buf->dma_bufs[i] = NULL;
                        goto done;
@@ -200,7 +200,7 @@ static int adf_buffer_import(struct adf_device *dev,
        if (user_buf.acquire_fence >= 0) {
                buf->acquire_fence = sync_fence_fdget(user_buf.acquire_fence);
                if (!buf->acquire_fence) {
-                       dev_err(&dev->base.dev, "getting fence fd %lld failed\n",
+                       dev_err(&dev->base.dev, "getting fence fd %d failed\n",
                                        user_buf.acquire_fence);
                        ret = -EINVAL;
                        goto done;
index 53d43f0102089a564849578cfe2a8cb658558dce..64034ce33a6bbd9ba490db915b9189268aaf6301 100644 (file)
@@ -25,7 +25,7 @@ struct adf_post_config32 {
        compat_size_t custom_data_size;
        compat_uptr_t custom_data;
 
-       __s64 complete_fence;
+       __s32 complete_fence;
 };
 
 struct adf_device_data32 {
index b703bf9e9a662a50ccb54459b228c827f040d41a..c5d2e62cdb9bfb2a73e361ad9db94e000f7a6986 100644 (file)
@@ -83,7 +83,7 @@ struct adf_event {
  */
 struct adf_vsync_event {
        struct adf_event base;
-       __u64 timestamp;
+       __aligned_u64 timestamp;
 };
 
 /**
@@ -119,12 +119,12 @@ struct adf_buffer_config {
        __u32 h;
        __u32 format;
 
-       __s64 fd[ADF_MAX_PLANES];
+       __s32 fd[ADF_MAX_PLANES];
        __u32 offset[ADF_MAX_PLANES];
        __u32 pitch[ADF_MAX_PLANES];
        __u8 n_planes;
 
-       __s64 acquire_fence;
+       __s32 acquire_fence;
 };
 #define ADF_MAX_BUFFERS (4096 / sizeof(struct adf_buffer_config))
 
@@ -150,7 +150,7 @@ struct adf_post_config {
        size_t custom_data_size;
        void __user *custom_data;
 
-       __s64 complete_fence;
+       __s32 complete_fence;
 };
 #define ADF_MAX_INTERFACES (4096 / sizeof(__u32))
 
@@ -180,7 +180,7 @@ struct adf_simple_buffer_alloc {
        __u16 h;
        __u32 format;
 
-       __s64 fd;
+       __s32 fd;
        __u32 offset;
        __u32 pitch;
 };
@@ -195,7 +195,7 @@ struct adf_simple_buffer_alloc {
  */
 struct adf_simple_post_config {
        struct adf_buffer_config buf;
-       __s64 complete_fence;
+       __s32 complete_fence;
 };
 
 /**