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 5456FC19F2A for ; Thu, 11 Aug 2022 21:42:02 +0000 (UTC) Received: from localhost ([::1]:49912 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oMFwF-0002LA-9v for qemu-devel@archiver.kernel.org; Thu, 11 Aug 2022 17:41:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56244) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oMFt4-0001V1-PQ for qemu-devel@nongnu.org; Thu, 11 Aug 2022 17:38:42 -0400 Received: from mail.freepascal.org ([178.33.235.90]:44738) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oMFsr-0005Fp-Pv for qemu-devel@nongnu.org; Thu, 11 Aug 2022 17:38:41 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.freepascal.org (Postfix) with ESMTP id 231DE1803BC for ; Thu, 11 Aug 2022 21:38:26 +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 2FBUqqIiszX5 for ; Thu, 11 Aug 2022 21:38:26 +0000 (UTC) Received: from [192.168.1.23] (i16-les02-ix2-176-180-129-30.sfr.lns.abo.bbox.fr [176.180.129.30]) by mail.freepascal.org (Postfix) with ESMTPSA id EA27D18038B for ; Thu, 11 Aug 2022 21:38:25 +0000 (UTC) Message-ID: <66112e17-e4ac-59fd-ceaf-56047015918a@freepascal.org> Date: Thu, 11 Aug 2022 23:38:23 +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 Content-Language: fr, en-US From: Pierre Muller To: "qemu-devel@nongnu.org Developers" Subject: [RFC] Unable to use qemu-ppc to run 32-bit powerpc executables generated on gcc110 machine Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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, 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" 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 ---------------- IN: _start 0x3ffda784: 7c230b78 mr r3, r1 0x3ffda788: 38800000 li r4, 0 0x3ffda78c: 3821fff0 addi r1, r1, -0x10 0x3ffda790: 90810000 stw r4, 0(r1) 0x3ffda794: 4bfe756d bl 0x3ffc1d00 ---------------- IN: _dl_start 0x3ffc1d00: 9421fd40 stwu r1, -0x2c0(r1) 0x3ffc1d04: 7c0802a6 mflr r0 0x3ffc1d08: 429f0005 bdnzl 0x3ffc1d0c ---------------- IN: _dl_start 0x3ffc1d0c: 93c102b8 stw r30, 0x2b8(r1) 0x3ffc1d10: 938102b0 stw r28, 0x2b0(r1) 0x3ffc1d14: 92e1029c stw r23, 0x29c(r1) 0x3ffc1d18: 930102a0 stw r24, 0x2a0(r1) 0x3ffc1d1c: 7fc802a6 mflr r30 0x3ffc1d20: 932102a4 stw r25, 0x2a4(r1) 0x3ffc1d24: 934102a8 stw r26, 0x2a8(r1) 0x3ffc1d28: 936102ac stw r27, 0x2ac(r1) 0x3ffc1d2c: 900102c4 stw r0, 0x2c4(r1) 0x3ffc1d30: 93a102b4 stw r29, 0x2b4(r1) 0x3ffc1d34: 93e102bc stw r31, 0x2bc(r1) 0x3ffc1d38: 7c7c1b78 mr r28, r3 0x3ffc1d3c: 3fde0004 addis r30, r30, 4 0x3ffc1d40: 3bded2d0 addi r30, r30, -0x2d30 0x3ffc1d44: 7d4d42a6 mfspr r10, 0x10d 0x3ffc1d48: 7d2c42a6 mfspr r9, 0x10c 0x3ffc1d4c: 7d0d42a6 mfspr r8, 0x10d 0x3ffc1d50: 7c0a4000 cmpw r10, r8 0x3ffc1d54: 4082fff0 bne 0x3ffc1d44 ---------------- IN: _dl_start 0x3ffc1d58: 91410268 stw r10, 0x268(r1) 0x3ffc1d5c: 38e00013 li r7, 0x13 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? Pierre Muller