From patchwork Thu Oct 26 00:14:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 738220 Delivered-To: patch@linaro.org Received: by 2002:adf:f842:0:b0:32d:baff:b0ca with SMTP id d2csp554646wrq; Wed, 25 Oct 2023 17:24:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHgPO+SnmLpmmq39UObNoZ7sbVD1oNf596wskWf4CRCsskBdYY0/eAb5gRxL/K/8XmSZ8pp X-Received: by 2002:a5d:4652:0:b0:32d:b051:9a2a with SMTP id j18-20020a5d4652000000b0032db0519a2amr11904176wrs.63.1698279886471; Wed, 25 Oct 2023 17:24:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698279886; cv=none; d=google.com; s=arc-20160816; b=RO+vwZQ6dpP1GwiKUtbDgaU6FNr6hSCsZg2YofQ5I8YGqOudVF/FLDNStKMPxvRkV/ ytvXqWlf+kuNUTbnQL9XWFeQl4QX5h68ztnhAoOpTNsi2Q1BjhOSf9GfqJZQ0TK5N48M pmD23OlFO2U+dRpGxmsUMJJPk/DKaOKGVkcZLHOQS6V5O+t98y567R/3qUvr3o6lKUPn aFkH2BO8ap9uxAKkQDTiVee7GCfQDEheNI7SHGoJx25WwadBe29c+WgvMkdaHJnufTfl YUf3i5q5Y1GK/mO1GfBfC3nMtA7NQEujEcT2Qdc1lYVBM9G944WRl5CksnB9pfjnRxIJ zO0g== 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=IRKpWuzD73nLvUgHfXSktD82HmfIC39HF668MZpjq5M=; fh=rYI8DiHAAFX3O5g969KmOAQ7d45Sb8OxQX1+DywGDk4=; b=rSflgEvKufXFhDrvAuz8B7oI3+fLmoaMy7Z1wAdIS91eHzKL+6i9BD3P6+ok9WFSHW xR0LcOJiS6jo2eOfoFcVFvhGSc+kQgL0L2IXfiKNxk+M205HaSD5Ey460a26/lqV7Myb /fljkpWGPxML6Ome+dJBDsyf7VkqiFQgIW3VvJcDuqPt0JrEZK+pjy+0PhYajesPWsmo O7VJCzfj9XGpNCMZGB7mRrlc0Cllj4+Hp0WzJqc9C4Qvy8xCahygaKPKpBSZoKGbB5sh WcqdtV7WSCv9a2eBJyTA/sbYxI09KMNjDbRoWuzL9tbAq7OiHrY1wrTjgu6LQihonN6E 0+Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a9okAxE7; 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 k8-20020adfe3c8000000b0032d9a2612e0si8347643wrm.538.2023.10.25.17.24.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Oct 2023 17:24:46 -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=a9okAxE7; 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 1qvo6e-000261-8p; Wed, 25 Oct 2023 20:20:12 -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 1qvo6E-00013a-A8 for qemu-devel@nongnu.org; Wed, 25 Oct 2023 20:19:46 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qvo62-0006dP-6n for qemu-devel@nongnu.org; Wed, 25 Oct 2023 20:19:44 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1caad0bcc95so2219265ad.0 for ; Wed, 25 Oct 2023 17:19:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698279572; x=1698884372; 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=IRKpWuzD73nLvUgHfXSktD82HmfIC39HF668MZpjq5M=; b=a9okAxE7NNTwnJTd/84QZDiZsy4ar1bPwOIhM4LV86FVlgxNeyw2cf3Ti7fIll0+sc EoF+k/mYSl0e2bCqZBwhikq33DupW693VOH5m1Wfs5HIzGKYN+CvCDGP2qO53aLmzOc4 //BYeuDJtq6Jh1U9kdGPwLfNSttw5E/mplAgJivvanl1KFEEaHmHbvpf9YBzQbvWSO4I AjKm+SHX56CEMq7ga1qVTwQ6KHmGjpWoC0ElR0b9kVB7xNoHNhLl+UdIbopEGejOu7dH sPszECaXR05b5mJCWEeforVEG+biBN5rTcZwqs1YYHdB7DguIEDfYVXgg/bWOsGhY5e+ +ngg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698279572; x=1698884372; 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=IRKpWuzD73nLvUgHfXSktD82HmfIC39HF668MZpjq5M=; b=L7+EHZGNu+El8/KSaYrhRA/bYqozzkxR31euGH+Mf6sywQ6dBP6C21XXKj7C4dGTys xe5NdZX/HpqN49RuFNLTJw8kQDy9u3+ifGY31L2FD0ZgByD/GUINQY2SDkWOgc09Xl6C GnI84gIJxW5HjDja9rbbVyNMZe410J7vVjtEDYv6tp8cV5pmdv3PK4EaixATQR11DsY9 QIng79wTKCEHgY1ialZBxR7VXUef8NXy4w7FA11LLhb09cCl40gwy7KAhhP4r9y42+gF nwRsnWMJw2rzTocSknd7fnVcAUzZHFOIK/oUnSqhUBNhkOvcm1EdN1Oi6Ht040glQcMr WAuw== X-Gm-Message-State: AOJu0Yx9WTvZiwaWW1BjkuFjEBggOft+4ZkXopos23DyFfDYy7x0sBie R2SbXlJMlIplhRHYS+wvOE2B2AjAFmpRnDqHFJU= X-Received: by 2002:a17:903:2291:b0:1c0:a5c9:e072 with SMTP id b17-20020a170903229100b001c0a5c9e072mr16183057plh.11.1698279572469; Wed, 25 Oct 2023 17:19:32 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id jh1-20020a170903328100b001c5fc291ef9sm9754655plb.209.2023.10.25.17.19.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 17:19:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland Subject: [PULL 29/94] target/sparc: Move WRTBR, WRHPR to decodetree Date: Wed, 25 Oct 2023 17:14:37 -0700 Message-Id: <20231026001542.1141412-59-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026001542.1141412-1-richard.henderson@linaro.org> References: <20231026001542.1141412-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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. Tested-by: Mark Cave-Ayland Acked-by: Mark Cave-Ayland Signed-off-by: Richard Henderson --- target/sparc/insns.decode | 9 ++++ target/sparc/translate.c | 111 +++++++++++++++++++------------------- 2 files changed, 66 insertions(+), 54 deletions(-) diff --git a/target/sparc/insns.decode b/target/sparc/insns.decode index f478999ee1..eab737fdcc 100644 --- a/target/sparc/insns.decode +++ b/target/sparc/insns.decode @@ -143,6 +143,15 @@ WRPR_strand_status 10 11010 110010 ..... . ............. @n_r_ri RDTBR 10 rd:5 101011 00000 0 0000000000000 } +{ + WRTBR 10 00000 110011 ..... . ............. @n_r_ri + WRHPR_hpstate 10 00000 110011 ..... . ............. @n_r_ri +} +WRHPR_htstate 10 00001 110011 ..... . ............. @n_r_ri +WRHPR_hintp 10 00011 110011 ..... . ............. @n_r_ri +WRHPR_htba 10 00101 110011 ..... . ............. @n_r_ri +WRHPR_hstick_cmpr 10 11111 110011 ..... . ............. @n_r_ri + 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 9b82e2bf6f..d87c08c18c 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -50,6 +50,7 @@ # define gen_helper_set_softint(E, S) qemu_build_not_reached() # define gen_helper_tick_get_count(D, E, T, C) qemu_build_not_reached() # define gen_helper_tick_set_count(P, S) qemu_build_not_reached() +# define gen_helper_tick_set_limit(P, S) qemu_build_not_reached() # define gen_helper_wrccr(E, S) qemu_build_not_reached() # define gen_helper_wrcwp(E, S) qemu_build_not_reached() # define gen_helper_wrgl(E, S) qemu_build_not_reached() @@ -3935,6 +3936,61 @@ static void do_wrssr(DisasContext *dc, TCGv src) TRANS(WRPR_strand_status, HYPV, do_wr_special, a, hypervisor(dc), do_wrssr) +TRANS(WRTBR, 32, do_wr_special, a, supervisor(dc), do_wrtba) + +static void do_wrhpstate(DisasContext *dc, TCGv src) +{ + tcg_gen_st_tl(src, tcg_env, env64_field_offsetof(hpstate)); + dc->base.is_jmp = DISAS_EXIT; +} + +TRANS(WRHPR_hpstate, HYPV, do_wr_special, a, hypervisor(dc), do_wrhpstate) + +static void do_wrhtstate(DisasContext *dc, TCGv src) +{ + TCGv_i32 tl = tcg_temp_new_i32(); + TCGv_ptr tp = tcg_temp_new_ptr(); + + tcg_gen_ld_i32(tl, tcg_env, env64_field_offsetof(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_st_tl(src, tp, env64_field_offsetof(htstate)); +} + +TRANS(WRHPR_htstate, HYPV, do_wr_special, a, hypervisor(dc), do_wrhtstate) + +static void do_wrhintp(DisasContext *dc, TCGv src) +{ + tcg_gen_mov_tl(cpu_hintp, src); +} + +TRANS(WRHPR_hintp, HYPV, do_wr_special, a, hypervisor(dc), do_wrhintp) + +static void do_wrhtba(DisasContext *dc, TCGv src) +{ + tcg_gen_mov_tl(cpu_htba, src); +} + +TRANS(WRHPR_htba, HYPV, do_wr_special, a, hypervisor(dc), do_wrhtba) + +static void do_wrhstick_cmpr(DisasContext *dc, TCGv src) +{ + TCGv_ptr r_tickptr = tcg_temp_new_ptr(); + + tcg_gen_mov_tl(cpu_hstick_cmpr, src); + tcg_gen_ld_ptr(r_tickptr, tcg_env, env64_field_offsetof(hstick)); + translator_io_start(&dc->base); + gen_helper_tick_set_limit(r_tickptr, cpu_hstick_cmpr); + /* End TB to handle timer interrupt */ + dc->base.is_jmp = DISAS_EXIT; +} + +TRANS(WRHPR_hstick_cmpr, HYPV, do_wr_special, a, hypervisor(dc), + do_wrhstick_cmpr) + static bool do_saved_restored(DisasContext *dc, bool saved) { if (!supervisor(dc)) { @@ -4624,63 +4680,10 @@ static void disas_sparc_legacy(DisasContext *dc, unsigned int insn) #endif case 0x30: goto illegal_insn; /* WRASR in decodetree */ -#if !defined(CONFIG_USER_ONLY) case 0x32: goto illegal_insn; /* WRPR in decodetree */ case 0x33: /* wrtbr, UA2005 wrhpr */ - { -#ifndef TARGET_SPARC64 - if (!supervisor(dc)) - goto priv_insn; - tcg_gen_xor_tl(cpu_tbr, cpu_src1, cpu_src2); -#else - CHECK_IU_FEATURE(dc, HYPV); - if (!hypervisor(dc)) - goto priv_insn; - cpu_tmp0 = tcg_temp_new(); - tcg_gen_xor_tl(cpu_tmp0, cpu_src1, cpu_src2); - switch (rd) { - case 0: // hpstate - tcg_gen_st_i64(cpu_tmp0, tcg_env, - offsetof(CPUSPARCState, - hpstate)); - save_state(dc); - gen_op_next_insn(); - tcg_gen_exit_tb(NULL, 0); - dc->base.is_jmp = DISAS_NORETURN; - break; - case 1: // htstate - // XXX gen_op_wrhtstate(); - break; - case 3: // hintp - tcg_gen_mov_tl(cpu_hintp, cpu_tmp0); - break; - case 5: // htba - tcg_gen_mov_tl(cpu_htba, cpu_tmp0); - break; - case 31: // hstick_cmpr - { - TCGv_ptr r_tickptr; - - tcg_gen_mov_tl(cpu_hstick_cmpr, cpu_tmp0); - r_tickptr = tcg_temp_new_ptr(); - tcg_gen_ld_ptr(r_tickptr, tcg_env, - offsetof(CPUSPARCState, hstick)); - translator_io_start(&dc->base); - gen_helper_tick_set_limit(r_tickptr, - cpu_hstick_cmpr); - /* End TB to handle timer interrupt */ - dc->base.is_jmp = DISAS_EXIT; - } - break; - case 6: // hver readonly - default: - goto illegal_insn; - } -#endif - } - break; -#endif + goto illegal_insn; /* WRTBR, WRHPR in decodetree */ #ifdef TARGET_SPARC64 case 0x2c: /* V9 movcc */ {