Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6B637C00140 for ; Fri, 12 Aug 2022 07:08:23 +0000 (UTC) Received: from localhost ([::1]:38618 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oMOmL-0002IQ-Of for qemu-devel@archiver.kernel.org; Fri, 12 Aug 2022 03:08:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43896) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oMOhY-0000zf-3v for qemu-devel@nongnu.org; Fri, 12 Aug 2022 03:03:28 -0400 Received: from mail.freepascal.org ([178.33.235.90]:59318) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oMOhU-0000M6-I3 for qemu-devel@nongnu.org; Fri, 12 Aug 2022 03:03:22 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.freepascal.org (Postfix) with ESMTP id 03400180312; Fri, 12 Aug 2022 07:03:19 +0000 (UTC) Received: from mail.freepascal.org ([127.0.0.1]) by localhost (idefixng.freepascal.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RBQldX8s9RPw; Fri, 12 Aug 2022 07:03:18 +0000 (UTC) Received: from [192.168.50.107] (gw-ics.u-strasbg.fr [130.79.210.225]) by mail.freepascal.org (Postfix) with ESMTPSA id BCA97180310; Fri, 12 Aug 2022 07:03:18 +0000 (UTC) Message-ID: <1f4c81d1-7127-6441-2435-cfd2aa557550@freepascal.org> Date: Fri, 12 Aug 2022 09:03:16 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.1.2 Subject: Re: [RFC] Unable to use qemu-ppc to run 32-bit powerpc executables generated on gcc110 machine Content-Language: fr, en-US To: Thomas Huth , "qemu-devel@nongnu.org Developers" References: <66112e17-e4ac-59fd-ceaf-56047015918a@freepascal.org> <9d24dd87-782f-ab15-9d48-51653801cee0@redhat.com> From: Pierre Muller In-Reply-To: <9d24dd87-782f-ab15-9d48-51653801cee0@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=178.33.235.90; envelope-from=pierre@freepascal.org; helo=mail.freepascal.org X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, NICE_REPLY_A=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Pierre Muller Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Le 12/08/2022 à 06:16, Thomas Huth a écrit : > On 11/08/2022 23.38, Pierre Muller wrote: >> >>   I am using qemu to check code generated by Free Pascal compiler >> for various CPUs. >> >>   Recently, this allowed me to find out that Free Pascal was generating >> wrong instructions, leading to SIGBUS errors using qemu-mips. >>   The same binaries worked without troubles on mips test machines, >> probably because SIGBUS is handled directly inside the kernel. >> >>   Here I would like to report the problem I get when trying to run >> powerpc executables using shared libs generated on gcc110 machine. >> >>   I copied over the needed libraries into a sys-root directory. >> >>   The problem is that the code crashes with a Illegal Instruction >> after only a very few instructions: >> >> muller@gcc186:~/pas/check$ ~/sys-root/bin/qemu-ppc -cpu g2 -d in_asm -L >> ~/sys-root/powerpc-linux ./twide1 > [...] >> 0x3ffc1d60:  f00004d7  xxlxor   v0, v0, v0 >> >> qemu: uncaught target signal 4 (Illegal instruction) - core dumped >> >> The problem is the the 'xxlxor' instruction is a VSX extension instruction. >> >>  There is apparently no cpu in the powerpc cpu list that enabled this >> extension. >> The output of cat /proc/cpuinfo on gcc110 gives that: >> ..... >> processor       : 63 >> cpu             : POWER7 (architected), altivec supported >> clock           : 3550.000000MHz >> revision        : 2.1 (pvr 003f 0201) >> >> timebase        : 512000000 >> platform        : pSeries >> model           : IBM,8231-E2B >> machine         : CHRP IBM,8231-E2B >> >>   Is there a way to enable cpu features separately for ppc like is done for >> x86_64? >> Or would it be possible to define a new cpu inside qemu source that would match >> the description above? > > So you are building on a POWER7 host and try to run the binaries on an > emulated G2? That sounds weird. Why don't you use The g2 was just an example, I used a script to iterate over all possible cpus (as listed by --cpu help), but I always get a Illegal instruction on xllxor, because none of the cpu in the least seems to enable VSX extension. > qemu-ppc64 -cpu power7 ... Because I am interested in testing 32-bit ELF binaries: muller@gcc186:~/pas/check$ file ./twide1 ./twide1: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), dynamically linked, interpreter /lib/ld.so.1, stripped muller@gcc186:~/pas/check$ qemu-ppc64 -cpu power7 ./twide1 -bash: qemu-ppc64: command not found muller@gcc186:~/pas/check$ ~/sys-root/bin/qemu-ppc64 -cpu power7 ./twide1 qemu-ppc64: ./twide1: Invalid ELF image for this architecture muller@gcc186:~/pas/check$ ~/sys-root/bin/qemu-ppc64 --version qemu-ppc64 version 7.0.0 Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers muller@gcc186:~/pas/check$ ~/gnu/qemu/build-qemu-7.1.0-rc2/qemu-ppc64 -cpu power7 ./twide1 qemu-ppc64: ./twide1: Invalid ELF image for this architecture So qemu-ppc64 (7.0.0 and 7.1.0-rc2) is only able to run 64-bit binaries. Pierre