From patchwork Mon Oct 8 21:22:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 148454 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp4139135lji; Mon, 8 Oct 2018 14:34:44 -0700 (PDT) X-Google-Smtp-Source: ACcGV62+8/GrC7QiCIsfQdfkXq1DrGErTWFwWAMquPmEldKbs2qq0a1YgOaJklDmc8XJD6TqIOq5 X-Received: by 2002:ac8:19ea:: with SMTP id s39-v6mr21211766qtk.215.1539034484313; Mon, 08 Oct 2018 14:34:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539034484; cv=none; d=google.com; s=arc-20160816; b=00Lg3Bg6Ss9gx6ddrRVWJr43TjSu7vuW/qn5HtkIL6WsjWqYGeYRdyybEqqDZ4yiUv fvWQzbXVWJVobo01edJJ2DXSYxfhnXy8M0i5zqXWMoYnzMh88dEzT6sAqjX2xBmh+DEg gTHlom5gBaUHGoauh3qBQhPk2MTXtzQskaUSGyWZpxXaM+EbpzywN72jGsSPEB/8R0wU OYwx+HiLdAZA1zfNwjTDRaAuPzmcfGIawoXlJKmp3yASSKr31UTn0rMc2ZMQ+k+Pn+YH EAJVMasdeCI0cBkBJLyZ1xkKajcNxKXZPEvv2K4SIP2fa99wvpnbvZ9U6ymqZLmSd+9Y WTRQ== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=IjpjVMYz7aP1wSnwsbhEtISF88v6xrr3WAXPRNpRlK8=; b=rXEv2PS7aYniRn5dtHWr2TVSuzBodZT7Y6vvzLL5OSl8finQuTV3WUfadAFNsGlTMN zcrjuHcBsfmNi7aWLYjSmPbjx6TUcVofD0MJ/NbU3eIhedZLMABW8SBDn7DenhsRdWl5 z74J+YQfrf/sx6HmnDKGxpVCZbJup8zq+d2A2TXY4ZmE8gkUUzqwfbLY6jwZmBJ7HGVY QwCOiB9Eot0AtMLKrlbqT5vbSi9vNh4/X3vzAO9fYub3jCOz7+nME9VVCH7tv3Qrqa6C q9frVN/81Z5viaSI61YvML/exHolWnjN2nUhusv+7+S7LkQX2DGyAzELcq2q2Ll/CUIt yldg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=hWnSI+2L; 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 m10-v6si3617160qth.251.2018.10.08.14.34.44 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 08 Oct 2018 14:34:44 -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=hWnSI+2L; 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]:48403 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g9dAp-0001ec-MC for patch@linaro.org; Mon, 08 Oct 2018 17:34:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58531) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g9d4S-0005Fr-1M for qemu-devel@nongnu.org; Mon, 08 Oct 2018 17:28:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g9cyq-0008AK-Vy for qemu-devel@nongnu.org; Mon, 08 Oct 2018 17:22:24 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]:36558) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g9cyq-00088s-MD for qemu-devel@nongnu.org; Mon, 08 Oct 2018 17:22:20 -0400 Received: by mail-pl1-x62d.google.com with SMTP id y11-v6so7463538plt.3 for ; Mon, 08 Oct 2018 14:22:18 -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 :mime-version:content-transfer-encoding; bh=IjpjVMYz7aP1wSnwsbhEtISF88v6xrr3WAXPRNpRlK8=; b=hWnSI+2LnsWFBLmZ7706s56My8r3xnf0qUhCMd2V3lXWhX2XZG2bdg4y4ciiUuuFUz KFBio5XLv+YqEOIfBqEN/To91EA0Q02HcnqVqe2gKnMB7bo87ER9GtNpawPFQAZ31E/K azU9EhATr1SFyx9Odct+5qveCmAn5ITndx5Ug= 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:mime-version:content-transfer-encoding; bh=IjpjVMYz7aP1wSnwsbhEtISF88v6xrr3WAXPRNpRlK8=; b=UGNxrLNKku/bUe5mTATikX7kqkf1uC1+e0MQ09aeUGm/Lt/V5njGhZ84UBlMV2WOpU GDUz/MgL0OfV1SKTP3JzGwBHo6sGBEy4d8XydLA9lBIFCUNLYtpCM8xm1QFL9VNbqG/3 DQ3KfC2uqodysvhW5NIjmZpZyNuHZUiOyIq4+z7YMsHzj/IL561b3zMu9q8TD4qxyvUe tj0lVgRgdJdjAP3tnGwZyF5rsIbZoF30p+vfsChZpwsrZwmWwYkFccq2yqtXejX/gM8A zu2brW540qe7V6i5SRsnX6ukjKQO7nKVWei/9YNIWrtlMNPNzw8LEjnFOi4lFb725XhU /FmA== X-Gm-Message-State: ABuFfojswdQ76WAo1CUHjf1KMSQU3G3MZnans6GhAVVpeQczRmX6U2Vo mqx0VAu1c7N1WlMRClrgZlV+qJPlqI8= X-Received: by 2002:a17:902:4401:: with SMTP id k1-v6mr25216613pld.97.1539033737069; Mon, 08 Oct 2018 14:22:17 -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 r25-v6sm20392913pgm.59.2018.10.08.14.22.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Oct 2018 14:22:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 8 Oct 2018 14:22:01 -0700 Message-Id: <20181008212205.17752-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181008212205.17752-1-richard.henderson@linaro.org> References: <20181008212205.17752-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::62d Subject: [Qemu-devel] [PATCH v3 06/10] 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. Reviewed-by: Philippe Mathieu-Daudé 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 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 66eaa40ed9..2af971e823 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1550,7 +1550,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, @@ -1560,7 +1559,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 */ @@ -3139,6 +3137,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 1d60569583..8279465d1d 100644 --- a/target/arm/translate.h +++ b/target/arm/translate.h @@ -195,6 +195,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 571beca8fd..9b00e977d8 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 83a6cb535f..f068b4c476 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 ea8545c43b..b1ee6533cc 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -9755,7 +9755,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)) { @@ -10963,7 +10963,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)