From patchwork Sun Mar 14 17:59:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 400099 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp2835446jai; Sun, 14 Mar 2021 11:07:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+7KfENi08hAtj37i0AUyg7YHQO4XtLtF6ymVM3pb96bdGH2yRP+uUyXeePCLJTwSOE36f X-Received: by 2002:a05:6e02:178e:: with SMTP id y14mr4322589ilu.175.1615745244985; Sun, 14 Mar 2021 11:07:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615745244; cv=none; d=google.com; s=arc-20160816; b=TvVaaLhQb/rHWrzCyQLEMjcSYwUaDRnecDl3xm5SQBeQxLjqeEYZnOPtPrLDqRjT0d YbcFMURyDLCh0tMkLOQK1qf8G3q3+OLIqkc4+sgaWeggQ3WdXD/+pSS16DRT1W0QfhUr Ia5yU0TfY6JFqyzM/rbRHqWBjIUJWlZfunz5UJ1agZ5eM8oigsfYK/RMpLDmtaOB1u9Q ZgBTaSLtr43xPlFeclt/FRBPyhAzjL1WRbefz5AX7wUO4NN6mpKrpTzDo3kgViFpYDSN b0W9by/yKsflCLe33CJQAtMK7M+X1FOyXcmKQMIcAzlYaJluR+zTGg7JEFnj9Y5kN5je oPJg== 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=nDEzeJHZqdUXe/dXYq7qR5PEy35VBqTIPDXHrdEdgcc=; b=dM+Sja0ZEQuImY0hD/qD9JZYmWumxrbWKE7JTWZ7JXT3BumXrjbKhN9iKALtnI6Yz4 x6KHQlKYz4xve/Nv3uYyH27Ik2lAtnOnPlfp55Q0VaEMJDKsiOJlYmYFwr5vmo7JxDPw D2K5Ubpub16leF0k1PTDJEXHrPUNuR0iP350A3P328rkzWZBkREMTZXE4yY55SbXaTwJ AvC0Gvb/kWqjhoUFDxtsbRuEviRxOkfvWwBeSI5LOHbT0/Qoha99v5FWxk/1EvqRfrjo Ukzw9GzrqP8vrMoeRWLhsaeTFpK+rwYoignBCtVw8HdJ8SHo/t49VJyuGA9q/XqjV30U WF9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=g7cYJVkb; 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 i6si9748161ilq.158.2021.03.14.11.07.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 14 Mar 2021 11:07:24 -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=g7cYJVkb; 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]:47674 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lLV9A-00076E-Et for patch@linaro.org; Sun, 14 Mar 2021 14:07:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48696) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lLV1c-0002WC-66 for qemu-devel@nongnu.org; Sun, 14 Mar 2021 13:59:36 -0400 Received: from mail-qk1-x736.google.com ([2607:f8b0:4864:20::736]:39194) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lLV1S-0002AA-T2 for qemu-devel@nongnu.org; Sun, 14 Mar 2021 13:59:35 -0400 Received: by mail-qk1-x736.google.com with SMTP id g185so29587728qkf.6 for ; Sun, 14 Mar 2021 10:59:21 -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=nDEzeJHZqdUXe/dXYq7qR5PEy35VBqTIPDXHrdEdgcc=; b=g7cYJVkbLThk/h2k9vtKEGK6c1ZrtHalidEAN5DgdaL9D4L8hZETV3bt1Bc3Qgf2iQ w8Ik2CZnwRKuJRTCl8BF1mjcxXYXm3WUDxogGZPMLTPZnxS2mQ4pIFQ5CNjj0mo8/i6E ddL7xISa/saEQdD98k8ZR9kwb6Cp3nim++XgsEGgA0d9ZEvtWo8mUCDt3wLMyPLY2+BI uEUI15mLlxl7enh/WRwWx2bvgdGKiDUNmGWRvzm9qrN0iuzfKzFYHcnX7I1d6tuaB838 mlg5B2hIVi3jJd5eEBcHcXAvrUiiteMrSww2+8GkdWoOAlJtBWgkxwoXR4WhwF1MT/yz BzRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nDEzeJHZqdUXe/dXYq7qR5PEy35VBqTIPDXHrdEdgcc=; b=BMwfirZ8R45tidtdEoaWythgdcsYtzUPIy+/Z0UofAVzQdcYX5r9jnOl0lKGVcRbXm ovNGqwi6npexdvgHxU1O0J4rtL1VX0WIRMArIDWFOAhFJnIdQ0CzPVYsJ7xdWWqm70Gr DM1nBja4bTJbF7DIcowtuoWW2AI5e4xI6l0UKmAPPAoypBEzZCU5+bKhSEbJyVHkataf m7+UcseypjO/8Wg7EINSnkt/tve0n3fdkefD11bf4PZ6zj32dh7fc/s4ePtVhhhMkhQF K8/XMElYzZoB8GRRBLzQy4vge+mfm3Oy33zUt4KDEgrhHYKmtDYzZA88BUoWQwUdVdx1 zLRA== X-Gm-Message-State: AOAM530i6f2T+8yhpKeuPbf+FIZoJpMw6hU4lgnBnxSQ6HFhNmauoeW1 sp/boeNUvu+CC+U65pIPu1RINpckBZPZGRJM X-Received: by 2002:a37:bc45:: with SMTP id m66mr22349615qkf.82.1615744760600; Sun, 14 Mar 2021 10:59:20 -0700 (PDT) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id c127sm10216240qkd.87.2021.03.14.10.59.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Mar 2021 10:59:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 10/16] target/ppc: Create helper_scv Date: Sun, 14 Mar 2021 11:59:00 -0600 Message-Id: <20210314175906.1733746-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210314175906.1733746-1-richard.henderson@linaro.org> References: <20210314175906.1733746-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::736; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x736.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=unavailable 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: ivan@vmfacility.fr, qemu-ppc@nongnu.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Perform the test against FSCR_SCV at runtime, in the helper. This means we can remove the incorrect set against SCV in ppc_tr_init_disas_context and do not need to add an HFLAGS bit. Signed-off-by: Richard Henderson --- target/ppc/helper.h | 1 + target/ppc/excp_helper.c | 9 +++++++++ target/ppc/translate.c | 20 +++++++------------- 3 files changed, 17 insertions(+), 13 deletions(-) -- 2.25.1 diff --git a/target/ppc/helper.h b/target/ppc/helper.h index 6a4dccf70c..513066d54d 100644 --- a/target/ppc/helper.h +++ b/target/ppc/helper.h @@ -13,6 +13,7 @@ DEF_HELPER_1(rfci, void, env) DEF_HELPER_1(rfdi, void, env) DEF_HELPER_1(rfmci, void, env) #if defined(TARGET_PPC64) +DEF_HELPER_2(scv, noreturn, env, i32) DEF_HELPER_2(pminsn, void, env, i32) DEF_HELPER_1(rfid, void, env) DEF_HELPER_1(rfscv, void, env) diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index 85de7e6c90..5c95e0c103 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -1130,6 +1130,15 @@ void helper_store_msr(CPUPPCState *env, target_ulong val) } #if defined(TARGET_PPC64) +void helper_scv(CPUPPCState *env, uint32_t lev) +{ + if (env->spr[SPR_FSCR] & (1ull << FSCR_SCV)) { + raise_exception_err(env, POWERPC_EXCP_SYSCALL_VECTORED, lev); + } else { + raise_exception_err(env, POWERPC_EXCP_FU, FSCR_IC_SCV); + } +} + void helper_pminsn(CPUPPCState *env, powerpc_pm_insn_t insn) { CPUState *cs; diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 7912495f28..d48c554290 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -173,7 +173,6 @@ struct DisasContext { bool vsx_enabled; bool spe_enabled; bool tm_enabled; - bool scv_enabled; bool gtse; ppc_spr_t *spr_cb; /* Needed to check rights for mfspr/mtspr */ int singlestep_enabled; @@ -4081,15 +4080,16 @@ static void gen_sc(DisasContext *ctx) #if !defined(CONFIG_USER_ONLY) static void gen_scv(DisasContext *ctx) { - uint32_t lev; + uint32_t lev = (ctx->opcode >> 5) & 0x7F; - if (unlikely(!ctx->scv_enabled)) { - gen_exception_err(ctx, POWERPC_EXCP_FU, FSCR_IC_SCV); - return; + /* Set the PC back to the faulting instruction. */ + if (ctx->exception == POWERPC_EXCP_NONE) { + gen_update_nip(ctx, ctx->base.pc_next - 4); } + gen_helper_scv(cpu_env, tcg_constant_i32(lev)); - lev = (ctx->opcode >> 5) & 0x7F; - gen_exception_err(ctx, POWERPC_SYSCALL_VECTORED, lev); + /* This need not be exact, just not POWERPC_EXCP_NONE */ + ctx->exception = POWERPC_SYSCALL_VECTORED; } #endif #endif @@ -7907,12 +7907,6 @@ static void ppc_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) ctx->spe_enabled = (hflags >> HFLAGS_SPE) & 1; ctx->altivec_enabled = (hflags >> HFLAGS_VR) & 1; ctx->vsx_enabled = (hflags >> HFLAGS_VSX) & 1; - if ((env->flags & POWERPC_FLAG_SCV) - && (env->spr[SPR_FSCR] & (1ull << FSCR_SCV))) { - ctx->scv_enabled = true; - } else { - ctx->scv_enabled = false; - } ctx->tm_enabled = (hflags >> HFLAGS_TM) & 1; ctx->gtse = !!(env->spr[SPR_LPCR] & LPCR_GTSE);