From patchwork Thu Jan 6 10:41:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 530351 Delivered-To: patch@linaro.org Received: by 2002:ad5:544f:0:0:0:0:0 with SMTP id a15csp1070288imp; Thu, 6 Jan 2022 03:00:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJw6x3gf9qPBk5f/sQJtft12VPniEElYQ5X5N7mIwJ/ZYODkKN12++SZbqtFMQE1bBVwhT2i X-Received: by 2002:a25:d854:: with SMTP id p81mr65654246ybg.256.1641466824559; Thu, 06 Jan 2022 03:00:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1641466824; cv=none; d=google.com; s=arc-20160816; b=VQ8/9X8TcNI/4ZJqdvAtrLvJs84bZoZ9OImthkHy52H8sFs8dEWQnLHRVuqTzbOXsT 6ED6W0z0XZUbSX4K3qKOjn+jWmZL8W+gtudpoHI4DBALB4qHXL8xK3ado+TiSgFdqwh9 dTdCflCwV4xK6vU6iKwAWBqws7pSrpwIhuz1nlT1bIkvoc7RJGLRBbr1Jgn3d9MkTOKY Hf1uPcDwio27dCH4UoeQkeLR618OqGwRlCGqIyKQAFU+TWpCJOyZThbaAVHppXEVeJnl V2BwmTGeDi7Ut8Hzsp7a6x3cPulaKBzrz82/1A1MoOhkvcvrVrTxHTo4k2mamGZGYT6V uzDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from; bh=GZ7s5xL0hfSZAKqIU3hQDaDCXmJvaJNLD4k5vGEk1Yo=; b=zBx/Fo1UeOT1WAvHRTft9vHw2fhsyM5k1zNSoMWLLOu0G5rLh11IbC5YFLwLORzd6k MniE3gIn2vtUnB/4Pnwgy3oum9eU8rLj2Vlp+MHsqHh+o2mLtKQ2sLPkvWCjS7IGxK+1 1tkBVg/UJsCoUEUuJUKkgCnDcBbvJBSafoacQD/MfYf/ODlonEZ+jVr38iDO/fXRUAeP 2WUUkdYNVBLECqV9Hira4JOggD+xLebxGcYEx/iGh43WryrwQO1bDL5z5pHh4G/AlU7z /03hJPM0t/Ss9KlRNFSDStjVHBVs7mkJAA3e5gnQajOEcA7th5vRavi5k/kCqKgETEL3 ZtlA== 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 o18si1161193ybg.358.2022.01.06.03.00.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Jan 2022 03:00:24 -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]:38502 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5QVM-0006Do-17 for patch@linaro.org; Thu, 06 Jan 2022 06:00:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:32804) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDb-0007qa-Eb for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:42:05 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:36477) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDS-0004k7-9w for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:42:01 -0500 Received: from quad ([82.142.12.178]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MgiPE-1mSoCy1N5I-00h2dv; Thu, 06 Jan 2022 11:41:52 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 21/27] linux-user/nios2: Fix EA vs PC confusion Date: Thu, 6 Jan 2022 11:41:31 +0100 Message-Id: <20220106104137.732883-22-laurent@vivier.eu> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220106104137.732883-1-laurent@vivier.eu> References: <20220106104137.732883-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:fpma7rgrQfMkXeh/gmxujbOIZZ+gON8IEBva0thvttFJabWTRgz AmoD1gUIwMuMBRE9ZqtYOYoMHOvnKy8K0LmMAepdPM2VoIlcc8qOq0s5yDjs9hyPp9H/TjE j2smxwB4W0SdbFH0ntiWcQdJ35t9Dp8k0F07t5S3H9CcqRo84/j6y8iR38ybqzBoI5k9Sts 4EwQeBHT9SbabDo1pQS8Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:Q+38r0NksW0=:1tS/clRubEgF3TQxL3cesn 9krz+O1NahMe+fxec3/9zevP8aXsG7SnyUIKOV7Ccxtsv064ZCmncFfzyYeBma8IKarZh8vW5 oMe8fXjHAbc2wpIfogqYskdK7bzWVPur2w4dWNR5rmLLQdo1KmyvrzaTclQitur+ijbCIJsA2 l8kiE5ZY7IeP5DWu8wAs5Kfsq1SwUTb0XVmUnjW+NqKnRqbzfSRPXnMELRxkDN3Qh0PbPhdvo zAbvAwX/BTZxZxYl8/1B/gA+uqXh/wa+0DWbVfRROu4MwjWFXTB0UW4NIhdWj37GIP25qF5qK T+yffcczYSHEGSmISLi++0RSqVw1JM8FK2fhphaNN4bQpF1wqCHXVCqDxUpZLfNUbhw33X+sW JdybWTAaMkkxeOzftkculPPmQJcruQ/5yjMaKHo8mNOPqHr9OUSuvI0EPkjyXkWFTkEWa4ORV 1fOm91EnPOHWk0+ypNGPETrrMiD++v0N3mIcidu26wQxYlfyZdAvFJyQ7bVVaTWRy1IIvTimu UfGzsJMiwvgkGMIATpwgtc7c2xde81TfWQNEPgRCM6dKqn6OLGLpy3reicuUOct4eh0vwr7CG j3ZIse0Tj7Bc5ACyCuA8lHPn3UnCBFXYvj3FfJruyn8guPfTjE6Zw/zX4svib9Km6cdCLumKc duYNqNdmKWh+H70NRnkIgtLtf5K3X1DG5F0u5kysq2ez1iWSzawnxGIpzXup4VAfo7pg= Received-SPF: none client-ip=212.227.126.134; 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_H5=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson The real kernel will talk about the user PC as EA, because that's where the hardware will have copied it, and where it expects to put it to then use ERET. But qemu does not emulate all of the exception stuff while emulating user-only. Manipulate PC directly. This fixes signal entry and return, and eliminates some slight confusion from target_cpu_copy_regs. Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: <20211221025012.1057923-6-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/nios2/cpu_loop.c | 5 +---- linux-user/nios2/signal.c | 6 +++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/linux-user/nios2/cpu_loop.c b/linux-user/nios2/cpu_loop.c index de0fc63e2196..1e93ef34e649 100644 --- a/linux-user/nios2/cpu_loop.c +++ b/linux-user/nios2/cpu_loop.c @@ -155,9 +155,6 @@ void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs) env->regs[R_SP] = regs->sp; env->regs[R_GP] = regs->gp; env->regs[CR_ESTATUS] = regs->estatus; - env->regs[R_EA] = regs->ea; - /* TODO: unsigned long orig_r7; */ - - /* Emulate eret when starting thread. */ env->regs[R_PC] = regs->ea; + /* TODO: unsigned long orig_r7; */ } diff --git a/linux-user/nios2/signal.c b/linux-user/nios2/signal.c index adbffe32e3c8..20b65aa06e08 100644 --- a/linux-user/nios2/signal.c +++ b/linux-user/nios2/signal.c @@ -73,7 +73,7 @@ static void rt_setup_ucontext(struct target_ucontext *uc, CPUNios2State *env) __put_user(env->regs[R_RA], &gregs[23]); __put_user(env->regs[R_FP], &gregs[24]); __put_user(env->regs[R_GP], &gregs[25]); - __put_user(env->regs[R_EA], &gregs[27]); + __put_user(env->regs[R_PC], &gregs[27]); __put_user(env->regs[R_SP], &gregs[28]); } @@ -122,7 +122,7 @@ static int rt_restore_ucontext(CPUNios2State *env, struct target_ucontext *uc, __get_user(env->regs[R_GP], &gregs[25]); /* Not really necessary no user settable bits */ __get_user(temp, &gregs[26]); - __get_user(env->regs[R_EA], &gregs[27]); + __get_user(env->regs[R_PC], &gregs[27]); __get_user(env->regs[R_RA], &gregs[23]); __get_user(env->regs[R_SP], &gregs[28]); @@ -181,7 +181,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, env->regs[4] = sig; env->regs[5] = frame_addr + offsetof(struct target_rt_sigframe, info); env->regs[6] = frame_addr + offsetof(struct target_rt_sigframe, uc); - env->regs[R_EA] = ka->_sa_handler; + env->regs[R_PC] = ka->_sa_handler; unlock_user_struct(frame, frame_addr, 1); }