From patchwork Thu Oct 20 03:06:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 616715 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp715502pvb; Wed, 19 Oct 2022 20:30:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6ByCsWy2HnBwUM540g0+nNuH2x+9obfUBCZICNM7+Ssfr6DcGmJpAFB/25I1Wf6xnvRbah X-Received: by 2002:ac8:5d49:0:b0:39a:4f7:e0b2 with SMTP id g9-20020ac85d49000000b0039a04f7e0b2mr9215512qtx.119.1666236620871; Wed, 19 Oct 2022 20:30:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666236620; cv=none; d=google.com; s=arc-20160816; b=e2HvWgL/TQmkf8Y3DdEH4D4UNTC4TmLY0TGWWss9rOPEIgSNYABeLhDS6azPKjSrab RAOjCjJnIXL9sbgYWe7Eocpz8mubW67+kbq1ZcKobSARWaTTpPHsZTs7rkxe3ixxkxgt YkTd6rt9crLvyiMfPXoR0mGvGOy2bwKMLGl95Oo9YiCp6qiklTNMZyFuoqRPYVMpF0ax n2gfc445jmgp5s/TKnQNHKhoeJGuYmhm5VEDJ8crDavyq1sakNDpN90fX51JLsI2QnZZ yc0NsQ6X5bHTxXtkTYj+gPDJe+Tu9y/cQlM9riawSKd79Qa3MsR8+E1aJIHJOLX9xcwf 98iA== 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=8swKSgWeilWZrM/mNtFL8crpzMp47VFbNvAGDxXmm3Y=; b=MRUO8i9oJrE22AkmQFsytPlKQlnhZyjZz63yW1DLCXbBU5lMrGW0hIX2xN03EnbceB NCuWYIpljMFpKhJmne+jC/F0z52CRrbt9yVWpeC8mrF7weDp2SyAQktY977vTNAn+E6q mdgjZEuSUMFXaf3JVVsfg1fJ15Ea9o7Cp7g6m+7Oa1kyUDldZlvoqVr41uyP+tWncYCj nGnJCVtkRG4Nf4+VqA3R8QUPCTALA6KEu7JBMoMzA8HLYQ4FCFJc93PY9icKg2iBItFt yf+VLfinJMRTkz2a9RkBpYNiTUQ6WmkFhNz49iHzLSgi3nsZn12Fdcoe3ZPKonDpIU7u okjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d4umjF4T; 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 q13-20020ad4574d000000b004b403f92673si10572516qvx.386.2022.10.19.20.30.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 19 Oct 2022 20:30:20 -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=d4umjF4T; 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]:37536 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olMGC-0003P4-8K for patch@linaro.org; Wed, 19 Oct 2022 23:30:20 -0400 Received: from [::1] (port=40128 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olLwm-0002zZ-7B for patch@linaro.org; Wed, 19 Oct 2022 23:10:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48144) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olLts-0002v1-Fm for qemu-devel@nongnu.org; Wed, 19 Oct 2022 23:07:17 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]:33478) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1olLtq-0001mO-RJ for qemu-devel@nongnu.org; Wed, 19 Oct 2022 23:07:16 -0400 Received: by mail-pf1-x42d.google.com with SMTP id m6so19087517pfb.0 for ; Wed, 19 Oct 2022 20:07:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=8swKSgWeilWZrM/mNtFL8crpzMp47VFbNvAGDxXmm3Y=; b=d4umjF4TJTeW9c8Lx+zwMgq38yaK0bBRGjjVIpQQUCBpLRaRO6PLJGWN9IemoAVWs7 irv/SL6Ft5MAnt9epwMuCLhkFiJ/PEAuD8FzWkILJM5A/ccPSa39CaFvv63Ghs/rPD6c zKPcs3vOWgM9NgfGlhI5MzoxlYA8Bqi4WCRkg7tJWPFscc/gY0qIw1y9neT3/XOrymW2 DJarUHgLMJPAv0k9PlWEiUPq1WPr7t7KyEvVf+0mCD2yTNWY77vfiSm7X9en9F2rrlFX RorpGbgsM01cCFE4uLoak/by4ckPEqBY2R8ztfiL4yeoKVX9O6I0AeocQJNqVOZRkgZj H1bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=8swKSgWeilWZrM/mNtFL8crpzMp47VFbNvAGDxXmm3Y=; b=0+VK/WSgGwodm0TV7E7NEY5MnIMat82e/mbpZsqY0atv7XJ9icuFmQOq2LROG2uMrP S2BXMFD8e1g96OjzC5MvAx7DG+0sa2tbfSkDAPsfQ4+VO/v3JhWep937+hlXYvtGzX5c 4DZJ3GrK4+52r645gYAfPZCcFJc5LBE2DkYKVRFgBvTYlSG+r0Q4iX2DdFooAfwnuHde 0vOwtzAvf/HJkLCX3XIC2lkx55BSs6umHsLo6fggkXeO+eTuqkiMVrROGFyB+0/cvTKv Odq8P215xg0laQoMiRgZxvXEf1eQMP7XCcqbT9wOdTCfe0xpAGXe/uZOuTODjSgzAICc jaDA== X-Gm-Message-State: ACrzQf1lI1X4WD1X/IJiBMa2gbSJdMh04zsnIuBMa1AeViJRPztaaa8w 4f7B4HAP2DXFm5oPKdMWRtm81GqfC/+4m9OU X-Received: by 2002:a63:1b15:0:b0:462:f17e:7051 with SMTP id b21-20020a631b15000000b00462f17e7051mr9991325pgb.619.1666235232375; Wed, 19 Oct 2022 20:07:12 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id m9-20020a63ed49000000b0043c7996f7f0sm10657647pgk.58.2022.10.19.20.07.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 20:07:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v8 1/9] target/arm: Introduce curr_insn_len Date: Thu, 20 Oct 2022 13:06:33 +1000 Message-Id: <20221020030641.2066807-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221020030641.2066807-1-richard.henderson@linaro.org> References: <20221020030641.2066807-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.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=unavailable 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" A simple helper to retrieve the length of the current insn. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/arm/translate.h | 5 +++++ target/arm/translate-vfp.c | 2 +- target/arm/translate.c | 5 ++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/target/arm/translate.h b/target/arm/translate.h index af5d4a7086..90bf7c57fc 100644 --- a/target/arm/translate.h +++ b/target/arm/translate.h @@ -226,6 +226,11 @@ static inline void disas_set_insn_syndrome(DisasContext *s, uint32_t syn) s->insn_start = NULL; } +static inline int curr_insn_len(DisasContext *s) +{ + return s->base.pc_next - s->pc_curr; +} + /* is_jmp field values */ #define DISAS_JUMP DISAS_TARGET_0 /* only pc was modified dynamically */ /* CPU state was modified dynamically; exit to main loop for interrupts. */ diff --git a/target/arm/translate-vfp.c b/target/arm/translate-vfp.c index bd5ae27d09..94cc1e4b77 100644 --- a/target/arm/translate-vfp.c +++ b/target/arm/translate-vfp.c @@ -242,7 +242,7 @@ static bool vfp_access_check_a(DisasContext *s, bool ignore_vfp_enabled) if (s->sme_trap_nonstreaming) { gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_smetrap(SME_ET_Streaming, - s->base.pc_next - s->pc_curr == 2)); + curr_insn_len(s) == 2)); return false; } diff --git a/target/arm/translate.c b/target/arm/translate.c index 2f72afe019..5752b7af5c 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -6650,7 +6650,7 @@ static ISSInfo make_issinfo(DisasContext *s, int rd, bool p, bool w) /* ISS not valid if writeback */ if (p && !w) { ret = rd; - if (s->base.pc_next - s->pc_curr == 2) { + if (curr_insn_len(s) == 2) { ret |= ISSIs16Bit; } } else { @@ -9812,8 +9812,7 @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) /* nothing more to generate */ break; case DISAS_WFI: - gen_helper_wfi(cpu_env, - tcg_constant_i32(dc->base.pc_next - dc->pc_curr)); + gen_helper_wfi(cpu_env, tcg_constant_i32(curr_insn_len(dc))); /* * The helper doesn't necessarily throw an exception, but we * must go back to the main loop to check for interrupts anyway.