From patchwork Mon May 13 07:47:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 796539 Delivered-To: patch@linaro.org Received: by 2002:a5d:452e:0:b0:34e:ceec:bfcd with SMTP id j14csp1884660wra; Mon, 13 May 2024 00:54:15 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW8l+ZiWQSO+YYcJBgy5zuojFbcRne9N3aLIZ7pC39r7CYio72NfmFpFrKpxOZVvBcrAnUdTlQPcL3zvLuuTehN X-Google-Smtp-Source: AGHT+IFPWOakp4tCuKBLhsU9q6JMJM0IqipbeXLZLa+0LFwZiz+fhn32VoXr4eab9ZgKbT2nkf2Y X-Received: by 2002:a05:6122:4691:b0:4c9:2540:8520 with SMTP id 71dfb90a1353d-4df88285a74mr6476924e0c.1.1715586855126; Mon, 13 May 2024 00:54:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1715586855; cv=none; d=google.com; s=arc-20160816; b=UOr+ymK9Z5PNNjfpUoEAs80LzkLpuBupkMvKUYKeruhLkeO38xxzmW7xB02bAUKBCT CWz58oQaiYT/ihv7VXQJT/kdLajvC5EOp1URSlA0/USvnRFR4044Cfv7I+sI7lLHgXZC ARWDmMoOD8BfTWrbsgVg0NnP86BExlZXa+DnZF342r2hq0CNZYGFJrDJhwc/hR8CEhz+ 7EF6/q0UeicJFUH//tlvTspPxOzRG9GZsPxCHdllraSkdAjPOnD/kfaHCwMP2tnUsJ7I agfJel+1dllRpU//WHxsNLNNpqyeaVoRBYUCKyEfS6VtyFIQ7oCfAbuJ6RIA1Swy49Pu s74g== 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=OXJrXEo5lvj8nKkiVWwei0sGVNNJi1pj05AdZLYlOuA=; fh=f2WZoDMBYjCKWIIOoPI+rQtxlv4fmOm4u+dLdQLqpOk=; b=u4ONilL/Wtlwo268M90eSGyKpw8C/+h4iW9jfYtLbIq6Udzr7Vs+3Xvm35hq6xn3dC 3F2QbCn8alHVZLckTkeRlfBeT0FKCPeoqRT/46FMWln0h1o+FZREvef0gEADeXIJH18u gUNeE6XrrzOtjTXzVxQ3HFNw2KgCkguZRWTVOzgEABqfdZd9zbfqHJ7vLyXsqF0EyZ3t uvfg/EP6n+ELU3HAx3kpzz3fJxJjTaKgSuQcMXxck7qbRy8OBGncLX1M4+iaYEVUMTnY QmBT29oAwKxvbjHxDcFjxSZbp1LGOrHmLrVDC1g/aSAPDCqalZ9vRVc67sJJq8EkpHen k2ig==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Knr9wDdZ; 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 af79cd13be357-792bf30b7e7si963071785a.334.2024.05.13.00.54.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 May 2024 00:54:15 -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=Knr9wDdZ; 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 1s6QSZ-0005HR-5H; Mon, 13 May 2024 03:50:59 -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 1s6QSW-0005EA-Jc for qemu-devel@nongnu.org; Mon, 13 May 2024 03:50:56 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s6QST-0001yl-7Q for qemu-devel@nongnu.org; Mon, 13 May 2024 03:50:56 -0400 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-34f7d8bfaa0so2921723f8f.0 for ; Mon, 13 May 2024 00:50:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715586651; x=1716191451; 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=OXJrXEo5lvj8nKkiVWwei0sGVNNJi1pj05AdZLYlOuA=; b=Knr9wDdZFJS1hOl1g7yUAlBt1SYoMm/ngxKB8ZDoabfLixRJLwb7fnnFYRlvVsf0up BnxFybrCQu885oPiEDItVdNmMlUSy5e9HGHNYPDLUIZ/d/fBCMVjnO8Ewhp3wo4yDQfS AcIGr+I1QekWmZJUWJ9UASHCpaW5fYvnGAo9HvhIj5A+6zSBzwIeFIVy64+lIwL9oxhY BDMa4FpHpH05ByCstdZhf08Tgj32xBr65BLPM6kjwzAIFyREUb72+trsR90ZK+PDlMpo wR6T+f82L3LvlNqvBAj7ZGoORr73utw34BJo3qYICwleXwbTu3TTQK4lELPwfW3Tq4rQ 89oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715586651; x=1716191451; 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=OXJrXEo5lvj8nKkiVWwei0sGVNNJi1pj05AdZLYlOuA=; b=nUyyEG8y1D7FlUEsrsTtAvxn7WXMqT8cQAf84/PpgkyWpA06frZIS+dgGV++8W2GXI wEiFzsX2VFCqpGQhGO+WDtoa05t9z94BUCFEgahDpANmHi6Fiyue60kWg+12H8elImtl 75gvyVko9g1Oj/LzvB+IXd10ZReXiINMwwaDofeckTwNH7q+NxVN8IBQ3b9zYx2QvN7Y dYnGt858nCRGmads2aJEOkr++Z9xXQycF+HU8VnJK0vWnQVK+elvSyA2VtxQCq8LYIPT XyJQm/ngq1YAZewmLY8RsXGnsvuGl3CIIz7Fnrscp7MunVN/cYY8WMauBnY+d/5s8YLy 6pNg== X-Gm-Message-State: AOJu0Yzm/gygs+cusfwhKtsvB9jAVIMkqS1YCnIm8sP+LY6RN7UnuDrr WfPaMdVJJHrUP8SXOBOpPz9UnMeWtTudIv40ziHqdmLlX95aJuQC7Kl9i0IW9ZV+vAxojbF5mud kv9w= X-Received: by 2002:adf:ed8d:0:b0:34d:b993:fe6e with SMTP id ffacd0b85a97d-3504a20a400mr6013029f8f.0.1715586651394; Mon, 13 May 2024 00:50:51 -0700 (PDT) Received: from stoup.. (12.red-213-97-13.staticip.rima-tde.net. [213.97.13.12]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3502b896a50sm10374262f8f.30.2024.05.13.00.50.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 00:50:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@gmx.de Subject: [PATCH v2 42/45] target/hppa: Implement PSW_T Date: Mon, 13 May 2024 09:47:14 +0200 Message-Id: <20240513074717.130949-43-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240513074717.130949-1-richard.henderson@linaro.org> References: <20240513074717.130949-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x42f.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 PSW_T enables a trap on taken branches, at the very end of the execution of the branch instruction. Signed-off-by: Richard Henderson --- target/hppa/cpu.c | 4 +-- target/hppa/translate.c | 55 +++++++++++++++++++++++++++++++---------- 2 files changed, 44 insertions(+), 15 deletions(-) diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c index f0507874ce..2a3b5fc498 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -76,10 +76,10 @@ void cpu_get_tb_cpu_state(CPUHPPAState *env, vaddr *pc, cs_base |= env->iaoq_b & ~TARGET_PAGE_MASK; } - /* ??? E, T, H, L bits need to be here, when implemented. */ + /* ??? E, H, L bits need to be here, when implemented. */ flags |= env->psw_n * PSW_N; flags |= env->psw_xb; - flags |= env->psw & (PSW_W | PSW_C | PSW_D | PSW_P); + flags |= env->psw & (PSW_W | PSW_C | PSW_D | PSW_P | PSW_T); #ifdef CONFIG_USER_ONLY flags |= TB_FLAG_UNALIGN * !env_cpu(env)->prctl_unalign_sigbus; diff --git a/target/hppa/translate.c b/target/hppa/translate.c index 79e29d722f..2290dc8533 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -1873,6 +1873,23 @@ static bool do_fop_dedd(DisasContext *ctx, unsigned rt, return nullify_end(ctx); } +static bool do_taken_branch_trap(DisasContext *ctx, DisasIAQE *next, bool n) +{ + if (unlikely(ctx->tb_flags & PSW_T)) { + /* + * The X, B and N bits are updated, and the instruction queue + * is advanced before the trap is recognized. + */ + nullify_set(ctx, n); + store_psw_xb(ctx, PSW_B); + install_iaq_entries(ctx, &ctx->iaq_b, next); + gen_excp_1(EXCP_TB); + ctx->base.is_jmp = DISAS_NORETURN; + return true; + } + return false; +} + /* Emit an unconditional branch to a direct target, which may or may not have already had nullification handled. */ static bool do_dbranch(DisasContext *ctx, int64_t disp, @@ -1882,6 +1899,9 @@ static bool do_dbranch(DisasContext *ctx, int64_t disp, if (ctx->null_cond.c == TCG_COND_NEVER && ctx->null_lab == NULL) { install_link(ctx, link, false); + if (do_taken_branch_trap(ctx, &ctx->iaq_j, is_n)) { + return true; + } if (is_n) { if (use_nullify_skip(ctx)) { nullify_set(ctx, 0); @@ -1898,7 +1918,9 @@ static bool do_dbranch(DisasContext *ctx, int64_t disp, nullify_over(ctx); install_link(ctx, link, false); - if (is_n && use_nullify_skip(ctx)) { + if (do_taken_branch_trap(ctx, &ctx->iaq_j, is_n)) { + /* done */ + } else if (is_n && use_nullify_skip(ctx)) { nullify_set(ctx, 0); store_psw_xb(ctx, 0); gen_goto_tb(ctx, 0, &ctx->iaq_j, NULL); @@ -1960,7 +1982,9 @@ static bool do_cbranch(DisasContext *ctx, int64_t disp, bool is_n, n = is_n && disp >= 0; next = iaqe_branchi(ctx, disp); - if (n && use_nullify_skip(ctx)) { + if (do_taken_branch_trap(ctx, &next, is_n)) { + /* done */ + } else if (n && use_nullify_skip(ctx)) { nullify_set(ctx, 0); store_psw_xb(ctx, 0); gen_goto_tb(ctx, 1, &next, NULL); @@ -1990,6 +2014,9 @@ static bool do_ibranch(DisasContext *ctx, unsigned link, { if (ctx->null_cond.c == TCG_COND_NEVER && ctx->null_lab == NULL) { install_link(ctx, link, with_sr0); + if (do_taken_branch_trap(ctx, &ctx->iaq_j, is_n)) { + return true; + } if (is_n) { if (use_nullify_skip(ctx)) { install_iaq_entries(ctx, &ctx->iaq_j, NULL); @@ -2005,20 +2032,22 @@ static bool do_ibranch(DisasContext *ctx, unsigned link, } nullify_over(ctx); - install_link(ctx, link, with_sr0); - if (is_n && use_nullify_skip(ctx)) { - install_iaq_entries(ctx, &ctx->iaq_j, NULL); - nullify_set(ctx, 0); - store_psw_xb(ctx, 0); - } else { - install_iaq_entries(ctx, &ctx->iaq_b, &ctx->iaq_j); - nullify_set(ctx, is_n); - store_psw_xb(ctx, PSW_B); + + if (!do_taken_branch_trap(ctx, &ctx->iaq_j, is_n)) { + if (is_n && use_nullify_skip(ctx)) { + install_iaq_entries(ctx, &ctx->iaq_j, NULL); + nullify_set(ctx, 0); + store_psw_xb(ctx, 0); + } else { + install_iaq_entries(ctx, &ctx->iaq_b, &ctx->iaq_j); + nullify_set(ctx, is_n); + store_psw_xb(ctx, PSW_B); + } + tcg_gen_lookup_and_goto_ptr(); + ctx->base.is_jmp = DISAS_NORETURN; } - tcg_gen_lookup_and_goto_ptr(); - ctx->base.is_jmp = DISAS_NORETURN; return nullify_end(ctx); }