From patchwork Wed Sep 4 19:30:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 173010 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp395475ilq; Wed, 4 Sep 2019 13:18:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqyMFZ6K1Fusp0fYKrYGYW2YDQv/7+rcePdfdyCjZgrvkByrgcyDa4NyZwbLB7lbWEt9+XtX X-Received: by 2002:a05:6402:160d:: with SMTP id f13mr70966edv.227.1567628327149; Wed, 04 Sep 2019 13:18:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567628327; cv=none; d=google.com; s=arc-20160816; b=Wb4Ur2guljHKo1yB0XvXZH9V40VgwWCxyhyekQ5SD8fBoXOfn79QfegN+zkhdrz7Fp fwDR0eAEZ2FcGGBrDx8U2zkXujZkqkGZMLjcgpw0CHCidfvu9y5oPI1SIqUaH2wp1p4S 9Zh6sqZOP55yeriRGBrhJyLFWX8MuOy7F3u/3XIpjx/qjMphc18NJmxarEoR8HBlbp5m hcJdMg5btsx0IaE46vQ366Bof86Tt8w0Q1OVMjvYyuyVCQunjJ4kYmCotJfDB3UvZrLp /J7/N0RLKu+IupnIWSG8dhRtILnUA6fcH5RObqSe1EaPLQioa2/yhqbjH4ljx/u8yZ/3 UBJw== 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=kYh+jTzMtTJhUz3xyrw306VQI42LXaHYhBmdbXyrNe4=; b=pwmHQumUxzIx6ZrbkFIMb7qAzUXcSFzyr4g7RQ+EbNP/DNHpsQnxDbSUdi/1uIoTci Pb++ti4+5iHnUV0HLgJsJwFQ8VVZnNfDJlS1w2RLIe+DxXifH+nhSLFJmziYArhP9nhs tmTBL6hgUQya6ZqOSSfU/y3E07mKs+cwQCBt5q5ZymqgOCpBpTycTnhRY4y/sm6YkpMp szyYis5D32Xoq1BiQnsZlEI2BHzBi8o4X0VQi2Gwu3Y6en+Kn1E5sJb1yk2FUlaiOMAj t5ttkigoGX0Mea7LRmBA2QKRH8xAqPdrr+eLa0qj+JCstDsyNP5nhVVginJ0Od+s9vWw WkEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=j8z0f6M1; 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=fail (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 p22si69347ejd.125.2019.09.04.13.18.46 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Sep 2019 13:18:47 -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=fail header.i=@linaro.org header.s=google header.b=j8z0f6M1; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38582 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5bjp-0002h3-FD for patch@linaro.org; Wed, 04 Sep 2019 16:18:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41189) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5b0u-0005Vw-Ap for qemu-devel@nongnu.org; Wed, 04 Sep 2019 15:32:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5b0r-000396-Ni for qemu-devel@nongnu.org; Wed, 04 Sep 2019 15:32:19 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:40829) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i5b0r-00031c-Bx for qemu-devel@nongnu.org; Wed, 04 Sep 2019 15:32:17 -0400 Received: by mail-pg1-x542.google.com with SMTP id w10so11781623pgj.7 for ; Wed, 04 Sep 2019 12:32:09 -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=kYh+jTzMtTJhUz3xyrw306VQI42LXaHYhBmdbXyrNe4=; b=j8z0f6M1DbmESvbrLP6Ai+6mNPVjcfyALCXzvJ+N1/hv/9xQp9JCdpBI7SVBvIu9us dql2/jSKMRgHEIJBT87Y18/fvO5kg236IRb0R6mNAp2s1BM/dQKOcDh4pkLRj3KxyMpW EYZGWPeNCf9hKbhr6k4RyaFinT6JUsL+kAwurUYhd+1lj8qnzdATs5bJUuhVPbbD+UrR bqXrYY6XG3HezqMhic337kD9dUddbDt/XAQOUB1UWeleSsVnEyZqvmHLHg7MzbSvMbNa +9N/TZRp5aOclAy048u5yLVwIrFvs6xlm1lnoGCiBZseVztVV+3fwL3JNt69ZyotcQf4 r52g== 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=kYh+jTzMtTJhUz3xyrw306VQI42LXaHYhBmdbXyrNe4=; b=n3yyG6y8kjaaKr3jKUFgjzxfktwYPPiz/rSwEA3oT4u4KOXURRi7M1e958TQok+/2j U+8jbsLQtefGud4h/dEO6qUiosQ2hUKelMaEGYdfnVKOU558ZApkD8XsiCBc2Qu0hTlf VU4PnXBrq1qA+so6tyU9xnmb+XrnegQEltSviUFp436fMu1VRJNnmavn4WybY2cRvcMy c6Sm7U0J9PW0Sk661M+mxnFkV5q4pdng3DcKidrdsRJ1qMj0g+8bQucnSi+V9fiKkqUK yliTavkrBw4+0TXHOeh0Men1G06NYoAbHmN8Li58iUiOhtznd56us2R7q0aBoF/U3RAO Sn4Q== X-Gm-Message-State: APjAAAV3HWK6+LzopqlRk9bMaBs73uCequIM76QeGsVsPfdVykx0Dn0n p6hJPTiNtd/th/xI5B9afU4/8ZfK5Ms= X-Received: by 2002:a65:4c4d:: with SMTP id l13mr35822424pgr.156.1567625528338; Wed, 04 Sep 2019 12:32:08 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id f6sm18999174pga.50.2019.09.04.12.32.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2019 12:32:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 4 Sep 2019 12:30:43 -0700 Message-Id: <20190904193059.26202-54-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190904193059.26202-1-richard.henderson@linaro.org> References: <20190904193059.26202-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::542 Subject: [Qemu-devel] [PATCH v4 53/69] target/arm: Convert T16 branch and exchange X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/translate.c | 70 +++++++++++++++++------------------------- target/arm/t16.decode | 10 ++++++ 2 files changed, 39 insertions(+), 41 deletions(-) -- 2.17.1 diff --git a/target/arm/translate.c b/target/arm/translate.c index 405176527c..e6ef935247 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -8364,7 +8364,7 @@ static bool trans_BX(DisasContext *s, arg_BX *a) if (!ENABLE_ARCH_4T) { return false; } - gen_bx(s, load_reg(s, a->rm)); + gen_bx_excret(s, load_reg(s, a->rm)); return true; } @@ -8391,6 +8391,32 @@ static bool trans_BLX_r(DisasContext *s, arg_BLX_r *a) return true; } +/* + * BXNS/BLXNS: only exist for v8M with the security extensions, + * and always UNDEF if NonSecure. We don't implement these in + * the user-only mode either (in theory you can use them from + * Secure User mode but they are too tied in to system emulation). + */ +static bool trans_BXNS(DisasContext *s, arg_BXNS *a) +{ + if (!s->v8m_secure || IS_USER_ONLY) { + unallocated_encoding(s); + } else { + gen_bxns(s, a->rm); + } + return true; +} + +static bool trans_BLXNS(DisasContext *s, arg_BLXNS *a) +{ + if (!s->v8m_secure || IS_USER_ONLY) { + unallocated_encoding(s); + } else { + gen_blxns(s, a->rm); + } + return true; +} + static bool trans_CLZ(DisasContext *s, arg_CLZ *a) { TCGv_i32 tmp; @@ -10756,49 +10782,11 @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) } break; case 3: - { /* 0b0100_0111_xxxx_xxxx * - branch [and link] exchange thumb register + * In decodetree */ - bool link = insn & (1 << 7); - - if (insn & 3) { - goto undef; - } - if (link) { - ARCH(5); - } - if ((insn & 4)) { - /* BXNS/BLXNS: only exists for v8M with the - * security extensions, and always UNDEF if NonSecure. - * We don't implement these in the user-only mode - * either (in theory you can use them from Secure User - * mode but they are too tied in to system emulation.) - */ - if (!s->v8m_secure || IS_USER_ONLY) { - goto undef; - } - if (link) { - gen_blxns(s, rm); - } else { - gen_bxns(s, rm); - } - break; - } - /* BLX/BX */ - tmp = load_reg(s, rm); - if (link) { - val = (uint32_t)s->base.pc_next | 1; - tmp2 = tcg_temp_new_i32(); - tcg_gen_movi_i32(tmp2, val); - store_reg(s, 14, tmp2); - gen_bx(s, tmp); - } else { - /* Only BX works as exception-return, not BLX */ - gen_bx_excret(s, tmp); - } - break; - } + goto illegal_op; } break; } diff --git a/target/arm/t16.decode b/target/arm/t16.decode index 0654275e68..edddbfb9b8 100644 --- a/target/arm/t16.decode +++ b/target/arm/t16.decode @@ -24,6 +24,7 @@ &s_rri_rot !extern s rn rd imm rot &s_rrrr !extern s rd rn rm ra &ri !extern rd imm +&r !extern rm &ldst_rr !extern p w u rn rt rm shimm shtype &ldst_ri !extern p w u rn rt imm &ldst_block !extern rn i b u w list @@ -144,3 +145,12 @@ MOV_rxi 00100 ... ........ @arith_1i %s CMP_xri 00101 ... ........ @arith_1i s=1 ADD_rri 00110 ... ........ @arith_1i %s SUB_rri 00111 ... ........ @arith_1i %s + +# Branch and exchange + +@branchr .... .... . rm:4 ... &r + +BX 0100 0111 0 .... 000 @branchr +BLX_r 0100 0111 1 .... 000 @branchr +BXNS 0100 0111 0 .... 100 @branchr +BLXNS 0100 0111 1 .... 100 @branchr