From patchwork Wed Mar 8 13:28:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 660447 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp330462wrb; Wed, 8 Mar 2023 05:35:38 -0800 (PST) X-Google-Smtp-Source: AK7set8rqxzKiTwUozH45kFFn7JF++q8eRjflUJ391OrNED/TJPlJ3j31BdNPNfCQlmp3IOatwCb X-Received: by 2002:a05:622a:44:b0:3bf:d2ed:ace7 with SMTP id y4-20020a05622a004400b003bfd2edace7mr29985075qtw.10.1678282537669; Wed, 08 Mar 2023 05:35:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678282537; cv=none; d=google.com; s=arc-20160816; b=aXDjjSw1vg76UFvuI0d24p2hKHUAtEsGvhcK+Bx4HCbse60Ty+t0XPkbnT3xRW+qZB mf3kPcaUUEr5rQ2G4RiXy1TRoG3ueD/GqSVxfSdxzDjFzh8th7zgHKr3qJ0sqEJ2bXBG JXG17AsQnmckmfLueUc7QQ0hGJHgcF1deQzTwUmlVIhoayMrrIy9RUu/YYhCdpeED46U R8PrsAME/427Uwxbu/WXeSo6fHmI/b+DPxJyQynaQyb07W3XBsP9LtuQYr8Z2F/cg0Vs oegZ+ccqtPPtK3dJJ2jM6GOtZx+gLiWJUDjewUU/pFg5RsGHq3cJWbraA3vtQvdHkzd2 7Uig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:ui-outboundreport :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=/mHzXyYzWR2GV7Jl6jAmZVW5dkD5pUIsZaK+fE3SXus=; b=KM9//NfoKVmHJmxuEi9mrdV4OahCzbbNEu3t2WpsKSyuAZYMWHPhbJcruW8U5Ib4Vj IgnZMrglel8EUKJEs6VQtTSc6dS88OGIJHcMYt/QdFfFJE7d84prwzRQ+3XjDfYQ7Pcs 0EzP/+IftXmO4Qz/41+O6OZle6jFXsN1xvzKT7y65xSIJIVhBkvc1EmJwxPYx2vjtw6x xa7F9JeWZbx84CPSTx0WvzbUpNhWM+GT/JMBWACjYk1KNsmKZKO/0bxDVoYYy2JmrzfX F3rnZCSs4+gM1PhiQTD96hL3Ux55aXmWttcQdATHj6lU9UpYo/dUr6yDRteVizzO4FFq ackA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s12-20020a05622a178c00b003a7e162f83bsi12122698qtk.349.2023.03.08.05.35.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 08 Mar 2023 05:35:37 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZtre-00022u-CE; Wed, 08 Mar 2023 08:29:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZtr6-0001lF-OL for qemu-devel@nongnu.org; Wed, 08 Mar 2023 08:29:23 -0500 Received: from mout.kundenserver.de ([212.227.17.24]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZtr2-00066q-RT for qemu-devel@nongnu.org; Wed, 08 Mar 2023 08:29:20 -0500 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1M894P-1pf8uz0etX-005GcR; Wed, 08 Mar 2023 14:29:10 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Richard Henderson , Laurent Vivier Subject: [PULL 18/28] linux-user/sparc: Fix sparc64_{get, set}_context traps Date: Wed, 8 Mar 2023 14:28:47 +0100 Message-Id: <20230308132857.161793-19-laurent@vivier.eu> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230308132857.161793-1-laurent@vivier.eu> References: <20230308132857.161793-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:m843k0kBoCultNKsgrK6bnXtkmMQGCmOv1QB/g34Sv8iuQMvGRB SWYnF+dnwyE9gBCpMXTCt0nZsJYVWEtXsvWavmh/Xo6pcXdy3vH329cVo6zr/Mc0WqNDrHz kBvSRFlfQlg0Q1w2CznHktStY/EWNRO1RlAWgm4r9pNTGnXslhJKfnXOaxx0Db0qufx4RsJ /wntGnkMEdEDrD5k4SDrA== UI-OutboundReport: notjunk:1;M01:P0:b1LHRQgv+To=;Ptw+EZXMTftM3wPoynduOJOCDc6 yLbXgDbYs4Oye/X7xwtBSbP3qG5/wrCSbwtWGbJwkvTCHeKh/bX41aR5Qh+/3XFLX1Qm45Ysz AeO1UFDCURucmJ8ME0tolMbargEpYwXMy34uLj4xRi2xtKIG/1Z4CyoW99Vhm3qDsTyYl/4R5 3oKRf3RtqimtEW+3mbX/JPGo+7Biaj2CboEl85K0WQ5pn3+eyUDTXjxijJDugs6HhscDU9PuI 9OFDP50ckp6cX0vlm19ybmgQRNZut0j+jxGT5TPZ83Fi/8HdDVMHJQh2JxGts0tv+JK6t77lQ tc7pqRE77gHZbAe/uzhn2Ka4CeKQNqh3O9xFW1AjixEXahz6DwnDE73Xipf/ePhz213xaXTbq Bh9DVhmW3rW70UEDKsUbjkvYjmiWi2BcynT8rcOiM4iomfhRbj+xbkiEmtDUETr8BuCcAxLUM 2F+56GsFcG8O58yagV8eKysoHTDfH0qcWB4s4RYEOBaAJw4ltW850prkPqqzlhDnhlosZNV7g DJihmVhXu+qwAMcoWYTzq/VEVG/AlPtk6116jkk9D5wtTiCqQWzyOGFxlIRy9duSujyv/rzDU xapyPTP6A2vC5zKwd3WQUQSt4SJdgdycD1XOtZU8LnPBqBIvx8eBSBYN7N8YAKK5/lXLVMUGa PzznQpQ7dhWIEruxzzGVacwmeyud9ALCfIOIlTFgMQ== Received-SPF: none client-ip=212.227.17.24; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Richard Henderson These traps are present for sparc64 with ilp32, aka sparc32plus. Enabling them means adjusting the defines over in signal.c, and fixing an incorrect usage of abi_ulong when we really meant the full register, target_ulong. Signed-off-by: Richard Henderson Message-Id: <20230216054516.1267305-7-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/sparc/cpu_loop.c | 21 ++++++++++----------- linux-user/sparc/signal.c | 36 +++++++++++++++++++----------------- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c index 2bcf32590fa1..edbc4f3bdcbf 100644 --- a/linux-user/sparc/cpu_loop.c +++ b/linux-user/sparc/cpu_loop.c @@ -213,25 +213,24 @@ void cpu_loop (CPUSPARCState *env) env->npc = env->npc + 4; break; - case TARGET_TT_SPILL: /* window overflow */ - save_window(env); - break; - case TARGET_TT_FILL: /* window underflow */ - restore_window(env); - break; - #ifdef TARGET_SPARC64 -#ifndef TARGET_ABI32 - case 0x16e: + case TT_TRAP + 0x6e: flush_windows(env); sparc64_get_context(env); break; - case 0x16f: + case TT_TRAP + 0x6f: flush_windows(env); sparc64_set_context(env); break; #endif -#endif + + case TARGET_TT_SPILL: /* window overflow */ + save_window(env); + break; + case TARGET_TT_FILL: /* window underflow */ + restore_window(env); + break; + case EXCP_INTERRUPT: /* just indicate that signals should be handled asap */ break; diff --git a/linux-user/sparc/signal.c b/linux-user/sparc/signal.c index b501750fe0f1..2be9000b9e04 100644 --- a/linux-user/sparc/signal.c +++ b/linux-user/sparc/signal.c @@ -503,7 +503,23 @@ long do_rt_sigreturn(CPUSPARCState *env) return -QEMU_ESIGRETURN; } -#if defined(TARGET_SPARC64) && !defined(TARGET_ABI32) +#ifdef TARGET_ABI32 +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 2 * 8, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + install_sigtramp(tramp, TARGET_NR_sigreturn); + + default_rt_sigreturn = sigtramp_page + 8; + install_sigtramp(tramp + 2, TARGET_NR_rt_sigreturn); + + unlock_user(tramp, sigtramp_page, 2 * 8); +} +#endif + +#ifdef TARGET_SPARC64 #define SPARC_MC_TSTATE 0 #define SPARC_MC_PC 1 #define SPARC_MC_NPC 2 @@ -575,7 +591,7 @@ void sparc64_set_context(CPUSPARCState *env) struct target_ucontext *ucp; target_mc_gregset_t *grp; target_mc_fpu_t *fpup; - abi_ulong pc, npc, tstate; + target_ulong pc, npc, tstate; unsigned int i; unsigned char fenab; @@ -773,18 +789,4 @@ do_sigsegv: unlock_user_struct(ucp, ucp_addr, 1); force_sig(TARGET_SIGSEGV); } -#else -void setup_sigtramp(abi_ulong sigtramp_page) -{ - uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 2 * 8, 0); - assert(tramp != NULL); - - default_sigreturn = sigtramp_page; - install_sigtramp(tramp, TARGET_NR_sigreturn); - - default_rt_sigreturn = sigtramp_page + 8; - install_sigtramp(tramp + 2, TARGET_NR_rt_sigreturn); - - unlock_user(tramp, sigtramp_page, 2 * 8); -} -#endif +#endif /* TARGET_SPARC64 */