From patchwork Sun Apr 17 17:43:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 562834 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp1860716map; Sun, 17 Apr 2022 11:05:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzG6+jUDDKYqMq5EIXR4i1iTB5/5DLKtiM3gnfMKogXd6vWNSVA9oiTdD0860c86TlcKJuU X-Received: by 2002:a05:622a:48e:b0:2e0:706f:1d4 with SMTP id p14-20020a05622a048e00b002e0706f01d4mr5042598qtx.326.1650218756555; Sun, 17 Apr 2022 11:05:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650218756; cv=none; d=google.com; s=arc-20160816; b=nE2EtHHyoDkRF9rV885n1UD9yMTVmPx9zcHtyt07w3yxyQG34oLU4KUrrjfqXneBuG BXLVHXQmv1xsj2wVvBKA0avXQNyvyTLkwK+LbNxLh8Yl5xIlnX+8zZnN5gTv1qaiCzAH XfN327rFv6Vc9dVrBXI9aPkdvoPYaxik5n07MgpiQWZfWUYug49/ltMcoDVJmiY6b/bO nbsMMChaIU4ROiKOKr20IAQhvkuh6V0GELb7bx+wcpXQNfM595Usik6ts3CVsrEKFj5a Qeq8LN6bCYkht3O9i2DwaX5hlDs1gFH7dbXJGTu2xUgxwlibxwPi/fFAdFlni/xc4LQ9 Dk6w== 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=S1tmxjtzChOlXlFN2H8r9mWpojIz96JDvEta62yTA5I=; b=Uh/zAC9ANKjtXjhHd5ZmF508b3CmsxHBYtWEAWvhLWU075Q8QXeEqQrkGaHa+nwG5r bbcZlnLpbsnC5JCl/so74u5WnYf+PObg6kg/Nnn2Izvs/a3UTFq+DfOqs0+Ec+JurSSd WSL6DxfHGJUvtVV7xQXAnDnnzM6DpT4kDzIoIaO4joueTPjKSgcqyRPX35nGfq+MFMGa gTfgpKpuF3ciZdHlqTcK9vM2JJb2nSBPf6rZM3Pp0/k6e7Q2W+j5AAWU6WRiGvb7Rp8N i1veejKdpnmf2W6gVPDlYZghbjJrQatCsheURDsjkEtUZDnWByon/xysqmz2P/yCv3u0 m6Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Zne17NRU; 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 bb9-20020a05622a1b0900b002e1fbf3bfdesi2236894qtb.463.2022.04.17.11.05.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 17 Apr 2022 11:05:56 -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=Zne17NRU; 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]:44776 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ng9HY-0006qo-5Q for patch@linaro.org; Sun, 17 Apr 2022 14:05:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48692) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ng8xK-0001KC-AU for qemu-devel@nongnu.org; Sun, 17 Apr 2022 13:45:02 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]:38898) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ng8xG-0003P6-SU for qemu-devel@nongnu.org; Sun, 17 Apr 2022 13:45:01 -0400 Received: by mail-pg1-x535.google.com with SMTP id s137so14960264pgs.5 for ; Sun, 17 Apr 2022 10:44:58 -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=S1tmxjtzChOlXlFN2H8r9mWpojIz96JDvEta62yTA5I=; b=Zne17NRUnh0wV0VRNjlf17bWBhR6aWhrYRfQZQQqXWiJJV446MgEBy89v0vWksqDOG fvaGxpOQViz2x6FcpbsKhcmcAcVBA7zafyDVRH2ISVowbzAvFoySKOzCgc9DDwKwV0R+ NJytjU2kLtiOlny2peLrTeoMovw7IZ+ubG9rtJ6rI/w7Hzk6L4pIuDEYWu2PeV94strA pZ3jt5IpS3Y6hTg0+fU0lIlXqBUBrgm1/xZiO6ldH5HkmRp6F9GT6iJK2t92Te7g137d iLXM35ugMD5K5yt5+DM36gL6ThOH0bo4um5qlKVWvLE4NqpQ5unmM/3Wff603FPPSEWm QsEA== 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=S1tmxjtzChOlXlFN2H8r9mWpojIz96JDvEta62yTA5I=; b=v32OeWQv4TCFe/G/0t3zPHiKba8tRPGhY4Ju202lIerTsAFLWTZlsd//PLLIiyF10N V0utz4J2Df74FIif/ok4lVJD6ghsGrpbs8Hb1dbBNtf39z3OZUtWKFWuogwAgk3qQX8m d92HlVbed+j+LxGK55O/sB3F2aCNpqIxUA6Fe/DZ8waOBLBbuVSBtSZExrQ7UflrO7Ya NW1DcJuYhTgNzGVGKnSOAwJ8G2Q3vnwYfGgqqT2n8nj4NaBtuqvXOeLzj6RK2bTqlQvi x+MYQNrP7+IBqBItWq9fg2DeioBQiLxTC61Or7kGb2zQbstohX4N667e+qwRKdkAEb+U crFA== X-Gm-Message-State: AOAM531z8N3y/KC05NOxIZKJARkogD5PUnmKNsJFsOPOHtEQcLZZKODl p1QSNK8K5G1M1TPohG3Ip1XKKlL6E4vzdw== X-Received: by 2002:a65:614e:0:b0:380:bfd9:d4ea with SMTP id o14-20020a65614e000000b00380bfd9d4eamr7020955pgv.92.1650217497383; Sun, 17 Apr 2022 10:44:57 -0700 (PDT) Received: from localhost.localdomain (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a138200b001cb6512b579sm10372119pja.44.2022.04.17.10.44.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Apr 2022 10:44:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 32/60] target/arm: Update sysreg fields when redirecting for E2H Date: Sun, 17 Apr 2022 10:43:58 -0700 Message-Id: <20220417174426.711829-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220417174426.711829-1-richard.henderson@linaro.org> References: <20220417174426.711829-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::535; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x535.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, T_SCC_BODY_TEXT_LINE=-0.01 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: qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The new_key is always non-zero during redirection, so remove the if. Update opc0 et al from the new key. Signed-off-by: Richard Henderson --- target/arm/helper.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 7c569a569a..aee195400b 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -5915,7 +5915,9 @@ static void define_arm_vh_e2h_redirects_aliases(ARMCPU *cpu) for (i = 0; i < ARRAY_SIZE(aliases); i++) { const struct E2HAlias *a = &aliases[i]; - ARMCPRegInfo *src_reg, *dst_reg; + ARMCPRegInfo *src_reg, *dst_reg, *new_reg; + uint32_t *new_key; + bool ok; if (a->feature && !a->feature(&cpu->isar)) { continue; @@ -5934,19 +5936,28 @@ static void define_arm_vh_e2h_redirects_aliases(ARMCPU *cpu) g_assert(src_reg->opaque == NULL); /* Create alias before redirection so we dup the right data. */ - if (a->new_key) { - ARMCPRegInfo *new_reg = g_memdup(src_reg, sizeof(ARMCPRegInfo)); - uint32_t *new_key = g_memdup(&a->new_key, sizeof(uint32_t)); - bool ok; + new_reg = g_memdup(src_reg, sizeof(ARMCPRegInfo)); + new_key = g_memdup(&a->new_key, sizeof(uint32_t)); - new_reg->name = a->new_name; - new_reg->type |= ARM_CP_ALIAS; - /* Remove PL1/PL0 access, leaving PL2/PL3 R/W in place. */ - new_reg->access &= PL2_RW | PL3_RW; + new_reg->name = a->new_name; + new_reg->type |= ARM_CP_ALIAS; + /* Remove PL1/PL0 access, leaving PL2/PL3 R/W in place. */ + new_reg->access &= PL2_RW; - ok = g_hash_table_insert(cpu->cp_regs, new_key, new_reg); - g_assert(ok); - } +#define E(X, N) \ + ((X & CP_REG_ARM64_SYSREG_##N##_MASK) >> CP_REG_ARM64_SYSREG_##N##_SHIFT) + + /* Update the sysreg fields */ + new_reg->opc0 = E(a->new_key, OP0); + new_reg->opc1 = E(a->new_key, OP1); + new_reg->crn = E(a->new_key, CRN); + new_reg->crm = E(a->new_key, CRM); + new_reg->opc2 = E(a->new_key, OP2); + +#undef E + + ok = g_hash_table_insert(cpu->cp_regs, new_key, new_reg); + g_assert(ok); src_reg->opaque = dst_reg; src_reg->orig_readfn = src_reg->readfn ?: raw_read;