Message ID | 1440150609-23312-1-git-send-email-a.hajda@samsung.com (mailing list archive) |
---|---|
State | RFC, archived |
Headers |
Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from <linux-media-owner@vger.kernel.org>) id 1ZSiy7-0002Yj-AK; Fri, 21 Aug 2015 11:50:39 +0200 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.76/mailfrontend-8) with esmtp id 1ZSiy5-0000Sy-jd; Fri, 21 Aug 2015 11:50:38 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752193AbbHUJuf (ORCPT <rfc822;mkrufky@linuxtv.org> + 1 other); Fri, 21 Aug 2015 05:50:35 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:62496 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751812AbbHUJue (ORCPT <rfc822;linux-media@vger.kernel.org>); Fri, 21 Aug 2015 05:50:34 -0400 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NTF00JEYFC79H90@mailout1.w1.samsung.com> for linux-media@vger.kernel.org; Fri, 21 Aug 2015 10:50:32 +0100 (BST) X-AuditID: cbfec7f5-f794b6d000001495-07-55d6f467d35f Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id EB.72.05269.764F6D55; Fri, 21 Aug 2015 10:50:31 +0100 (BST) Received: from AMDC1061.digital.local ([106.116.147.88]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NTF0009AFBUHB20@eusync3.samsung.com>; Fri, 21 Aug 2015 10:50:31 +0100 (BST) From: Andrzej Hajda <a.hajda@samsung.com> To: Hans Verkuil <hans.verkuil@cisco.com> Cc: linux-media@vger.kernel.org, Andrzej Hajda <a.hajda@samsung.com> Subject: [RFC PATCH] v4l2-compat-ioctl32: fix struct v4l2_event32 alignment Date: Fri, 21 Aug 2015 11:50:09 +0200 Message-id: <1440150609-23312-1-git-send-email-a.hajda@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrDJMWRmVeSWpSXmKPExsVy+t/xq7rpX66FGry8b2lxa905VoslP3cx WfRs2MrqwOwx5fdGVo++LasYPT5vkgtgjuKySUnNySxLLdK3S+DKeH/9N1vBVZ6KHT9+sTUw HuTqYuTgkBAwkVhzy6uLkRPIFJO4cG89WxcjF4eQwFJGiV3PzkE5TUwS73Z/ZgSpYhPQlPi7 +SYbiC0CZH+bvo0ZxGYWcJGY+XMpM8hQYQFviaMfpEDCLAKqEh8nT2MCsXkFnCUau9+wQyyT kzh5bDLrBEbuBYwMqxhFU0uTC4qT0nON9IoTc4tL89L1kvNzNzFC/Px1B+PSY1aHGAU4GJV4 eGdEXgsVYk0sK67MPcQowcGsJMJr/QIoxJuSWFmVWpQfX1Sak1p8iFGag0VJnHfmrvchQgLp iSWp2ampBalFMFkmDk6pBkajvF83eE8vC53JltswoYuRQUw9SM6F3WxXgmmlO7fU9WULvibb G9tsbeGOe+FcfvD79G9FBk0cqgc+bXH5GTMnRkf1e5p9/b/NZi1Jy87eid/lXntrk7ROX90h tfK16zaoZ75YKCp8OH7mA9+q/l/c03ocZyxpX8jTo/KVNaBdITubM8b1iRJLcUaioRZzUXEi AJAkEIrvAQAA Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: <linux-media.vger.kernel.org> X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2015.8.21.94517 X-PMX-Spam: Gauge=IIIIIIIII, Probability=9%, Report=' HTML_NO_HTTP 0.1, MULTIPLE_RCPTS 0.1, HTML_00_10 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_1700_1799 0, BODY_SIZE_2000_LESS 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, NO_URI_HTTPS 0, SINGLE_URI_IN_BODY 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_URI_IN_BODY 0, __HAS_FROM 0, __HAS_HTML 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __MIME_TEXT_ONLY 0, __MULTIPLE_RCPTS_CC_X2 0, __SANE_MSGID 0, __SINGLE_URI_TEXT 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __URI_IN_BODY 0, __URI_NO_WWW 0, __URI_NS ' |
Commit Message
Andrzej Hajda
Aug. 21, 2015, 9:50 a.m. UTC
Union v4l2_event::u is aligned to 8 bytes on arm32. On arm64 v4l2_event32::u
is aligned to 4 bytes. As a result structures v4l2_event and v4l2_event32 have
different sizes and VIDOC_DQEVENT ioctl does not work from arm32 apps running
on arm64 kernel. The patch fixes it.
Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
Hi Hans,
It seems there is problem with VIDIOC_DQEVENT called from arm32 apps on arm64
kernel. After tracking down the issue it seems v4l2_event32 on arm64 have
different field alignment/size than v4l2_event on arm32. The patch fixes it.
But i guess it can break ABI on other architectures. Simple tests shows:
i386:
sizeof(struct v4l2_event)=0x78
offsetof(struct v4l2_event::u)=0x4
amd64:
sizeof(struct v4l2_event)=0x88
offsetof(struct v4l2_event::u)=0x8
arm:
sizeof(struct v4l2_event)=0x80
offsetof(struct v4l2_event::u)=0x8
arm64:
sizeof(struct v4l2_event)=0x88
offsetof(struct v4l2_event::u)=0x8
Any advices how to fix it in arch compatible way?
Regards
Andrzej
---
drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 08/21/2015 11:50 AM, Andrzej Hajda wrote: > Union v4l2_event::u is aligned to 8 bytes on arm32. On arm64 v4l2_event32::u > is aligned to 4 bytes. As a result structures v4l2_event and v4l2_event32 have > different sizes and VIDOC_DQEVENT ioctl does not work from arm32 apps running > on arm64 kernel. The patch fixes it. > > Signed-off-by: Andrzej Hajda <a.hajda@samsung.com> > --- > Hi Hans, > > It seems there is problem with VIDIOC_DQEVENT called from arm32 apps on arm64 > kernel. After tracking down the issue it seems v4l2_event32 on arm64 have > different field alignment/size than v4l2_event on arm32. The patch fixes it. > But i guess it can break ABI on other architectures. Simple tests shows: > > i386: > sizeof(struct v4l2_event)=0x78 > offsetof(struct v4l2_event::u)=0x4 > > amd64: > sizeof(struct v4l2_event)=0x88 > offsetof(struct v4l2_event::u)=0x8 > > arm: > sizeof(struct v4l2_event)=0x80 > offsetof(struct v4l2_event::u)=0x8 > > arm64: > sizeof(struct v4l2_event)=0x88 > offsetof(struct v4l2_event::u)=0x8 > > Any advices how to fix it in arch compatible way? I noticed a compat_s64 type that knows about the 4-byte alignment on i386. So I think this can be solved by declaring v4l2_event32 as follows: struct v4l2_event32 { __u32 type; union { compat_s64 value64; __u8 data[64]; } u; __u32 pending; __u32 sequence; struct compat_timespec timestamp; __u32 id; __u32 reserved[8]; }; I think that this will force the correct alignment. Can you check this? Good catch BTW. Looking at v4l2-compat-ioctl32.c I suspect that compat_u/s64 will need to be used in more places: v4l2_standard32 (replace the id[2] array by compat_u64 id) and v4l2_ext_control32 are both almost certainly wrong for arm64. I would check those two. Regards, Hans > > Regards > Andrzej > --- > drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c > index af63543..a4a1856 100644 > --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c > +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c > @@ -739,7 +739,7 @@ struct v4l2_event32 { > __u32 type; > union { > __u8 data[64]; > - } u; > + } u __attribute__((aligned(8))); > __u32 pending; > __u32 sequence; > struct compat_timespec timestamp; > -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c index af63543..a4a1856 100644 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c @@ -739,7 +739,7 @@ struct v4l2_event32 { __u32 type; union { __u8 data[64]; - } u; + } u __attribute__((aligned(8))); __u32 pending; __u32 sequence; struct compat_timespec timestamp;