From patchwork Fri Oct 1 15:33:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 515043 Delivered-To: patch@linaro.org Received: by 2002:a02:606e:0:0:0:0:0 with SMTP id d46csp915076jaf; Fri, 1 Oct 2021 08:41:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJziVEsuwLt2bGnHaPhym7H2hftTRnxsxgQOpth+Bp/CESThZagFEXTu1/JD5x+ZbcaRYZWa X-Received: by 2002:a67:3388:: with SMTP id z130mr5051822vsz.34.1633102898287; Fri, 01 Oct 2021 08:41:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633102898; cv=none; d=google.com; s=arc-20160816; b=C2aEgAQxpFoxu6IBV/5lrlnz4qgCOua1waQhQlJMy3Lz+cfjJfvmpuev+yPnJ4wL1W QMqAFokwQcdrVgNVW7rDT3WKzK3Zla97DR1/qgf+pEXc9djfChVm4ApOMbC3Ryx28TiD 5fBFVpu+1qq/adY91BwJrSD0OtfkROA1sdBDgJ17/GnvRvovdaCqPP/a/j9r7SQWYC9c E4lDL20Env360vNsSK4uFZA49Z4wkqeV5xhFFnT7oW+i2AW2JJTbmmUCgUStels38pV4 6LKJ5Qs2S3+tJan226PqJq3eo42uvuu2rSTkLdd0DQs68noou/h4C4dx6o6Ev10YCxSU mJqA== 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 :dkim-signature; bh=F9yEwPrmR9xpxjbUMZcvWlIm4BrVKkXnEjUbM9qs6VM=; b=rGRGUzNlHAhiRSKfCXeqHS7WKO1mp1c3BOKddpkVH7etQTO0BPrXs7a1HrZGicgjVo Xb00DLSv8IFZ+elRojWyrv+aUAywgreoQHsOISQ3U+0m9BqLnpMmB+DfzWYMSuwLGFJ+ HjBGwdYOFZUjVIXNSNvy3uHImnx6bsi/Gvy4SkbzS5Mfh19msQYk29IChbN5hTjdkQPZ S1MogHoyfTK/erLt+uZIdHC4zmhLdqTtTk/63/CC6XFyn5glOtct3QdkzJaOz2/PZ5r/ Iaw497pDyPKPf6FrIHpJIYfg1stj5zMfgstquzUgWUZcMxnSyAGP7sebMt2p1h3hBDrZ aUpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=o5YqmOZ8; 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"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h22si6462756vsu.215.2021.10.01.08.41.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Oct 2021 08:41:38 -0700 (PDT) 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; dkim=fail header.i=@linaro.org header.s=google header.b=o5YqmOZ8; 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"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:52170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWKfJ-0001KB-IV for patch@linaro.org; Fri, 01 Oct 2021 11:41:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33820) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWKY1-0006fM-LT for qemu-devel@nongnu.org; Fri, 01 Oct 2021 11:34:05 -0400 Received: from mail-qk1-x72a.google.com ([2607:f8b0:4864:20::72a]:41945) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWKXt-0007k7-Lu for qemu-devel@nongnu.org; Fri, 01 Oct 2021 11:34:05 -0400 Received: by mail-qk1-x72a.google.com with SMTP id m7so9492388qke.8 for ; Fri, 01 Oct 2021 08:33:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=F9yEwPrmR9xpxjbUMZcvWlIm4BrVKkXnEjUbM9qs6VM=; b=o5YqmOZ8FQBpCsn3z4vAOehwAN/laf9MPTJhYFBaERaLSGNW5YWCYzLnKFmjDVJBpY nhDH4Pu1UY+3kJS8mpObw5e8sfY9wSKtnW+Nilgr+M7wVFAqjXhaaoLgnN+gV703rkPw uaSDs9KpDJ1b8X4dkMUnhB9snJKW4Z7NPgvb4cjUfr6UgvcfxZ5vJhS6lqA8bI/iVzLw BJGTkZt2tHPkYoW2Iupse/ws8qDhQKvkBz9MLwXp1abzRblh44nwp1RpI3rBnQVidhAf 0RSM/OJ4+qWhN9zLTEJcrTblQry22ni/xKp/jdZfMXTuFeaz6r4CQxQBywU9R5RzrS82 gjRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=F9yEwPrmR9xpxjbUMZcvWlIm4BrVKkXnEjUbM9qs6VM=; b=NSO9LaACfSIX2rYiq+BZXVR+4BI8O5gYfUF/zfysxdiEdEY8L+KIAIjctTXTmqeDdf 1MSoC1Zrq7DxcfLTQcl5y9SU0zCCSId/jxhPFjXIrxPRvB1vrYIh6adNKKsZPUeS4nP2 refU1DAzTy992inZd4vbdYTZOiJAoaOJVsY+yf8rxva0s4I3Z/ETLax3ssrzvYwYWwi2 evoEGnkIw5piNwg45OBnO8u0W6aU5F4Qwf373a8UpG/knCFihvR+N6pi5odlMrk95RWX dFnbWEnqYrz7sSjQSXiBmPlShEWK5DIh0xe9FYu5UE4wcrJiOzXKupdF9c52I8orTj0N coiw== X-Gm-Message-State: AOAM530Fkti5a5nBgaiTGimFYlLIcaptz90NK4VE34zTChSunCDhGWOg zlLbyuCQ+vKwGjsfZ0AN9YSWkBUo9hxXlw== X-Received: by 2002:a37:a20a:: with SMTP id l10mr10193543qke.273.1633102436730; Fri, 01 Oct 2021 08:33:56 -0700 (PDT) Received: from localhost.localdomain (c-67-174-166-185.hsd1.ga.comcast.net. [67.174.166.185]) by smtp.gmail.com with ESMTPSA id x8sm3484823qtv.5.2021.10.01.08.33.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 08:33:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 6/9] linux-user/nios2: Fix EA vs PC confusion Date: Fri, 1 Oct 2021 11:33:44 -0400 Message-Id: <20211001153347.1736014-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211001153347.1736014-1-richard.henderson@linaro.org> References: <20211001153347.1736014-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::72a; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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: marex@denx.de, crwulff@gmail.com, alex.bennee@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- linux-user/nios2/cpu_loop.c | 5 +---- linux-user/nios2/signal.c | 6 +++--- 2 files changed, 4 insertions(+), 7 deletions(-) -- 2.25.1 diff --git a/linux-user/nios2/cpu_loop.c b/linux-user/nios2/cpu_loop.c index de0fc63e21..1e93ef34e6 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 adbffe32e3..20b65aa06e 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); }