From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ig65G-0007L2-V6 for qemu-devel@nongnu.org; Thu, 11 Oct 2007 18:00:47 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ig65F-0007KK-CJ for qemu-devel@nongnu.org; Thu, 11 Oct 2007 18:00:46 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ig65F-0007KH-8g for qemu-devel@nongnu.org; Thu, 11 Oct 2007 18:00:45 -0400 Received: from bangui.magic.fr ([195.154.194.245]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Ig65E-0004TQ-HD for qemu-devel@nongnu.org; Thu, 11 Oct 2007 18:00:44 -0400 Subject: Re: [Qemu-devel] RFC: fix run of 32 bits Linux executables on 64 bits targets From: "J. Mayer" In-Reply-To: References: <1192002128.9976.186.camel@rapid> <470C8AD9.6000002@bellard.org> <20071010174906.GC3379@networkno.de> <470D1C9A.2000505@bellard.org> Content-Type: text/plain Date: Fri, 12 Oct 2007 00:00:40 +0200 Message-Id: <1192140040.9976.235.camel@rapid> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: blauwirbel@gmail.com On Thu, 2007-10-11 at 22:26 +0300, Blue Swirl wrote: > On 10/10/07, Fabrice Bellard wrote: > > Thiemo Seufer wrote: > > > Fabrice Bellard wrote: > > >> J. Mayer wrote: > > >>> Following the patches done for elfload32, it appeared to me that there > > >>> were still problems that would prevent 32 bits executables to run on 64 > > >>> bits target in linux user mode emulation. > > >>> [...] > > >> Are you sure it is a good idea to try to add 32 bit executable support to a > > >> 64 bit target ? In the end you will need to write a 64 bit to 32 bit linux > > >> syscall converter which would mean duplicating all the linux-user code of > > >> the corresponding 32 bit target (think of ioctls with strutures, signals > > >> frames, etc...). > > > > > > I would think this feature will be limited to platforms which can handle > > > 32bit and 64bit binaries with a single personality. > > > > I am not sure it is a common case ! > > > > However, I suggest to emulate a 32 bit user linux system with a 64 bit > > guest CPU running in 32 bit compatibily mode. It would be useful to test > > 64 bit CPUs in 32 bit compatibility mode. The only required modification > > in linux user is to rename target_ulong so that it can have a different > > size of the CPU word default size. > > I made a patch to rename target_ulong/long to abi_ulong/long and also > add a new emulator target that uses the 32 bit ABI with 64 bit CPU. > > Some Sparc32 binaries run, others don't, possibly indicating bugs in > the Sparc64 emulation! > > The patch is quite large because of the renaming, but this shouldn't > have effect to any other target. Any comments? Great ! The patch seems safe, at first look, then I noticed a few things that are not correct or may be improved: * In linux-user/main.c: PowerPC DCR access should keep using target_ulong. This is a hardware bus, not an ABI dependent stuff. If a 32 bits cast is needed, it would be done in the micro-ops that handle the DCR bus accesses. * in linux-user/qemu.h: why is there still a OVERRIDE_ELF_CLASS variable, when checking TARGET_ABI32 should be sufficient ? It seems to me that having 2 defines which are, in fact, synonymous may be a source of confusion. * in configure: you also added a sparc64-softmmu target, which seems not related with this particular patch. * in configure: why add a specific TARGET_ABI32_DIR variable for that case ? It seems to me that a TARGET_ABI_DIR variable could be useful for all targets. Let me give an example: I want to add a ppcemb-linux-user target, emulating a PowerPC 32 with 64 bits registers and SIMD extensions but I don't want to duplicate the linux-user/ppc subdirectory. Having a TARGET_ABI_DIR available for all targets would solve my problem. In fact, even ppc and ppc64 could be merged... As you need this feature in your case, I think it would be a good idea to add it for all targets. And then, the kludge in Makefile.target could be replaced by: -CPPFLAGS+=-I$(SRC_PATH)/linux-user -I $(SRC_PATH)/linux-user/$(TARGET_ARCH) +CPPFLAGS+=-I$(SRC_PATH)/linux-user -I $(SRC_PATH)/linux-user/$(TARGET_ABI_DIR) which is simpler and easier to understand, imho. -- J. Mayer Never organized