From patchwork Thu Sep 27 21:13:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 147740 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp2526857lji; Thu, 27 Sep 2018 14:40:11 -0700 (PDT) X-Google-Smtp-Source: ACcGV60uwxjrqQKZdCuo/lOcZUXSrEeoI6qhqlMi5ny22rkvqP5sbFmmsNmQnVGmlDc5LK1EbsbA X-Received: by 2002:ac8:34bc:: with SMTP id w57-v6mr10087088qtb.239.1538084411749; Thu, 27 Sep 2018 14:40:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538084411; cv=none; d=google.com; s=arc-20160816; b=NmGKfcsazkqhdufForAExwGkLC66A+SSLVXAwW9cLRRDJbVxe/G7DYLnR9QQ013XuF TQF2sQFPF38hk5wdKJDGcSBiI6LSMV6v72l3Jp2MyPmT6lQEoU9r6SlOYAUuvgUX31C1 gWZiXg0xYLqd8HFb63rTjt0XepbnBGVcAIi7VUw33UuQxb83huSFfNOqxzbpPBeTdS9Z 9x+cpA6adkSf5iBPmvm3ZxqkhYN0mSAK/XSCCRBVWaCT/iiMRSz30DajHtblcwuX3w+v GHkOuET2FHwDIbQ/CELvzDlV7n9gljpq1y8Fh7+to3y9w4D2m3EVQm2xpK668JXy07A8 zcqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=waibaX9GfmLCLeNaQ//+CLR7lm2AHxayHMg40yZdgx4=; b=ZynWSDEhkibwJC4fps3zc65hEygnXWt5/5utIuUGXX8m2CZFoUecRN8iqKX/iwxWgs TNCbecBuGIOxUqGUVeZAOrCAAJVdvVtoYneQQ7NGf74cD57wT+LHQUJeXn7fnk9pW9Jj mkSGDwiY2tiq4Y/L6D5oJKVoqFj8JspuMDPm9FW37Gqe3znq2He3I+ko5b+uZ7jrklU6 dc3uUz4YlkVLC488BAYoIqJgW9hVVG09W0tDxmwrPKOsivhZhG3ONLbz3gnsJa118Ce0 Ktk5tRCh5hYPzkZd61vJQoZkwPuc295ALdaocsXtcjtb1SQl2tFRhGimJ2/fHQ2B4AqQ oLPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="bF/tA565"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id u32-v6si557515qth.220.2018.09.27.14.40.11 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 27 Sep 2018 14:40:11 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="bF/tA565"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39600 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5e15-0003qj-0n for patch@linaro.org; Thu, 27 Sep 2018 17:40:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54163) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5dpZ-0003xg-37 for qemu-devel@nongnu.org; Thu, 27 Sep 2018 17:28:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5dbR-0000p5-3E for qemu-devel@nongnu.org; Thu, 27 Sep 2018 17:13:45 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:41254) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g5dbM-0000bl-6o for qemu-devel@nongnu.org; Thu, 27 Sep 2018 17:13:37 -0400 Received: by mail-pf1-x441.google.com with SMTP id m77-v6so2747574pfi.8 for ; Thu, 27 Sep 2018 14:13:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=waibaX9GfmLCLeNaQ//+CLR7lm2AHxayHMg40yZdgx4=; b=bF/tA565908qsHFUt3Z9cPy1drHNW4WPpnX7Mi3aZq94hFpZGhVymg8PTIJvkWsqrK kjSJ04hGqAEceRdxikf+vi+ulBJo9fFyA548RqBxCzrSF0sjjBwBVfc5EH6+xobmQhuK +dgFJEzpAaZqsyrJuqMIohSqlLnTKzGPP1rfU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=waibaX9GfmLCLeNaQ//+CLR7lm2AHxayHMg40yZdgx4=; b=bfnqHJL3L5rBipVoz11NDc7Aot0+v83NWIIVG6OglHYi5YBvA70EZ5ReHPl6+MJbTs BA88sigkTltBYksgCwP5RVfDldyhf4hrTJfHB10IG6nUhgYcoDgnxaQiddM8aWzxK7kb scZ/+1s6J/y8kaIniBSGKnLGZjfqMmY5ikwMhCFhj62974coSt29RRgaRS3qY6nxctnE zECL2ZzUphz7ViX0hN+XTzO6QebVJhjOSHZN9HclBXZrhD/fPvwnDeeWVI7oByzmZkSS ldf+ViDeWLRso+XYiJVzIhFGnrOm8K1ssTpEYhp9+zLct3tvN+LNcevpemtS33mcIHG2 tifg== X-Gm-Message-State: ABuFfoh5MopN/DyXb2pOt+24XIqTWPJ9u4+rVLYTlTWjYdpG5y5D1FNz f7F7PdnawNXDiuKHLXjtJNkEN7AEUMo= X-Received: by 2002:a17:902:bc8b:: with SMTP id bb11-v6mr12749780plb.112.1538082812634; Thu, 27 Sep 2018 14:13:32 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-8-179.tukw.qwest.net. [97.113.8.179]) by smtp.gmail.com with ESMTPSA id l26-v6sm5395884pfg.161.2018.09.27.14.13.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Sep 2018 14:13:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 27 Sep 2018 14:13:18 -0700 Message-Id: <20180927211322.16118-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180927211322.16118-1-richard.henderson@linaro.org> References: <20180927211322.16118-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 Subject: [Qemu-devel] [PATCH v2 5/9] target/arm: Convert division from feature bits to isar0 tests X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Both arm and thumb2 division are controlled by the same ISAR field, which takes care of the arm implies thumb case. Having M imply thumb2 division was wrong for cortex-m0, which is v6m and does not have thumb2 at all, much less thumb2 division. Signed-off-by: Richard Henderson --- target/arm/cpu.h | 12 ++++++++++-- target/arm/translate.h | 2 ++ linux-user/elfload.c | 4 ++-- target/arm/cpu.c | 10 +--------- target/arm/translate.c | 4 ++-- 5 files changed, 17 insertions(+), 15 deletions(-) -- 2.17.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 1e3c4650ce..cd57c5aae0 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1527,7 +1527,6 @@ enum arm_features { ARM_FEATURE_VFP3, ARM_FEATURE_VFP_FP16, ARM_FEATURE_NEON, - ARM_FEATURE_THUMB_DIV, /* divide supported in Thumb encoding */ ARM_FEATURE_M, /* Microcontroller profile. */ ARM_FEATURE_OMAPCP, /* OMAP specific CP15 ops handling. */ ARM_FEATURE_THUMB2EE, @@ -1537,7 +1536,6 @@ enum arm_features { ARM_FEATURE_V5, ARM_FEATURE_STRONGARM, ARM_FEATURE_VAPA, /* cp15 VA to PA lookups */ - ARM_FEATURE_ARM_DIV, /* divide supported in ARM encoding */ ARM_FEATURE_VFP4, /* VFPv4 (implies that NEON is v2) */ ARM_FEATURE_GENERIC_TIMER, ARM_FEATURE_MVFR, /* Media and VFP Feature Registers 0 and 1 */ @@ -3111,6 +3109,16 @@ extern const uint64_t pred_esz_masks[4]; /* * 32-bit feature tests via id registers. */ +static inline bool aa32_feature_thumb_div(ARMCPU *cpu) +{ + return FIELD_EX32(cpu->id_isar0, ID_ISAR0, DIVIDE) != 0; +} + +static inline bool aa32_feature_arm_div(ARMCPU *cpu) +{ + return FIELD_EX32(cpu->id_isar0, ID_ISAR0, DIVIDE) > 1; +} + static inline bool aa32_feature_aes(ARMCPU *cpu) { return FIELD_EX32(cpu->id_isar5, ID_ISAR5, AES) != 0; diff --git a/target/arm/translate.h b/target/arm/translate.h index baacfd7e6b..3eb863ae43 100644 --- a/target/arm/translate.h +++ b/target/arm/translate.h @@ -194,6 +194,8 @@ static inline TCGv_i32 get_ahp_flag(void) static inline bool aa32_dc_feature_##NAME(DisasContext *dc) \ { return aa32_feature_##NAME(dc->cpu); } +FORWARD_FEATURE(thumb_div) +FORWARD_FEATURE(arm_div) FORWARD_FEATURE(aes) FORWARD_FEATURE(pmull) FORWARD_FEATURE(sha1) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 408bf67206..1ddb1fd102 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -471,8 +471,8 @@ static uint32_t get_elf_hwcap(void) GET_FEATURE(ARM_FEATURE_VFP3, ARM_HWCAP_ARM_VFPv3); GET_FEATURE(ARM_FEATURE_V6K, ARM_HWCAP_ARM_TLS); GET_FEATURE(ARM_FEATURE_VFP4, ARM_HWCAP_ARM_VFPv4); - GET_FEATURE(ARM_FEATURE_ARM_DIV, ARM_HWCAP_ARM_IDIVA); - GET_FEATURE(ARM_FEATURE_THUMB_DIV, ARM_HWCAP_ARM_IDIVT); + GET_FEATURE_ID(arm_div, ARM_HWCAP_ARM_IDIVA); + GET_FEATURE_ID(thumb_div, ARM_HWCAP_ARM_IDIVT); /* All QEMU's VFPv3 CPUs have 32 registers, see VFP_DREG in translate.c. * Note that the ARM_HWCAP_ARM_VFPv3D16 bit is always the inverse of * ARM_HWCAP_ARM_VFPD32 (and so always clear for QEMU); it is unrelated diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 020e79918b..4f2372c6d7 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -825,7 +825,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) * Presence of EL2 itself is ARM_FEATURE_EL2, and of the * Security Extensions is ARM_FEATURE_EL3. */ - set_feature(env, ARM_FEATURE_ARM_DIV); + assert(aa32_feature_arm_div(cpu)); set_feature(env, ARM_FEATURE_LPAE); set_feature(env, ARM_FEATURE_V7); } @@ -858,12 +858,6 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) if (arm_feature(env, ARM_FEATURE_V5)) { set_feature(env, ARM_FEATURE_V4T); } - if (arm_feature(env, ARM_FEATURE_M)) { - set_feature(env, ARM_FEATURE_THUMB_DIV); - } - if (arm_feature(env, ARM_FEATURE_ARM_DIV)) { - set_feature(env, ARM_FEATURE_THUMB_DIV); - } if (arm_feature(env, ARM_FEATURE_VFP4)) { set_feature(env, ARM_FEATURE_VFP3); set_feature(env, ARM_FEATURE_VFP_FP16); @@ -1384,8 +1378,6 @@ static void cortex_r5_initfn(Object *obj) ARMCPU *cpu = ARM_CPU(obj); set_feature(&cpu->env, ARM_FEATURE_V7); - set_feature(&cpu->env, ARM_FEATURE_THUMB_DIV); - set_feature(&cpu->env, ARM_FEATURE_ARM_DIV); set_feature(&cpu->env, ARM_FEATURE_V7MP); set_feature(&cpu->env, ARM_FEATURE_PMSA); cpu->midr = 0x411fc153; /* r1p3 */ diff --git a/target/arm/translate.c b/target/arm/translate.c index 06d61b1e0d..c94c69e331 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -9726,7 +9726,7 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) case 1: case 3: /* SDIV, UDIV */ - if (!arm_dc_feature(s, ARM_FEATURE_ARM_DIV)) { + if (!aa32_dc_feature_arm_div(s)) { goto illegal_op; } if (((insn >> 5) & 7) || (rd != 15)) { @@ -10884,7 +10884,7 @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) tmp2 = load_reg(s, rm); if ((op & 0x50) == 0x10) { /* sdiv, udiv */ - if (!arm_dc_feature(s, ARM_FEATURE_THUMB_DIV)) { + if (!aa32_dc_feature_thumb_div(s)) { goto illegal_op; } if (op & 0x20)