From patchwork Thu Oct 27 10:02:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 619182 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp177676pvb; Thu, 27 Oct 2022 03:10:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4ztQvr/lFxjform0/s+kG3s40ziu+CGmkictLn4uNL1BwAqeuiOe2oIyNiE+aSKEeRatpN X-Received: by 2002:a05:620a:1fa:b0:6ee:8d8e:4f5 with SMTP id x26-20020a05620a01fa00b006ee8d8e04f5mr35114167qkn.564.1666865432158; Thu, 27 Oct 2022 03:10:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666865432; cv=none; d=google.com; s=arc-20160816; b=S5mFR3WWT6dWwWaPXlnpakglgxOlxKruaZ5gCwEek87NeOWm2D33o4rQG7qB6C+roh xzKqJyjOQnAyhxPkcf61LUByIFHclleu992LTTvTD2z1+qE5YjBajnJoTLMgQHJZdFt5 +n6lKOvmvhnBkXEdwZWpRZNUCtuUc/+1SWHnOBFVc6qVp8W5WVvkPfywlrjTtSvWfbZX x+xfCcCYfwlUyaHezFR0/7pM+lhdmS2GA9d5kTB09mDuY6zddM6jcd7XC7SplqguK6N8 VtAx99FFXAEMotUU80GHqtEsiAO5RWQS2lUJKiYYU5cDDzE07e7fuJv/pqdm8vT9b9QD tjlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender: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:cc:to :from:dkim-signature; bh=Oz6SbhxWMBqT3eH0LGJA5+0yBaJCELCj9GF6rT/F9o0=; b=oZzQJFzcWThR/t5nw2T6cmbdwGM6zwLVCVsg7by0J6Qi1iwjjWVimaTO6ygKjxlpnn OAb/bKlMCzqTx4Bq7TQHk9DG6PJdFDLPCND4ykIxF23t3Q2v5H0eJUJagqOLgyGksqFG nOB4Ry+wl88577fSnqH1prkHN568+XbgigiKy0Zsef65GkCZDFZ58bfmIAjS1qwnhToU DEhZLW/zZKYnxHKi+YsTBp1J3hFtBYUcKXXvQMimd9QgzjMQl50ELaBfKVWlaSi+HxwR zSuCPjG4qJCpm2luAHGtqFtFXeSj0Btn76JFuYAgf0lJ49dGbi/YYiImfVLFffw8x855 SW6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z6IpPF6Y; 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=pass (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 k5-20020a056214102500b004ac7bf99f76si563852qvr.38.2022.10.27.03.10.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Oct 2022 03:10:32 -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=pass header.i=@linaro.org header.s=google header.b=Z6IpPF6Y; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onzjd-0007pL-62; Thu, 27 Oct 2022 06:03:37 -0400 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 1onzjQ-00078d-DT for qemu-devel@nongnu.org; Thu, 27 Oct 2022 06:03:28 -0400 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onzjO-0004GB-4f for qemu-devel@nongnu.org; Thu, 27 Oct 2022 06:03:23 -0400 Received: by mail-pg1-x530.google.com with SMTP id h185so827529pgc.10 for ; Thu, 27 Oct 2022 03:03:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Oz6SbhxWMBqT3eH0LGJA5+0yBaJCELCj9GF6rT/F9o0=; b=Z6IpPF6YEC3aoReax7k9p+yt6O0jopCUepnfq6j0IY2m9QhiFdxG25MilVlY7fyO1L 2pG7HIxRblOvfXPWX7aGJspS1g1dGagzFsHv64x5CVhz0BfvhJh9tY6i3bvpeEHwtPx9 RmKD5PnnHF9Efs8k4R8krWCXDZfn23W72JUZ36ufTIWi2ioJQgF6HEnGFt3sd59e5EqQ 0RNFPtVI10WE71JEYNoLiZdBN+BbGesPzoKlrjUeDkB3wDmYtLBjIMtRodGpECe9/X4U oixXO+JLFaJ7SlhrRkJZA6sDn3+GkCzg5F9hkDCoY18tyHQyFKsH728T4zD+EVyKpK54 Jp4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Oz6SbhxWMBqT3eH0LGJA5+0yBaJCELCj9GF6rT/F9o0=; b=vMRJPVfgV7BhRie1jTgLfIlHV9nFMLVRp9JNkQrGDjukwdM50g0XldgptBcPiHTuPR jyhu1EZPegM54b87yVXmm35cYdaj4IshombJc+eD6QP97LpxN2Sy/rfVqUhiUNb4/+cQ CIO0Qqi6Qdk/fE2F0i8CzT9hIU+g2mNRBq/EBvrVwCWJ2BCYBvdIlbUo/q7WMW2BpcU2 rXp5IxhtqwZ8p2G5luW933n/N9n8GPbCO02QB+hIYeO87a8mQqq0CKBdWz+yKkk+iVwK F4v0ENe8j99msMRrzXQkEROnG+2WnA3pPlh05LzIsr4bof/l5292k2mMOmBeKNYFea7G TmsA== X-Gm-Message-State: ACrzQf1H74I0i8IK07DKwvJqvv1vWFvKk4l06GmiYV6c3mfwkAZVv3qz 8f5xWuG0aFIKOJw1bGFsrLomQristhEx5kDX X-Received: by 2002:a63:e211:0:b0:43b:f03e:3cc5 with SMTP id q17-20020a63e211000000b0043bf03e3cc5mr41866170pgh.256.1666864999682; Thu, 27 Oct 2022 03:03:19 -0700 (PDT) Received: from localhost.localdomain ([2001:8003:501a:d301:3a91:9408:3918:55a]) by smtp.gmail.com with ESMTPSA id n13-20020a17090a2bcd00b0020a825fc912sm2354631pje.45.2022.10.27.03.03.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 03:03:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: cfontana@suse.de Subject: [PATCH v2 4/6] target/openrisc: Use cpu_unwind_state_data for mfspr Date: Thu, 27 Oct 2022 21:02:52 +1100 Message-Id: <20221027100254.215253-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221027100254.215253-1-richard.henderson@linaro.org> References: <20221027100254.215253-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::530; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x530.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_HELO_NONE=0.001, SPF_PASS=-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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Since we do not plan to exit, use cpu_unwind_state_data and extract exactly the data requested. Signed-off-by: Richard Henderson --- target/openrisc/sys_helper.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c index a3508e421d..dde2fa1623 100644 --- a/target/openrisc/sys_helper.c +++ b/target/openrisc/sys_helper.c @@ -199,6 +199,7 @@ target_ulong HELPER(mfspr)(CPUOpenRISCState *env, target_ulong rd, target_ulong spr) { #ifndef CONFIG_USER_ONLY + uint64_t data[TARGET_INSN_START_WORDS]; MachineState *ms = MACHINE(qdev_get_machine()); OpenRISCCPU *cpu = env_archcpu(env); CPUState *cs = env_cpu(env); @@ -232,14 +233,20 @@ target_ulong HELPER(mfspr)(CPUOpenRISCState *env, target_ulong rd, return env->evbar; case TO_SPR(0, 16): /* NPC (equals PC) */ - cpu_restore_state(cs, GETPC(), false); + if (cpu_unwind_state_data(cs, GETPC(), data)) { + return data[0]; + } return env->pc; case TO_SPR(0, 17): /* SR */ return cpu_get_sr(env); case TO_SPR(0, 18): /* PPC */ - cpu_restore_state(cs, GETPC(), false); + if (cpu_unwind_state_data(cs, GETPC(), data)) { + if (data[1] & 2) { + return data[0] - 4; + } + } return env->ppc; case TO_SPR(0, 32): /* EPCR */