From patchwork Fri Aug 21 09:50:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 7050891 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 82F9E9F344 for ; Fri, 21 Aug 2015 09:50:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BA1A020612 for ; Fri, 21 Aug 2015 09:50:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BCD0B20606 for ; Fri, 21 Aug 2015 09:50:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752193AbbHUJuf (ORCPT ); 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 ); 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 To: Hans Verkuil Cc: linux-media@vger.kernel.org, Andrzej Hajda 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: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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(-) 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;