Received: by 10.213.65.68 with SMTP id h4csp1018269imn; Sun, 18 Mar 2018 11:07:23 -0700 (PDT) X-Google-Smtp-Source: AG47ELsHTbHfVRjQQaoUmT0EtZ61g4tdpluqd5gs3cOfQBH3g/VkhIsSBd0NXfLranQqBttLthKQ X-Received: by 2002:a17:902:6b82:: with SMTP id p2-v6mr9737786plk.326.1521396443122; Sun, 18 Mar 2018 11:07:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521396443; cv=none; d=google.com; s=arc-20160816; b=BBqHutDFJ1DNKKIbuqQLPnphSi3iihXi+7wYTQfdj39JrIbPsa2P+xBgFLfZlcikKO gz8d6PYZHxqoPy58u/QcNdeJYTkDwoXiZMXUca1uLnHzJmtuuLI+XRius/hu5DCG1N14 5RhzwpxFVPqKFS2umQMTU5fggGGHvSTshxKkPzWUGVaoM0+34LaGTPJ4d6kBYQP2ZN+6 n9BOgRhynUnVP5neyLqepgNAn1KRARt58HP838Hol2bB+Fk9roTYrhPsCabUew5w4YRg zW4pLSbH+bMe0cr4dRhcnoL/t8OHihR07wKXNe64N6BuSSRTZdJ9fFNO7oEXm++KpP9p TYPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=bJHDxKsTyAHJgMnx4c7LdpRBce0YuxR1PgR9BWmOaxs=; b=txex3nFLWhJHl+4Z0I/yKo824NlUJ45Sz8kOhlGBzDr+1SdJlsAqhmAymbLLSPDU4I jPXx6/4HeqYwEDFqWpcvpxmel3nTjRBqBcVReWgAVxHCWNYA3eiRvjJo816XFgU7Wbzf 08c5QhiC5bu/Gfw6GX8xjUVLYZGHOp60olpa7W39w0wNZkH1eW6sVvTTSIMEFBmzea+/ zQdp/F12BEJjhMKhl/c+BovU0AeublcEwOSzCt66tmRclUx3f4F31aauyMkOgXI1DdcQ 3EnXGDVfbvE6NWqu3g3QlAvnug91XfLN2nfQD5LgASTkb25sReJKyBkOnvOaFFO1mEAF sZXg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n9si8397583pge.307.2018.03.18.11.06.57; Sun, 18 Mar 2018 11:07:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754304AbeCRSFV (ORCPT + 99 others); Sun, 18 Mar 2018 14:05:21 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:41114 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754121AbeCRSFS (ORCPT ); Sun, 18 Mar 2018 14:05:18 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.87 #1 (Red Hat Linux)) id 1excgE-0007Zt-RZ; Sun, 18 Mar 2018 18:05:14 +0000 Date: Sun, 18 Mar 2018 18:05:14 +0000 From: Al Viro To: Dominik Brodowski Cc: linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, arnd@arndb.de, linux-arch@vger.kernel.org, Ralf Baechle , James Hogan , linux-mips@linux-mips.org, Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , linuxppc-dev@lists.ozlabs.org, Martin Schwidefsky , Heiko Carstens , linux-s390@vger.kernel.org, "David S . Miller" , sparclinux@vger.kernel.org, Ingo Molnar , Jiri Slaby , x86@kernel.org Subject: Re: [RFC PATCH 3/6] fs: provide generic compat_sys_p{read,write}64() implementations Message-ID: <20180318180514.GT30522@ZenIV.linux.org.uk> References: <20180318161056.5377-1-linux@dominikbrodowski.net> <20180318161056.5377-4-linux@dominikbrodowski.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180318161056.5377-4-linux@dominikbrodowski.net> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Mar 18, 2018 at 05:10:53PM +0100, Dominik Brodowski wrote: > +#ifdef __ARCH_WANT_COMPAT_SYS_PREADWRITE64 > +#if defined(__ARCH_WANT_COMPAT_SYS_WITH_PADDING) && \ > + defined(__ARCH_WANT_LE_COMPAT_SYS) > +COMPAT_SYSCALL_DEFINE6(pread64, unsigned int, fd, char __user *, ubuf, > + u32, count, u32, padding, u32, poslo, u32, poshi) > +#elif defined(__ARCH_WANT_COMPAT_SYS_WITH_PADDING) && \ > + !defined(__ARCH_WANT_LE_COMPAT_SYS) > +COMPAT_SYSCALL_DEFINE6(pread64, unsigned int, fd, char __user *, ubuf, > + u32, count, u32, padding, u32, poshi, u32, poslo) > +#elif !defined(__ARCH_WANT_COMPAT_SYS_WITH_PADDING) && \ > + defined(__ARCH_WANT_LE_COMPAT_SYS) > +COMPAT_SYSCALL_DEFINE5(pread64, unsigned int, fd, char __user *, ubuf, > + u32, count, u32, poslo, u32, poshi) > +#else /* no padding, big endian */ > +COMPAT_SYSCALL_DEFINE5(pread64, unsigned int, fd, char __user *, ubuf, > + u32, count, u32, poshi, u32, poslo) > +#endif > +{ > +#ifdef CONFIG_S390 > + if ((compat_ssize_t) count < 0) > + return -EINVAL; > +#endif /* CONFIG_S390 */ > + return do_pread64(fd, ubuf, count, > + ((loff_t) (unsigned long) (poshi) << 32) | > + (unsigned long) (poslo)); > +} Egads... You have 4 ifdefs before you even get to the body. And good luck trying to actually keep track of that mess. They clearly go in 2 pairs, right? One parameter is "do we have padding" (== does ABI prohibit passing 64bit value in 4th and 5th words), another is the order in which the halves of 64bit are passed. On l-e you have bits 0..31 in the first one and bits 32..63 in the second; on b-e it's the other way round. Only the logics for putting them together into a 64bit value cares which half is which; insisting on the names of form {hi,lo} gives you arseloads of similar variants in ifdefs, all for the sake of not having conditional code in the body. Or, actually, in the inlined helper for building that 64bit out of two halves...