From nobody Tue Feb 10 02:55:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1585027307; cv=none; d=zohomail.com; s=zohoarc; b=kpIk1aKuR2/KE4OfUMLnMnrnvTIw7YA+MDLVvBtz/CTDFF7BqPK7WSLNUnoJU5CFc4WlkCDF6J6HFBfFTPayknYI6/J+bng8bcEJJhwUSPfQGnw2ZVTkJrabiFMlhmFpTtEwcKuopOn08hNJcYpoNAK+x5Q9O15CHrXSAzRjjKQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585027307; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tcsgzJVTLK54cgncnCOYcMMEi6JDfwZGAAln7+1Uon0=; b=QgDUDu6mgMDoggKv65U/RDsWsdmkiT3R8ljMrGjjuKH6VG7WXSphyzsASPl0AA9GuLDJXuOgGF1XGYMIgrsChdN8FZc7ykC1gJlPFRxOGInOP3Dpfr84MWHOw7vl/MHegtgn2xlsLCYVNc1GSmcbX5BBlyfrLoZvwsRTpmYbkoY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1585027307463328.49616696299734; Mon, 23 Mar 2020 22:21:47 -0700 (PDT) Received: from localhost ([::1]:42974 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jGc0Y-0003nA-9L for importer@patchew.org; Tue, 24 Mar 2020 01:21:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36944) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jGbu8-0004ah-JG for qemu-devel@nongnu.org; Tue, 24 Mar 2020 01:15:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jGbu7-0001dz-1W for qemu-devel@nongnu.org; Tue, 24 Mar 2020 01:15:08 -0400 Received: from bilbo.ozlabs.org ([2401:3900:2:1::2]:36903 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jGbu6-0001Zo-Lw; Tue, 24 Mar 2020 01:15:06 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 48mfZW5ZGqz9sSQ; Tue, 24 Mar 2020 16:14:59 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1585026899; bh=oE4yK1ja4e8fv4EUGbm9wj49lexWi9/2JDgy8C7lmz4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CEXX/vHB2F4mMOI2cOhiXiPuMjmfWTe8ZcYD26XkiFocZnbILC2y0AsOaPBrt6U2K bZ35GRmx53PQ+xe7UDtS1qKCdgzB2qG0Z0KZJZAEr5aDp2ZNcTp9ra1bcZGmT4pFFI R0ZTtJ9Z7YhgkYtQWyJn7TyB3reP+LTKOLFyTPL4= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 4/7] target/ppc: don't byte swap ELFv2 signal handler Date: Tue, 24 Mar 2020 16:14:53 +1100 Message-Id: <20200324051456.256116-5-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200324051456.256116-1-david@gibson.dropbear.id.au> References: <20200324051456.256116-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: aik@ozlabs.ru, Richard Henderson , qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson , Vincent Fazio , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Vincent Fazio Previously, the signal handler would be byte swapped if the target and host CPU used different endianness. This would cause a SIGSEGV when attempting to translate the opcode pointed to by the swapped address. Thread 1 "qemu-ppc64" received signal SIGSEGV, Segmentation fault. 0x00000000600a9257 in ldl_he_p (ptr=3D0x4c2c061000000000) at qemu/include/= qemu/bswap.h:351 351 __builtin_memcpy(&r, ptr, sizeof(r)); #0 0x00000000600a9257 in ldl_he_p (ptr=3D0x4c2c061000000000) at qemu/incl= ude/qemu/bswap.h:351 #1 0x00000000600a92fe in ldl_be_p (ptr=3D0x4c2c061000000000) at qemu/incl= ude/qemu/bswap.h:449 #2 0x00000000600c0790 in translator_ldl_swap at qemu/include/exec/transla= tor.h:201 #3 0x000000006011c1ab in ppc_tr_translate_insn at qemu/target/ppc/transla= te.c:7856 #4 0x000000006005ae70 in translator_loop at qemu/accel/tcg/translator.c:1= 02 The signal handler will be byte swapped as a result of the __get_user() call in sigaction() if it is necessary, no additional swap is required. Signed-off-by: Vincent Fazio Reviewed-by: Laurent Vivier Reviewed-by: Richard Henderson Message-Id: <20200319133244.8818-1-vfazio@xes-inc.com> Signed-off-by: David Gibson --- linux-user/ppc/signal.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/linux-user/ppc/signal.c b/linux-user/ppc/signal.c index 0c4e7ba54c..ecd99736b7 100644 --- a/linux-user/ppc/signal.c +++ b/linux-user/ppc/signal.c @@ -567,10 +567,8 @@ void setup_rt_frame(int sig, struct target_sigaction *= ka, env->nip =3D tswapl(handler->entry); env->gpr[2] =3D tswapl(handler->toc); } else { - /* ELFv2 PPC64 function pointers are entry points, but R12 - * must also be set */ - env->nip =3D tswapl((target_ulong) ka->_sa_handler); - env->gpr[12] =3D env->nip; + /* ELFv2 PPC64 function pointers are entry points. R12 must also b= e set. */ + env->gpr[12] =3D env->nip =3D ka->_sa_handler; } #else env->nip =3D (target_ulong) ka->_sa_handler; --=20 2.25.1