From patchwork Mon Aug 31 11:56:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 7099521 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 DF2139F1B9 for ; Mon, 31 Aug 2015 11:57:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 14D71206A4 for ; Mon, 31 Aug 2015 11:57:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D11F5206A2 for ; Mon, 31 Aug 2015 11:57:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752680AbbHaL5f (ORCPT ); Mon, 31 Aug 2015 07:57:35 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:35223 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752568AbbHaL5e (ORCPT ); Mon, 31 Aug 2015 07:57:34 -0400 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NTY00FKH3VW9860@mailout1.w1.samsung.com> for linux-media@vger.kernel.org; Mon, 31 Aug 2015 12:57:32 +0100 (BST) X-AuditID: cbfec7f4-f79c56d0000012ee-ed-55e4412c4b4a Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 2D.09.04846.C2144E55; Mon, 31 Aug 2015 12:57:32 +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 <0NTY00HNF3VDZ000@eusync3.samsung.com>; Mon, 31 Aug 2015 12:57:32 +0100 (BST) From: Andrzej Hajda To: Hans Verkuil Cc: linux-media@vger.kernel.org, b.zolnierkie@samsung.com, m.szyprowski@samsung.com, Andrzej Hajda Subject: [PATCH] v4l2-compat-ioctl32: fix alignment for ARM64 Date: Mon, 31 Aug 2015 13:56:15 +0200 Message-id: <1441022175-19725-1-git-send-email-a.hajda@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOJMWRmVeSWpSXmKPExsVy+t/xq7o6jk9CDVq+K1vcWneO1WLjjPWs Fkt+7mKy6NmwldVi7ZG77A6sHlN+b2T16NuyitHj8ya5AOYoLpuU1JzMstQifbsEroz1k6+w FLSJVlxvbWJuYPwq0MXIySEhYCLR0rKOCcIWk7hwbz1bFyMXh5DAUkaJpumzwRJCAk1MEq9v mIHYbAKaEn8332QDsUWA7G/TtzGD2MwCVRK/L09gB7GFBWwlri66ABZnEVCVeHqsHayeV8BZ 4uihK2wQy+QkTh6bzDqBkXsBI8MqRtHU0uSC4qT0XEO94sTc4tK8dL3k/NxNjBDvf9nBuPiY 1SFGAQ5GJR7eD12PQ4VYE8uKK3MPMUpwMCuJ8PIbPgkV4k1JrKxKLcqPLyrNSS0+xCjNwaIk zjt31/sQIYH0xJLU7NTUgtQimCwTB6dUA+Nyi5Cv3NVycYbTRZ5qzvzwW/rwj13eNx9OWnXz 4DyzxWGzYzYZPGTYlvmXfc2hn+cuvwv4u6W86ZF1btLKG49EJ2tPbIh9In71uf7Hx5w3Llrv j4zZ+so6kNPvQsaOoi2BFQd6cr4//B//+dDLu2+LnDYv03lV++KJUempqXJan+z66oWYGye9 VmIpzkg01GIuKk4EAHaZWED6AQAA Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 Alignment/padding rules on AMD64 and ARM64 differs. To allow properly match compatible ioctls on ARM64 kernels without breaking AMD64 some fields should be aligned using compat_s64 type and in one case struct should be unpacked. Signed-off-by: Andrzej Hajda --- Hi Hans, I have tested following structures: struct v4l2_format32 struct v4l2_buffer32 struct v4l2_framebuffer32 struct v4l2_standard32 struct v4l2_input32 struct v4l2_edid32 struct v4l2_ext_controls32 struct v4l2_ext_control32 struct v4l2_event32 struct v4l2_create_buffers32 Following structures should be fixed: v4l2_standard32 - .id alignment v4l2_input32 - whole struct padding v4l2_event32 - .data alignment I hope this patch does it correctly. Regards Andrzej --- drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c index af63543..d309d270 100644 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c @@ -266,7 +266,7 @@ static int put_v4l2_create32(struct v4l2_create_buffers *kp, struct v4l2_create_ struct v4l2_standard32 { __u32 index; - __u32 id[2]; /* __u64 would get the alignment wrong */ + compat_u64 id; __u8 name[24]; struct v4l2_fract frameperiod; /* Frames, not fields */ __u32 framelines; @@ -286,7 +286,7 @@ static int put_v4l2_standard32(struct v4l2_standard *kp, struct v4l2_standard32 { if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_standard32)) || put_user(kp->index, &up->index) || - copy_to_user(up->id, &kp->id, sizeof(__u64)) || + put_user(kp->id, &up->id) || copy_to_user(up->name, kp->name, 24) || copy_to_user(&up->frameperiod, &kp->frameperiod, sizeof(kp->frameperiod)) || put_user(kp->framelines, &up->framelines) || @@ -587,10 +587,10 @@ struct v4l2_input32 { __u32 type; /* Type of input */ __u32 audioset; /* Associated audios (bitfield) */ __u32 tuner; /* Associated tuner */ - v4l2_std_id std; + compat_s64 std; __u32 status; __u32 reserved[4]; -} __attribute__ ((packed)); +}; /* The 64-bit v4l2_input struct has extra padding at the end of the struct. Otherwise it is identical to the 32-bit version. */ @@ -738,6 +738,7 @@ static int put_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext struct v4l2_event32 { __u32 type; union { + compat_s64 value64; __u8 data[64]; } u; __u32 pending;