From patchwork Tue Jul 23 03:34:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 813938 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp2141690wro; Mon, 22 Jul 2024 20:37:27 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV2BJewJizFpn8RA5ZFKZ5DXn0lrYoxoz609zWuwkyjFN5ys+9A+Veng9tH5R4Ubct+aM0p8cYxKGK0AyPB124o X-Google-Smtp-Source: AGHT+IE4SREy5VseKGkKDJY/50OYnOlammak5oy/Tx5EmoLa3wUC9J7S5FpWEEsGC2xTtlVqPhyt X-Received: by 2002:a05:620a:4106:b0:79f:1915:5b3d with SMTP id af79cd13be357-7a1c06c5a7amr196696385a.18.1721705847695; Mon, 22 Jul 2024 20:37:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721705847; cv=none; d=google.com; s=arc-20160816; b=cskrO8tdd8TAo3Pu7MdHbK4rYm60NCZ44QwJUaEWlkI6i0GokUdT6pWRzwqMubxpfO EiFB1p9zAU9PS7jW8QG9K3iaBVGghL+rTn4XUWAfQiOcKaWfSG/2ewc7IXWl+RjxcRq7 ezeULauJxjiNmJ4op1qQhcClVPtCV5Uht72y5GQgnPRKQLGK+nIyJTCPo5Ou4s/7f7QH RxewckHzI9BzPw3jXkJ0NFdQf/enekEVHDz6hQXUmmjtAWwSDBPWpmJfgbgfqSY5AHs7 YDl86LsVcdR/EZOqw1mUWXy9xg3oalLNUaEDkvYysU5IMwzCvLQMMrMnOrERSbyfq0jx uqww== 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=vMEEORHFY/5AJeKs7AXO2kip576OxvLWKFUcuNYKW6c=; fh=SzyanoJ2dK3fF15FSnLUFXGq7SBYR1IsiEs+gdHraiY=; b=nZt9rOYgj+KM6mnWKUpLgZqF2hna/hZCXRYFxi8kWJI370XLsoow4kFjJ1RNuazNVq pmzt2QmYNEffVC4cVtQj7kKRNWruUIbwIICpJXJ6rGN6nNebg0Fhn4559+r2DET2E+yy xgdBukV+2UG1kgRT9O60ft3EOIQuMmj4nTgcxxA1m6EvN6DT46n+annrveEadt019tqJ POvda8LDPq4wSOPJvxkDk456kLa9TYt07PjMoAYpSC+yMx1SD9WZBEycNOniM2HvEWKI EN5VWMZlzM1C5SjtiAtL4cHBfMc8oKDg7xBklU6rP+mu48Svb5Xw4enBP+Gt5ZARlkNv dbFw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aQn+7Z0f; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a198f986e6si942371485a.93.2024.07.22.20.37.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2024 20:37:27 -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=aQn+7Z0f; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sW6J6-0002eW-BG; Mon, 22 Jul 2024 23:35:20 -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 1sW6J2-0002RL-TV for qemu-devel@nongnu.org; Mon, 22 Jul 2024 23:35:16 -0400 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sW6J0-0001xq-Mc for qemu-devel@nongnu.org; Mon, 22 Jul 2024 23:35:16 -0400 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-70d1d818c42so1122102b3a.1 for ; Mon, 22 Jul 2024 20:35:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721705713; x=1722310513; 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=vMEEORHFY/5AJeKs7AXO2kip576OxvLWKFUcuNYKW6c=; b=aQn+7Z0fIEZjXKw0cu+5kpbaqSsSJaEV3l8j4h6auVlEIb985VZjQ4oHYIDdUhmQnF Jm3U7Cui7gKUdQlKt9vspacptjiznJZlJNoxSD+pkda45e0DHLXqp56lEHt+R6Ncet8g 91t3ckWuBxKK4q/Hu1mPsY4Fd2wfImpWcrewb9O1HwcuTaW52nj2MpK6ORH2YHrV35L3 R6R0GgTBug0h6C0uKKrViND34yKslC5yViM0agaUBnTI2W3m3yacy5wn4NMezxpX7lz1 LB1ennyb0egTkSGFpa3dr+iNuKPvFAIbuXlchX7pBZ+EX3gSh6W0xg+mUCGgC5Jj83xD Wobw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721705713; x=1722310513; 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=vMEEORHFY/5AJeKs7AXO2kip576OxvLWKFUcuNYKW6c=; b=YmU8un3UYjujYya0dds6GOhIzurILPWUT4/6Ffbv+D/iLWKN8S/NCbvk9ymXARMa/y KHqmnd3hkyieb7Z41wFhqNUnZ3s128aI18NBtyy/wum7aE8cFIJq49B3gdbsoHB7n+Np 3gKxPIlp7eIej5/4dX3Vkuz3fOv1ZZqzYFciDXiYtqVWnQ6IXLRXIsekv9vq6BlPVur6 ZL0r2G6MhJ92RERiLzb6AWmDeWrO+vMwiMJTKJI9p1YKOXgxtxFJD9WHLo76ECAfIAQm EtGQONDAVwyesUWuEQtHiL+Ug96LlaoTumKz9q1JNgYMMcNihjxW252+hOmpwxyL5lsc hm3Q== X-Gm-Message-State: AOJu0Yy8Z/QykNrQtnrWWyuMDEs+sJSwxmHo6ufKiEvJ3K1qSnca8feL g81bL5he6nKl9yyrP9nSWwiMSY3huSrr6XjqDvvjEmCOe1HYh3hdTTM5hvOVXf4Lu5y+5np0CLO D7WUbAw== X-Received: by 2002:a05:6a00:2e03:b0:706:5dab:83c4 with SMTP id d2e1a72fcca58-70d3a8b177amr2736644b3a.14.1721705713035; Mon, 22 Jul 2024 20:35:13 -0700 (PDT) Received: from stoup.. ([203.56.128.103]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70d2b96bfcasm2171380b3a.87.2024.07.22.20.35.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jul 2024 20:35:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Nicholas Piggin , BALATON Zoltan Subject: [PATCH 06/12] target/ppc: Split out helper_dbczl for 970 Date: Tue, 23 Jul 2024 13:34:45 +1000 Message-ID: <20240723033451.546151-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240723033451.546151-1-richard.henderson@linaro.org> References: <20240723033451.546151-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::432; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x432.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 We can determine at translation time whether the insn is or is not dbczl. We must retain a runtime check against the HID5 register, but we can move that to a separate function that never affects other ppc models. Reviewed-by: Nicholas Piggin Reviewed-by: BALATON Zoltan Signed-off-by: Richard Henderson --- target/ppc/helper.h | 7 +++++-- target/ppc/mem_helper.c | 34 +++++++++++++++++++++------------- target/ppc/translate.c | 24 ++++++++++++++---------- 3 files changed, 40 insertions(+), 25 deletions(-) diff --git a/target/ppc/helper.h b/target/ppc/helper.h index 76b8f25c77..afc56855ff 100644 --- a/target/ppc/helper.h +++ b/target/ppc/helper.h @@ -46,8 +46,11 @@ DEF_HELPER_FLAGS_3(stmw, TCG_CALL_NO_WG, void, env, tl, i32) DEF_HELPER_4(lsw, void, env, tl, i32, i32) DEF_HELPER_5(lswx, void, env, tl, i32, i32, i32) DEF_HELPER_FLAGS_4(stsw, TCG_CALL_NO_WG, void, env, tl, i32, i32) -DEF_HELPER_FLAGS_3(dcbz, TCG_CALL_NO_WG, void, env, tl, i32) -DEF_HELPER_FLAGS_3(dcbzep, TCG_CALL_NO_WG, void, env, tl, i32) +DEF_HELPER_FLAGS_2(dcbz, TCG_CALL_NO_WG, void, env, tl) +DEF_HELPER_FLAGS_2(dcbzep, TCG_CALL_NO_WG, void, env, tl) +#ifdef TARGET_PPC64 +DEF_HELPER_FLAGS_2(dcbzl, TCG_CALL_NO_WG, void, env, tl) +#endif DEF_HELPER_FLAGS_2(icbi, TCG_CALL_NO_WG, void, env, tl) DEF_HELPER_FLAGS_2(icbiep, TCG_CALL_NO_WG, void, env, tl) DEF_HELPER_5(lscbx, tl, env, tl, i32, i32, i32) diff --git a/target/ppc/mem_helper.c b/target/ppc/mem_helper.c index 5067919ff8..d4957efd6e 100644 --- a/target/ppc/mem_helper.c +++ b/target/ppc/mem_helper.c @@ -296,26 +296,34 @@ static void dcbz_common(CPUPPCState *env, target_ulong addr, } } -void helper_dcbz(CPUPPCState *env, target_ulong addr, uint32_t opcode) +void helper_dcbz(CPUPPCState *env, target_ulong addr) { - int dcbz_size = env->dcache_line_size; - -#if defined(TARGET_PPC64) - /* Check for dcbz vs dcbzl on 970 */ - if (env->excp_model == POWERPC_EXCP_970 && - !(opcode & 0x00200000) && ((env->spr[SPR_970_HID5] >> 7) & 0x3) == 1) { - dcbz_size = 32; - } -#endif - - dcbz_common(env, addr, dcbz_size, ppc_env_mmu_index(env, false), GETPC()); + dcbz_common(env, addr, env->dcache_line_size, + ppc_env_mmu_index(env, false), GETPC()); } -void helper_dcbzep(CPUPPCState *env, target_ulong addr, uint32_t opcode) +void helper_dcbzep(CPUPPCState *env, target_ulong addr) { dcbz_common(env, addr, env->dcache_line_size, PPC_TLB_EPID_STORE, GETPC()); } +#ifdef TARGET_PPC64 +void helper_dcbzl(CPUPPCState *env, target_ulong addr) +{ + int dcbz_size = env->dcache_line_size; + + /* + * The translator checked for POWERPC_EXCP_970. + * All that's left is to check HID5. + */ + if (((env->spr[SPR_970_HID5] >> 7) & 0x3) == 1) { + dcbz_size = 32; + } + + dcbz_common(env, addr, dcbz_size, ppc_env_mmu_index(env, false), GETPC()); +} +#endif + void helper_icbi(CPUPPCState *env, target_ulong addr) { addr &= ~(env->dcache_line_size - 1); diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 0bc16d7251..9e472ab7ef 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -178,6 +178,7 @@ struct DisasContext { /* Translation flags */ MemOp default_tcg_memop_mask; #if defined(TARGET_PPC64) + powerpc_excp_t excp_model; bool sf_mode; bool has_cfar; bool has_bhrb; @@ -4445,27 +4446,29 @@ static void gen_dcblc(DisasContext *ctx) /* dcbz */ static void gen_dcbz(DisasContext *ctx) { - TCGv tcgv_addr; - TCGv_i32 tcgv_op; + TCGv tcgv_addr = tcg_temp_new(); gen_set_access_type(ctx, ACCESS_CACHE); - tcgv_addr = tcg_temp_new(); - tcgv_op = tcg_constant_i32(ctx->opcode & 0x03FF000); gen_addr_reg_index(ctx, tcgv_addr); - gen_helper_dcbz(tcg_env, tcgv_addr, tcgv_op); + +#ifdef TARGET_PPC64 + if (ctx->excp_model == POWERPC_EXCP_970 && !(ctx->opcode & 0x00200000)) { + gen_helper_dcbzl(tcg_env, tcgv_addr); + return; + } +#endif + + gen_helper_dcbz(tcg_env, tcgv_addr); } /* dcbzep */ static void gen_dcbzep(DisasContext *ctx) { - TCGv tcgv_addr; - TCGv_i32 tcgv_op; + TCGv tcgv_addr = tcg_temp_new(); gen_set_access_type(ctx, ACCESS_CACHE); - tcgv_addr = tcg_temp_new(); - tcgv_op = tcg_constant_i32(ctx->opcode & 0x03FF000); gen_addr_reg_index(ctx, tcgv_addr); - gen_helper_dcbzep(tcg_env, tcgv_addr, tcgv_op); + gen_helper_dcbzep(tcg_env, tcgv_addr); } /* dst / dstt */ @@ -6486,6 +6489,7 @@ static void ppc_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) ctx->default_tcg_memop_mask = ctx->le_mode ? MO_LE : MO_BE; ctx->flags = env->flags; #if defined(TARGET_PPC64) + ctx->excp_model = env->excp_model; ctx->sf_mode = (hflags >> HFLAGS_64) & 1; ctx->has_cfar = !!(env->flags & POWERPC_FLAG_CFAR); ctx->has_bhrb = !!(env->flags & POWERPC_FLAG_BHRB);