Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755931AbbLQULX (ORCPT ); Thu, 17 Dec 2015 15:11:23 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:50115 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754643AbbLQULV (ORCPT ); Thu, 17 Dec 2015 15:11:21 -0500 From: Arnd Bergmann To: Catalin Marinas Cc: Yury Norov , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, pinskia@gmail.com, Prasun.Kapoor@caviumnetworks.com, schwab@suse.de, broonie@kernel.org, Nathan_Lynch@mentor.com, agraf@suse.de, klimov.linux@gmail.com, Andrew Pinski , jan.dakinevich@gmail.com, Andrew Pinski , ddaney.cavm@gmail.com, bamvor.zhangjian@huawei.com, philipp.tomsich@theobroma-systems.com, joseph@codesourcery.com, christoph.muellner@theobroma-systems.com Subject: Re: [PATCH v6 12/20] arm64:ilp32: add sys_ilp32.c and a separate table (in entry.S) to use it Date: Thu, 17 Dec 2015 21:10:26 +0100 Message-ID: <2105480.kqDuemge8n@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: <20151217182753.GF25232@e104818-lin.cambridge.arm.com> References: <1450215766-14765-1-git-send-email-ynorov@caviumnetworks.com> <1450215766-14765-13-git-send-email-ynorov@caviumnetworks.com> <20151217182753.GF25232@e104818-lin.cambridge.arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:wzAX6ogaEQIxruWe3zOzbs9JLgirpWPrq3EcUBsKeXXUp8A8/8O V7yIgC9i1bv9LiVrHIRa5Qtjmd4ct/5/MtZmMdSM4WBoBnGHtHXoCRmERuUGtd7dEcOEQbZ IgdUpZLLjVEpNw+lGlLKWA9j86G7x0hVTIv2MnUvOslCohrRtLIB67OOD4aw2ivcuGG65Np ePshGidYVhjCNVrpneYbg== X-UI-Out-Filterresults: notjunk:1;V01:K0:QJQ9fXe6ve8=:PaUuWmdnWzFB02k2V4ipeh ht7oWkTWyHpyc9DdQkijs4f8IJfE92gY4G5DEvFMIqOK1lCuBAg6Oo7/R+RPhz7ts90cHgqRt EvyzbWEavN4cOMPnzOLpNGwxpemuYzmykLkK5iupPWLK076PUPeoWhWOhZTgCjtF9mwnIGU+E 1Mm8GIZ3hWVcnGcFK+zKWIg3OLz9nnJhV6Rdc/cfLE3FkJmZNqxZQq9AuNw0kvRGcmcna5qDu OPw1heQPy8UPf6BD2GbiS1CSv+CWlghf01hkUdOEG/8H5ZzY4TNGbQzWtFptPYz+JzPK+pktO btzPs3NkmfJXbI/MMxPyvb56ep/NR2AQgs+KUAxQIjpxCw5T582ZBfxXqSaJUCbGKCp4SPij0 rKDbGnyUU4AHgkgY6bshe9OW3s1LHAtuKZMjjzBvfSAhyypLCVEvI8A/p1EpFf29RYEKcppev orpnFS17zLRuy0yMiReB6x1VcNMhBhwDGHtGuGxwUnmDxMYq4P8nAA3fmXbSTyDzuo6CYJ8Pm mcY0rObMpMkBrYW53mzkL/clgtu2dapv2O3xTK1qJ3HZZPMujuzep2kTmo5tLn3I7vuaTBs1a gYrDIYZqMIGXVztnHcWzwhiMm+XdJ4n5/Hg9SErVPY+fauLwcKWcH7rCNYRjw+zB/faAlDCYJ Y4eu8Slf9N9R28rmLAERPD9ZvcBzZo5Gnin3wrTrHsuZrMHl76JCf360cBvjCY+VHoatb24mD AT21O451rbDrVklN Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2369 Lines: 51 On Thursday 17 December 2015 18:27:53 Catalin Marinas wrote: > On Wed, Dec 16, 2015 at 12:42:38AM +0300, Yury Norov wrote: > > +#define compat_sys_lookup_dcookie sys_lookup_dcookie > > +#define compat_sys_pread64 sys_pread64 > > +#define compat_sys_pwrite64 sys_pwrite64 > > +#define compat_sys_readahead sys_readahead > > +#define compat_sys_shmat sys_shmat > > I wonder whether we need wrappers (actually, not only for these but > sys_read etc.). These functions take either a pointer or a size_t > argument which are 32-bit with ILP32 but treated as 64-bit by an LP64 > kernel. Can we guarantee that user space zeros the top 32-bit of the > arguments passed here? I'm pretty sure that is safe. I haven't read the calling conventions specification for arm64 ilp32, but usually all function arguments are passed as 64-bit registers with proper sign-extend or zero-extend. Most other syscalls rely on this behavior too, not just the ones that are being modified here. > With compat/AArch32, this is guaranteed by the kernel since EL0 won't be > able to touch the top part but here I'm not entirely sure. As long as > user space used Wn registers for 32-bit types, we are probably fine (the > architecture guarantees the top 32-bit zeroing following a MOV, LDR etc. > instruction into a Wn register). We just need to mention this in the ABI > document (ilp32.txt). I think the aarch32 case is actually the hard one, because it has to worry about explicitly sign-extending 32-bit arguments (signed int or signed long) that might be negative, e.g. user space passes -1 as 0xffffffff, which the kernel entry turns into 0x00000000ffffffff when it should use 0xffffffffffffffff. The COMPAT_SYSCALL_DEFINEx macros take care of this. > > + > > +#define compat_sys_open_by_handle_at sys_open_by_handle_at > > +#define compat_sys_openat sys_openat > > So using sys_openat() forces O_LARGEFILE and we don't have a problem > with (f)truncate. We may have an issue with AArch32 compat though. aarch32 uses the correct compat functions in asm/unistd32.h Arnd -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/