Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933377AbcKHMMd (ORCPT ); Tue, 8 Nov 2016 07:12:33 -0500 Received: from mout.kundenserver.de ([212.227.126.130]:51774 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932614AbcKHMM3 (ORCPT ); Tue, 8 Nov 2016 07:12:29 -0500 From: Arnd Bergmann To: linux-arm-kernel@lists.infradead.org Cc: Michael Zoran , gregkh@linuxfoundation.org, stefan.wahren@i2se.com, devel@driverdev.osuosl.org, daniels@collabora.com, swarren@wwwdotorg.org, lee@kernel.org, linux-kernel@vger.kernel.org, eric@anholt.net, noralf@tronnes.org, weiyongjun1@huawei.com, linux-rpi-kernel@lists.infradead.org, popcornmix@gmail.com, bobby.prani@gmail.com Subject: Re: [PATCH] staging: vc04_services: Add 32-bit compatibility ioctls Date: Tue, 08 Nov 2016 13:11:11 +0100 Message-ID: <3832904.LMk9ToHSyP@wuerfel> User-Agent: KMail/5.1.3 (Linux/4.4.0-34-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <20161108004835.7458-1-mzoran@crowfest.net> References: <20161108004835.7458-1-mzoran@crowfest.net> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:ynqSJjDxsgHfXtLoGGRRTzeOKg1+M2/CCkxGoYNRRqfvPcynNb4 0lESV2etYpfYpZCXAOSpCJ1GkDW+DFeco7jEkMYhCVnV82sorshaES5kthwb4hG6leQq+QY N7eCtrsBjA9Vo+IHN5E0qaOLK85/rndpBZ0+YaL7LpOJ0vI3EKMnUe8Hf5PwHpyK0j9uUSl aESYDOEOXKYArOAwR1MkA== X-UI-Out-Filterresults: notjunk:1;V01:K0:DSqu6Tk6hUA=:zD9miBtk5P1A5fBTi4UNk2 vQuJXJRSHvgKUuixRlFcexH6Ln3FYaqE/EKbFGXP7urSQK0ccvodfaSItJF7kVTg9MTzde5oC 9nJR4Ftq2HsDHJYF9r6XZjv8y2hIupdKj1JWe7DqcIMNu3xlirx7g7Ow3i6oDwh3uIwOnahbZ 2oHYtVhfLwlu1SaWLiWslwHLPlf9i4A4fIHDB4qvlOIrjaIomcIgkAWOwELAufwg0RwTeX4l3 QsgyQAgmu0v39ndLGNFQnccPR6nJ0qOfwjdvlxe5b3YE2sq5IAiC1nS5yRd/SvOJ/+Jwm5DB8 km1gJGJbuksVzpqAm53O7Qd4vSZDjA66ntX7y+eBLIki37dmuMX07nRNcCetx47zksjE7Vc3f RZDFA0To5F0wsWEUAgOVknnPXze6t39MahHW2ew1jscoYXhMzbp6ybXfF0FKBFax5lbQz7DN+ Lr65kmuLRmyfAxzW/wU0KbC6noPl1LOMKRjWXBaBlvqDLRUZNRIP08571SZQPug6yIwVewi7P NVbHdfFxYMSscLGX04EdEfd2wG7r5ERrgruspqiPsbvK/cNzAiXcUnZFdONgNbmbVUdE4RjjI SCvIkeimTiC3aRG9FBEpyhE2lxIzQbSTFcmOtPr3Y3+J2ckcwWlmsLNFf09FjZIHlj0mdLSXc YvhBnsbb6Y5WYITMqanR3M1RmdB4iVPO+chuJkKIM5wmlwjRsgb1RqCOgzsVYfl1KXcKwUGrM ZhoKzfEfhAvEiejI Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2626 Lines: 78 On Monday, November 7, 2016 4:48:35 PM CET Michael Zoran wrote: > .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 269 +++++++++++++++++++++ > .../vc04_services/interface/vchiq_arm/vchiq_if.h | 25 ++ > .../interface/vchiq_arm/vchiq_ioctl.h | 102 ++++++++ > 3 files changed, 396 insertions(+) > > diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c > index 8fcd940..df343a0 100644 > --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c > +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c > @@ -573,12 +573,40 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) > "vchiq: could not connect: %d", status); > break; > > +#if defined(CONFIG_64BIT) > + case VCHIQ_IOC_CREATE_SERVICE32: > +#endif > case VCHIQ_IOC_CREATE_SERVICE: { > VCHIQ_CREATE_SERVICE_T args; > USER_SERVICE_T *user_service = NULL; > void *userdata; > int srvstate; > > +#if defined(CONFIG_64BIT) > + if (cmd == VCHIQ_IOC_CREATE_SERVICE32) { Better use CONFIG_COMPAT here. Also, a simple #ifdef is sufficient as neither of those symbols can be a loadable module. Also, just move all the compat handling into the .compat_ioctl callback function and move out the common parts into helpers for simplicity. > +#if defined(CONFIG_64BIT) > + if (cmd == VCHIQ_IOC_AWAIT_COMPLETION32) { > + VCHIQ_AWAIT_COMPLETION32_T args32; > + > + if (copy_from_user(&args32, (const void __user *)arg, > + sizeof(args32)) != 0) { > + ret = -EFAULT; > + break; > + } > + > + args.count = args32.count; > + args.buf = > + (VCHIQ_COMPLETION_DATA_T *)(unsigned long) > + args32.buf; > + args.msgbufsize = args32.msgbufsize; > + args.msgbufcount = args32.msgbufcount; > + args.msgbufs = (void **)(unsigned long)args32.msgbufs; > + } else > +#endif There seems to be a bit of confusion about the address space here. args.buf should be a user space pointer, right? > +#if defined(CONFIG_64BIT) > +typedef struct { > + u32 data; > + unsigned int size; > +} VCHIQ_ELEMENT32_T; > +#endif remove the typedefs, it just forces someone to clean it up later. > #define VCHIQ_IOC_CONNECT _IO(VCHIQ_IOC_MAGIC, 0) > #define VCHIQ_IOC_SHUTDOWN _IO(VCHIQ_IOC_MAGIC, 1) > #define VCHIQ_IOC_CREATE_SERVICE \ > _IOWR(VCHIQ_IOC_MAGIC, 2, VCHIQ_CREATE_SERVICE_T) > +#if defined(CONFIG_64BIT) > +#define VCHIQ_IOC_CREATE_SERVICE32 \ > + _IOWR(VCHIQ_IOC_MAGIC, 2, VCHIQ_CREATE_SERVICE32_T) > +#endif No need for the #ifdef here. Arnd