From patchwork Sun Oct 22 05:59:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 736990 Delivered-To: patch@linaro.org Received: by 2002:adf:dd81:0:b0:32d:baff:b0ca with SMTP id x1csp1006170wrl; Sat, 21 Oct 2023 23:14:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGSpBaNA7SQoCp7rGJtBLCS49Iz/Q4JhMEWvF15vU6+SGEawfwMXPk5wNLu0w0g3GvsMfiS X-Received: by 2002:ad4:5a05:0:b0:66d:59a4:a2f3 with SMTP id ei5-20020ad45a05000000b0066d59a4a2f3mr10812827qvb.14.1697955245900; Sat, 21 Oct 2023 23:14:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697955245; cv=none; d=google.com; s=arc-20160816; b=EJu/ZXFHU/KOcW0rfdzzQ3zRJyPJ4cQ1QzOG1QD1H73SJwUHxE5awMuHdoctIi/orN 7f76pCdPDPBUViz3LRcgOwQX/TJ1ooVcmgqAVUfcdwyT5hr1cGUimOe1+P8N5fuuMHMD CsTff8jp6mv9l5FXKO7TYssBfZD7cncrriRLnHtknXcQezDBD/z8EUBXTGcEM8BMe7w0 FAMKBCjyhG0BoUVgCkRQgL78RwPWZSjZliGYHUPI00o0RGN1QocNSLVUvmjD2k8OqxnB MNzOgRjW1fJKeEChZdIhKPvWozS+tAmhYd4jLc+BS67oa+RoafKGULx3DTtnB3yJYJwy F+Nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=qdMramiYwqBa4t1ThcN9BlHwMoxzWRlkGXH/FBRcYbw=; fh=TYrED6TOMxGX0VC4GtjviASLbYyJe19+7/tKWjN44KQ=; b=MZQstv3FW+uT1QiOdxhVpI30p2Z8Z9iY9gcgDMq+vpfsDA7RAMf4mTaDGC9dx10fnn 5fpnJGyJaDV3KgJ3qAnIerTGZlWZEA8Cuz+hQTXLxbD4L/UHXUlu8TQY3+X/gLK7hjgt Jj3KmDS22EQka6vkSeJwnL71LMgQGLiAwJlyVDL+PiYkQ/wgMZm+9z33xhbbc0dD6gqp Xf/HCmPhYXjCJtoKJjgbRaCOfg7MuiaSw0UtW3UcFs1iAJFgNP+mFpz9Fs/xzFCEOIKH QBMPO+P9IRZjOy5i1SNn5qy7XTWfDyVLJB9hoo0IaK5BXWW9fUO2kO5jakcdSFpjfA0i mD+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Swq/ofx6"; 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 p18-20020a05620a057200b00774173d6bb4si3569710qkp.190.2023.10.21.23.14.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 21 Oct 2023 23:14:05 -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="Swq/ofx6"; 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 1quRWQ-0000eB-EM; Sun, 22 Oct 2023 02:01:10 -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 1quRWA-0000Zp-6d for qemu-devel@nongnu.org; Sun, 22 Oct 2023 02:00:56 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1quRW8-0001Zq-CF for qemu-devel@nongnu.org; Sun, 22 Oct 2023 02:00:53 -0400 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1ca74e77aecso23797035ad.1 for ; Sat, 21 Oct 2023 23:00:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697954451; x=1698559251; darn=nongnu.org; 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=qdMramiYwqBa4t1ThcN9BlHwMoxzWRlkGXH/FBRcYbw=; b=Swq/ofx6EPuNND6QV9TI6olAfJN6L3bcxo8hx6e0a814ow4CAZH5WOl3n1nn6KSy8l DgmZDGBsLtwCFNIiLFgDFQHYw9OAmTN2lddxyhAHU8l6N6Cb4FIfTKFSrGGXXcrKstBI yed464rGmJ05tEFWRvNBhrzKto8fqI4akvUnPAfaAVME7RIrGEmL2lIL7/SVrxl5mI0F /Lj/CiJgp7SryItSAFsKJTh/JUVsQZXvj6R1yyT6Uwmmhik8GHgx6Orv6yajPre3IhAp /CKEVKLGU6VkCs2Xe7Hux7CiDl0f4umvXk0Stg9JMv+iLVxjxKUsQCq/8xbF3tECP68K H0sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697954451; x=1698559251; 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=qdMramiYwqBa4t1ThcN9BlHwMoxzWRlkGXH/FBRcYbw=; b=e4EWCxxyutGPWZLtdIvJsdbyokcPZKySA3H2c191pYSTS+kEWn0/qNHg4Eg0UOyasj 18jLbB3eI3U8qbS3CVf+p7wFgwkAxEJTQ2i8TRmPW35cgy81DdkfWyPwT5Ww/2vrdIRM BXkV3BChbE+DeL94IF3JsY8Ojy3O/0fbzMhT/FQjJDRA6r/TWL/1M0PcyRN2I48lzgIU NoMc4RuHM/kPlKW94PkcAYVyeI2IoS13wIdU9/2R8zge/HUOxI4VK0j1LjxOVkMTJivJ kThL3V9G/h96d3L2X1zFaTaqHlhVNlqBQAdCN+U1zw/g9TquXELpaPhgih+XiNeewtjr V3sg== X-Gm-Message-State: AOJu0YyOF7TURc3f1RSi7b2NR4WzWFjYI0UNgsRbolH15ZNrzK7wMGWT vwn37yQrfC372YPui1hdpQ+nv7qjuIHifRR1O7M= X-Received: by 2002:a17:903:32c1:b0:1c7:5776:a30f with SMTP id i1-20020a17090332c100b001c75776a30fmr7696260plr.12.1697954451130; Sat, 21 Oct 2023 23:00:51 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id je17-20020a170903265100b001c728609574sm3999887plb.6.2023.10.21.23.00.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Oct 2023 23:00:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk Subject: [PATCH v4 22/90] target/sparc: Move RDPSR, RDHPR to decodetree Date: Sat, 21 Oct 2023 22:59:23 -0700 Message-Id: <20231022060031.490251-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231022060031.490251-1-richard.henderson@linaro.org> References: <20231022060031.490251-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Implement htstate in the obvious way. Signed-off-by: Richard Henderson --- target/sparc/insns.decode | 10 +++ target/sparc/translate.c | 133 ++++++++++++++++++++++++++------------ 2 files changed, 101 insertions(+), 42 deletions(-) diff --git a/target/sparc/insns.decode b/target/sparc/insns.decode index 1b084c5b97..a7d78eb6c6 100644 --- a/target/sparc/insns.decode +++ b/target/sparc/insns.decode @@ -44,6 +44,16 @@ CALL 01 i:s30 RDY 10 rd:5 101000 rs1:5 0 0000000000000 } +{ + RDPSR 10 rd:5 101001 00000 0 0000000000000 + RDHPR_hpstate 10 rd:5 101001 00000 0 0000000000000 +} +RDHPR_htstate 10 rd:5 101001 00001 0 0000000000000 +RDHPR_hintp 10 rd:5 101001 00011 0 0000000000000 +RDHPR_htba 10 rd:5 101001 00101 0 0000000000000 +RDHPR_hver 10 rd:5 101001 00110 0 0000000000000 +RDHPR_hstick_cmpr 10 rd:5 101001 11111 0 0000000000000 + Tcc_r 10 0 cond:4 111010 rs1:5 0 cc:1 0000000 rs2:5 { # For v7, the entire simm13 field is present, but masked to 7 bits. diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 81de714aa6..ed68b792d4 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -36,7 +36,9 @@ #include "exec/helper-info.c.inc" #undef HELPER_H -#ifndef TARGET_SPARC64 +#ifdef TARGET_SPARC64 +#define gen_helper_rdpsr(D, E) qemu_build_not_reached() +#else #define gen_helper_rdccr(D, E) qemu_build_not_reached() #endif @@ -260,15 +262,14 @@ static void gen_move_Q(DisasContext *dc, unsigned int rd, unsigned int rs) /* moves */ #ifdef CONFIG_USER_ONLY #define supervisor(dc) 0 -#ifdef TARGET_SPARC64 #define hypervisor(dc) 0 -#endif #else #ifdef TARGET_SPARC64 #define hypervisor(dc) (dc->hypervisor) #define supervisor(dc) (dc->supervisor | dc->hypervisor) #else #define supervisor(dc) (dc->supervisor) +#define hypervisor(dc) 0 #endif #endif @@ -3334,6 +3335,93 @@ static TCGv do_rdstrand_status(DisasContext *dc, TCGv dst) TRANS(RDSTRAND_STATUS, HYPV, do_rd_special, true, a->rd, do_rdstrand_status) +static TCGv do_rdpsr(DisasContext *dc, TCGv dst) +{ + update_psr(dc); + gen_helper_rdpsr(dst, tcg_env); + return dst; +} + +TRANS(RDPSR, 32, do_rd_special, supervisor(dc), a->rd, do_rdpsr) + +static TCGv do_rdhpstate(DisasContext *dc, TCGv dst) +{ +#ifdef TARGET_SPARC64 + tcg_gen_ld_i64(dst, tcg_env, offsetof(CPUSPARCState, hpstate)); + return dst; +#else + qemu_build_not_reached(); +#endif +} + +TRANS(RDHPR_hpstate, HYPV, do_rd_special, hypervisor(dc), a->rd, do_rdhpstate) + +static TCGv do_rdhtstate(DisasContext *dc, TCGv dst) +{ +#ifdef TARGET_SPARC64 + TCGv_i32 tl = tcg_temp_new_i32(); + TCGv_ptr tp = tcg_temp_new_ptr(); + + tcg_gen_ld_i32(tl, tcg_env, offsetof(CPUSPARCState, tl)); + tcg_gen_andi_i32(tl, tl, MAXTL_MASK); + tcg_gen_shli_i32(tl, tl, 3); + tcg_gen_ext_i32_ptr(tp, tl); + tcg_gen_add_ptr(tp, tp, tcg_env); + + tcg_gen_ld_i64(dst, tp, offsetof(CPUSPARCState, htstate)); + return dst; +#else + qemu_build_not_reached(); +#endif +} + +TRANS(RDHPR_htstate, HYPV, do_rd_special, hypervisor(dc), a->rd, do_rdhtstate) + +static TCGv do_rdhintp(DisasContext *dc, TCGv dst) +{ +#ifdef TARGET_SPARC64 + return cpu_hintp; +#else + qemu_build_not_reached(); +#endif +} + +TRANS(RDHPR_hintp, HYPV, do_rd_special, hypervisor(dc), a->rd, do_rdhintp) + +static TCGv do_rdhtba(DisasContext *dc, TCGv dst) +{ +#ifdef TARGET_SPARC64 + return cpu_htba; +#else + qemu_build_not_reached(); +#endif +} + +TRANS(RDHPR_htba, HYPV, do_rd_special, hypervisor(dc), a->rd, do_rdhtba) + +static TCGv do_rdhver(DisasContext *dc, TCGv dst) +{ +#ifdef TARGET_SPARC64 + return cpu_hver; +#else + qemu_build_not_reached(); +#endif +} + +TRANS(RDHPR_hver, HYPV, do_rd_special, hypervisor(dc), a->rd, do_rdhver) + +static TCGv do_rdhstick_cmpr(DisasContext *dc, TCGv dst) +{ +#ifdef TARGET_SPARC64 + return cpu_hstick_cmpr; +#else + qemu_build_not_reached(); +#endif +} + +TRANS(RDHPR_hstick_cmpr, HYPV, do_rd_special, hypervisor(dc), a->rd, + do_rdhstick_cmpr) + #define CHECK_IU_FEATURE(dc, FEATURE) \ if (!((dc)->def->features & CPU_FEATURE_ ## FEATURE)) \ goto illegal_insn; @@ -3365,45 +3453,6 @@ static void disas_sparc_legacy(DisasContext *dc, unsigned int insn) TCGv cpu_tmp0 __attribute__((unused)); #if !defined(CONFIG_USER_ONLY) - if (xop == 0x29) { /* rdpsr / UA2005 rdhpr */ -#ifndef TARGET_SPARC64 - if (!supervisor(dc)) { - goto priv_insn; - } - update_psr(dc); - gen_helper_rdpsr(cpu_dst, tcg_env); -#else - CHECK_IU_FEATURE(dc, HYPV); - if (!hypervisor(dc)) - goto priv_insn; - rs1 = GET_FIELD(insn, 13, 17); - switch (rs1) { - case 0: // hpstate - tcg_gen_ld_i64(cpu_dst, tcg_env, - offsetof(CPUSPARCState, hpstate)); - break; - case 1: // htstate - // gen_op_rdhtstate(); - break; - case 3: // hintp - tcg_gen_mov_tl(cpu_dst, cpu_hintp); - break; - case 5: // htba - tcg_gen_mov_tl(cpu_dst, cpu_htba); - break; - case 6: // hver - tcg_gen_mov_tl(cpu_dst, cpu_hver); - break; - case 31: // hstick_cmpr - tcg_gen_mov_tl(cpu_dst, cpu_hstick_cmpr); - break; - default: - goto illegal_insn; - } -#endif - gen_store_gpr(dc, rd, cpu_dst); - break; - } if (xop == 0x2a) { /* rdwim / V9 rdpr */ if (!supervisor(dc)) { goto priv_insn;