From patchwork Wed Sep 4 19:30:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 172978 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp364158ilq; Wed, 4 Sep 2019 12:47:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqzFzCgugdZbSLktkzEQEExRV1m0breQgBxUWDdNeN8Rw/NgQNTCw/CmHw0YqVmGr07HUyUx X-Received: by 2002:a17:906:b35a:: with SMTP id cd26mr33885967ejb.243.1567626435874; Wed, 04 Sep 2019 12:47:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567626435; cv=none; d=google.com; s=arc-20160816; b=VwO7fafolOq3U+fOzJLMMY3XWdcSsRawPVI66E5NM02suje/txa5o6z3nOfzq/DT6v V3zaKcXfqem/iS5roXF8x7DOQ+StiTG3UeJWvzWCH72mDG7sTb9ccB+ycZf+9PkcUTv3 fzTaMbEMEP63L6C7mAb8Pu233pdvnJO5BptU8buXxIPfnnCuqNsMLNR9DRPMjhia5qvs nOKZCsgFph2X35IKHhHL3LS6kTad4rXGH25ce8b5EHPF+KBraXVjGj21bE+74+gzlcvz ohjr3FFSzHMCa/Zv94c5FEPD3LAJNiT9e+TvBG8uHWRuDPkgH5ExPgM/f2AEK9PrH746 /S1A== 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=qIboakrWv9IiGA+mdMxhBvLjlTlOJK5d1FVqxlQZi7U=; b=yZlFu/II5w8EhZTQ1VP5G7o2Q/9/x9e6WiDL1g7FGy3yaHgQhZtWi43OeK/eoSqXQO dvAN37ogAAJYoDTurB/Y15cHcG+yZIPwxi2t64SgPDiH6U4GTKhgm70fjri6Hid4nB+W HR+3r0YHnwqKIYmhnm7DtKRpevxi9FUY91xE5WwveIBhdrR4hJ/wIEvdrgEii4eqAl31 JzG3G8/oeQcmfwV3IdeQO19prIeLdbZKtoHKPmqZLLAz5QDrj2a7P8lWjrF0glwp2Z4O xI7v295Pt9eyW1k72KYmOtDAD1iKuLZA85wCTf7B0RwacEg63yMQpFb1QGlwkVWbREkk kC0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=tHoGUVce; 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 s56si6144942eda.145.2019.09.04.12.47.15 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Sep 2019 12:47: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=fail header.i=@linaro.org header.s=google header.b=tHoGUVce; 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]:37782 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5bFJ-0002sL-Vl for patch@linaro.org; Wed, 04 Sep 2019 15:47:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39959) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5azv-0004KC-Eh for qemu-devel@nongnu.org; Wed, 04 Sep 2019 15:31:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5azt-0002Ek-JI for qemu-devel@nongnu.org; Wed, 04 Sep 2019 15:31:19 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:42985) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i5azt-0002E1-Ab for qemu-devel@nongnu.org; Wed, 04 Sep 2019 15:31:17 -0400 Received: by mail-pl1-x643.google.com with SMTP id y1so10011102plp.9 for ; Wed, 04 Sep 2019 12:31:17 -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=qIboakrWv9IiGA+mdMxhBvLjlTlOJK5d1FVqxlQZi7U=; b=tHoGUVceZAs8Vh4SMtRsAay5YBKllYR3EERReCZ7oqZws/QiS1wYSKRM01SXA5Fz/n nDYYu9GVabSJr0K/i667V2zI2nkC+Yd6c7DlxkNjOK9GYBZtvSCpBHNkTIYtA0D4kCgp +ScJJ6BeKxvmnukc0AKJCa9lw8P9ArRPH88riZPYm/pJLFZXIis3TeWztY3LhYa0VzXr KNgNINPkEXloRwEgUw5oUXCHyi+8GMSQhCaPmaZQh/PxqLJm3BzbTXkVxsZHPwX6oOGd 7iwYhlttSJVKEevJEvOsD/SaPje29+1mq2zsGzi8nEvhmdo3ttGhUmrN1J5QrGUbH8WB iWeg== 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=qIboakrWv9IiGA+mdMxhBvLjlTlOJK5d1FVqxlQZi7U=; b=eRM0zmQ0RVCLT1rsasTurd8p3Q5JAOYby4h089fprA2bIxQwQRFwb4WWvYMOBsVai/ BuNukEx+e9HuUrMDd8lfBhNjpm873A9On3hsd+lO989PRNXa8fKbGvjxAMG+f5MZ4SRx Q0Q/hudrMC9ku0mAEpF0sZevUFg4kF7wnImGyNUyEl2C5koEVhnAn2beGPVKZZg6q4Lt 6a3hw1JnhWErvmoiyHAlHY2nk/uheqvQJcXX+mKhHanwUK5kzzA0wrDDkS3WsFpngXt2 XRD0vsvQso12gZxwSlqoMOxCn4hnSI3k/vikzGxMwQhgTpynr6s9gI95z19NbZwDa3nQ 2ldQ== X-Gm-Message-State: APjAAAXCjedoeEsmkGO5K+xrR5HUyXf7t1xrSabY6BOeTaDbYe34Yh5s 3Vulz42xQPklRkjetBo+ivfT/xtxBjM= X-Received: by 2002:a17:902:6842:: with SMTP id f2mr43499203pln.39.1567625476030; Wed, 04 Sep 2019 12:31:16 -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.31.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2019 12:31:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 4 Sep 2019 12:30:02 -0700 Message-Id: <20190904193059.26202-13-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::643 Subject: [Qemu-devel] [PATCH v4 12/69] target/arm: Convert MSR (immediate) and hints 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 | 60 +++++++++++++++++++++++++++++------------- target/arm/a32.decode | 25 ++++++++++++++++++ target/arm/t32.decode | 17 ++++++++++++ 3 files changed, 84 insertions(+), 18 deletions(-) -- 2.17.1 diff --git a/target/arm/translate.c b/target/arm/translate.c index 71cc96b70e..58bfbb8ed9 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -8282,6 +8282,44 @@ DO_SMLAWX(SMLAWT, 1, 1) #undef DO_SMLAWX +/* + * MSR (immediate) and hints + */ + +static bool trans_YIELD(DisasContext *s, arg_YIELD *a) +{ + gen_nop_hint(s, 1); + return true; +} + +static bool trans_WFE(DisasContext *s, arg_WFE *a) +{ + gen_nop_hint(s, 2); + return true; +} + +static bool trans_WFI(DisasContext *s, arg_WFI *a) +{ + gen_nop_hint(s, 3); + return true; +} + +static bool trans_NOP(DisasContext *s, arg_NOP *a) +{ + return true; +} + +static bool trans_MSR_imm(DisasContext *s, arg_MSR_imm *a) +{ + uint32_t val = ror32(a->imm, a->rot * 2); + uint32_t mask = msr_mask(s, a->mask, a->r); + + if (gen_set_psr_im(s, mask, a->r, val)) { + unallocated_encoding(s); + } + return true; +} + /* * Legacy decoder. */ @@ -8555,21 +8593,9 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) } store_reg(s, rd, tmp); } else { - if (((insn >> 12) & 0xf) != 0xf) - goto illegal_op; - if (((insn >> 16) & 0xf) == 0) { - gen_nop_hint(s, insn & 0xff); - } else { - /* CPSR = immediate */ - val = insn & 0xff; - shift = ((insn >> 8) & 0xf) * 2; - val = ror32(val, shift); - i = ((insn & (1 << 22)) != 0); - if (gen_set_psr_im(s, msr_mask(s, (insn >> 16) & 0xf, i), - i, val)) { - goto illegal_op; - } - } + /* MSR (immediate) and hints */ + /* All done in decodetree. Illegal ops already signalled. */ + g_assert_not_reached(); } } else if ((insn & 0x0f900000) == 0x01000000 && (insn & 0x00000090) != 0x00000090) { @@ -10522,9 +10548,7 @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) goto illegal_op; break; case 2: /* cps, nop-hint. */ - if (((insn >> 8) & 7) == 0) { - gen_nop_hint(s, insn & 0xff); - } + /* nop hints in decodetree */ /* Implemented as NOP in user mode. */ if (IS_USER(s)) break; diff --git a/target/arm/a32.decode b/target/arm/a32.decode index 19d12e726b..3d5c5408f9 100644 --- a/target/arm/a32.decode +++ b/target/arm/a32.decode @@ -22,6 +22,7 @@ # All insns that have 0xf in insn[31:28] are in a32-uncond.decode. # +&empty &s_rrr_shi s rd rn rm shim shty &s_rrr_shr s rn rd rm rs shty &s_rri_rot s rn rd imm rot @@ -152,3 +153,27 @@ SMULBB .... 0001 0110 .... 0000 .... 1000 .... @rd0mn SMULBT .... 0001 0110 .... 0000 .... 1100 .... @rd0mn SMULTB .... 0001 0110 .... 0000 .... 1010 .... @rd0mn SMULTT .... 0001 0110 .... 0000 .... 1110 .... @rd0mn + +# MSR (immediate) and hints + +&msr_i r mask rot imm +@msr_i ---- .... .... mask:4 .... rot:4 imm:8 &msr_i + +{ + { + YIELD ---- 0011 0010 0000 1111 ---- 0000 0001 + WFE ---- 0011 0010 0000 1111 ---- 0000 0010 + WFI ---- 0011 0010 0000 1111 ---- 0000 0011 + + # TODO: Implement SEV, SEVL; may help SMP performance. + # SEV ---- 0011 0010 0000 1111 ---- 0000 0100 + # SEVL ---- 0011 0010 0000 1111 ---- 0000 0101 + + # The canonical nop ends in 00000000, but the whole of the + # rest of the space executes as nop if otherwise unsupported. + NOP ---- 0011 0010 0000 1111 ---- ---- ---- + } + # Note mask = 0 is covered by NOP + MSR_imm .... 0011 0010 .... 1111 .... .... .... @msr_i r=0 +} +MSR_imm .... 0011 0110 .... 1111 .... .... .... @msr_i r=1 diff --git a/target/arm/t32.decode b/target/arm/t32.decode index 122a0537ed..ccb7cdd4ef 100644 --- a/target/arm/t32.decode +++ b/target/arm/t32.decode @@ -19,6 +19,7 @@ # This file is processed by scripts/decodetree.py # +&empty !extern &s_rrr_shi !extern s rd rn rm shim shty &s_rrr_shr !extern s rn rd rm rs shty &s_rri_rot !extern s rn rd imm rot @@ -166,3 +167,19 @@ QADD 1111 1010 1000 .... 1111 .... 1000 .... @rndm QSUB 1111 1010 1000 .... 1111 .... 1010 .... @rndm QDADD 1111 1010 1000 .... 1111 .... 1001 .... @rndm QDSUB 1111 1010 1000 .... 1111 .... 1011 .... @rndm + +# Branches and miscellaneous control + +{ + YIELD 1111 0011 1010 1111 1000 0000 0000 0001 + WFE 1111 0011 1010 1111 1000 0000 0000 0010 + WFI 1111 0011 1010 1111 1000 0000 0000 0011 + + # TODO: Implement SEV, SEVL; may help SMP performance. + # SEV 1111 0011 1010 1111 1000 0000 0000 0100 + # SEVL 1111 0011 1010 1111 1000 0000 0000 0101 + + # The canonical nop ends in 0000 0000, but the whole rest + # of the space is "reserved hint, behaves as nop". + NOP 1111 0011 1010 1111 1000 0000 ---- ---- +}