From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eu-smtp-delivery-151.mimecast.com ([185.58.86.151]:30615 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388658AbhAOUDD (ORCPT ); Fri, 15 Jan 2021 15:03:03 -0500 From: David Laight Subject: RE: [PATCH] Adds a new ioctl32 syscall for backwards compatibility layers Date: Fri, 15 Jan 2021 20:01:15 +0000 Message-ID: References: <20210106064807.253112-1-Sonicadvance1@gmail.com> <20210115070326.294332-1-Sonicadvance1@gmail.com> In-Reply-To: <20210115070326.294332-1-Sonicadvance1@gmail.com> MIME-Version: 1.0 Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT List-ID: To: "'sonicadvance1@gmail.com'" Cc: Richard Henderson , Ivan Kokshaysky , Matt Turner , Russell King , Catalin Marinas , Will Deacon , Tony Luck , Fenghua Yu , Geert Uytterhoeven , Michal Simek , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Yoshinori Sato , Rich Felker , "David S. Miller" , Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "x86@kernel.org" , "H. Peter Anvin" , Chris Zankel , Max Filippov , Alexander Viro , Arnd Bergmann , Andrew Morton , Aleksa Sarai , Xiaoming Ni , David Rientjes , Willem de Bruijn , Christian Brauner , Miklos Szeredi , Minchan Kim , "Eric W. Biederman" , Stephen Rothwell , Vincenzo Frascino , Vlastimil Babka , Oleg Nesterov , YueHaibing , Suren Baghdasaryan , Nicholas Piggin , Brian Gerst , Dominik Brodowski , Jan Kara , Arnaldo Carvalho de Melo , "linux-alpha@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-ia64@vger.kernel.org" , "linux-m68k@lists.linux-m68k.org" , "linux-mips@vger.kernel.org" , "linux-parisc@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "linux-s390@vger.kernel.org" , "linux-sh@vger.kernel.org" , "sparclinux@vger.kernel.org" , "linux-xtensa@linux-xtensa.org" , "linux-fsdevel@vger.kernel.org" , "linux-api@vger.kernel.org" , "linux-arch@vger.kernel.org" From: sonicadvance1@gmail.com > Sent: 15 January 2021 07:03 > Problem presented: > A backwards compatibility layer that allows running x86-64 and x86 > processes inside of an AArch64 process. > - CPU is emulated > - Syscall interface is mostly passthrough > - Some syscalls require patching or emulation depending on behaviour > - Not viable from the emulator design to use an AArch32 host process > You are going to need to add all the x86 compatibility code into your arm64 kernel. This is likely to be different from the 32bit arm compatibility because 64bit items are only aligned on 32bit boundaries. The x86 x32 compatibility will be more like the 32bit arm 'compat' code - I'm pretty sure arm32 64bit aligned 64bit data. You'll then need to remember how the process entered the kernel to work out which compatibility code to invoke. This is what x86 does. It allows a single process to do all three types of system call. Trying to 'patch up' structures outside the kernel, or in the syscall interface code will always cause grief somewhere. The only sane place is in the code that uses the structures. Which, for ioctls, means inside the driver that parses them. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)