From patchwork Fri Feb 1 16:06:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 157273 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp636567jaa; Fri, 1 Feb 2019 08:22:17 -0800 (PST) X-Google-Smtp-Source: ALg8bN7WqZJVrdRb1puk6T8Zs64Rime+X6r0lmZWcX3DswiPSTy2AK2cM0CHv+kwcA2it4UiXKIt X-Received: by 2002:a5b:791:: with SMTP id b17mr38457650ybq.172.1549038136994; Fri, 01 Feb 2019 08:22:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549038136; cv=none; d=google.com; s=arc-20160816; b=Z2oGKTuxbdln7FGYgNBZ5BwN0L/vbi0ivtEGgZDW/B4roKGj3lx3HEa1p0Dxpig50q 9GvrzGKPdq9BQiHqQKjUZq2N6ifFAZvro0rcSKbol0uc9OQ40GqAlJf4o/JHcY52b4+o SXV5CNaIPRfRwqVppQaFykb/BtZ2lpO5Sa7CQxnUrTjloQuWbKWq+vVGaLL4RB+H8l1X xxQayLCADzy3PaO5cLrR/CIsreIQUqc2rs+V3hnt369rZXLNeNXms60N+VUilA7sJf7a pLJVQFAqM85TvFewZf2aAqXV5JYTG3tC6ayp9fEdh420R2xyc35XCs4TKCiUF8RxY7j+ 3TjA== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=B/UucwWChTaW08M3YZajzMy5v3A/FpvEhhZ/4x3ykfA=; b=L1E2NfFTr7PTr4stuxVPqcV3iI+GEEqvK5ew5rABNA4suMVOsPXKOm/d9TM+C4XFF5 EycVqNfHHJTgLvb4RXcPPvr+/rIA3BGWjoiiY8JVdeIhYWBlpB0LWbSCwd0LLLRBz2Y4 KqPUpRTf3FQAxWiMPtS0PyJ3bcuThvNbMOVZmMtmtlqBsfYovlQ3qDh3NfVY90ypVAVp Y8O5XgcKUe5sKZhUHdqS9dP9rggZuxwFCf596JUZYrlH1MqU2x05VKKvpbHKKjXXSzLg 0Ki/TJxw2P4FD844akvpoUQGchOPeIueT9e4ncIIGle+XZvGs6fYdeLmfFbdDNojGhD8 9WdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=iRYYhJjd; 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 x92si4936750ybh.363.2019.02.01.08.22.16 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Feb 2019 08:22:16 -0800 (PST) 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=iRYYhJjd; 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 ([127.0.0.1]:57456 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpba4-0003iH-C4 for patch@linaro.org; Fri, 01 Feb 2019 11:22:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58937) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpbMC-0008F2-3O for qemu-devel@nongnu.org; Fri, 01 Feb 2019 11:08:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gpbM9-0003hf-Tc for qemu-devel@nongnu.org; Fri, 01 Feb 2019 11:07:56 -0500 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:34190) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gpbM9-0003W8-JV for qemu-devel@nongnu.org; Fri, 01 Feb 2019 11:07:53 -0500 Received: by mail-wr1-x42d.google.com with SMTP id f7so7744098wrp.1 for ; Fri, 01 Feb 2019 08:07:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=B/UucwWChTaW08M3YZajzMy5v3A/FpvEhhZ/4x3ykfA=; b=iRYYhJjdudUdCFpaCoxizKsftvl53NYiLr0xMVDek/Wg4AhAFCEZ+jz8VHhwjQtl/p Gb5nmHHe25TqPdOaXcoHS8USAkNFgar3ZWzIRvTXL+mgVi66seYsjhHBghfcUGbPxXOl L2MsCm9C3Lh+Fbcm0sw0BKKhka4SbEC7Ze0dc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=B/UucwWChTaW08M3YZajzMy5v3A/FpvEhhZ/4x3ykfA=; b=ujRrQzBsR12F/TL45vBbT4xOh2GEhm7jHnQ+f+phy5u3dUfOjfey7zqwXWBQS6UnSc 5gkdyNaT6NhsFnPH0k5ug4A6c3RfUmFdLvZyUzOZWPGSN1h9iH65VSFaVimZp+G64QR0 kylTMPpKb3D7TJZW32I0p27Y2ESXUSDJ29jY6DuwseO4VdjnayCG52jYYIyb9oqwmlk2 lz9O/OSCneP4kYClyccpD+lbDCgQyLXsgC8UHyGhWC7nyfgmi48oLtKj/Ru825EV2uNL jwbAkXXMYhMdspkydbGbwsoajFsVOAnxz3KSScwCmEV8OFb59sDs+v2pZUVnYtnHgo0r 8npQ== X-Gm-Message-State: AJcUukfSZkhGPggH66Dp5AFqXOScEGdTd+uIFw3p1GKIiiltfZVphclc 4h7nh5NaycJschziis85FsSyu83f5huIBw== X-Received: by 2002:adf:9d85:: with SMTP id p5mr37612693wre.41.1549037254463; Fri, 01 Feb 2019 08:07:34 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id n6sm2847250wmk.9.2019.02.01.08.07.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Feb 2019 08:07:33 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 1 Feb 2019 16:06:36 +0000 Message-Id: <20190201160653.13829-31-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201160653.13829-1-peter.maydell@linaro.org> References: <20190201160653.13829-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42d Subject: [Qemu-devel] [PULL 30/47] target/arm/translate-a64: Don't underdecode FP insns 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" In the encoding groups * floating-point data-processing (1 source) * floating-point data-processing (2 source) * floating-point data-processing (3 source) * floating-point immediate * floating-point compare * floating-ponit conditional compare * floating-point conditional select bit 31 is M and bit 29 is S (and bit 30 is 0, already checked at this point in the decode). None of these groups allocate any encoding for M=1 or S=1. We checked this in disas_fp_compare(), disas_fp_ccomp() and disas_fp_csel(), but missed it in disas_fp_1src(), disas_fp_2src(), disas_fp_3src() and disas_fp_imm(). We also missed that in the fp immediate encoding the imm5 field must be all zeroes. Correctly UNDEF the unallocated encodings here. Reported-by: Laurent Desnogues Signed-off-by: Peter Maydell Reviewed-by: Laurent Desnogues Message-id: 20190125182626.9221-7-peter.maydell@linaro.org --- target/arm/translate-a64.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 94907f0ae97..6c4b20daf2c 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -5636,11 +5636,17 @@ static void handle_fp_fcvt(DisasContext *s, int opcode, */ static void disas_fp_1src(DisasContext *s, uint32_t insn) { + int mos = extract32(insn, 29, 3); int type = extract32(insn, 22, 2); int opcode = extract32(insn, 15, 6); int rn = extract32(insn, 5, 5); int rd = extract32(insn, 0, 5); + if (mos) { + unallocated_encoding(s); + return; + } + switch (opcode) { case 0x4: case 0x5: case 0x7: { @@ -5867,13 +5873,14 @@ static void handle_fp_2src_half(DisasContext *s, int opcode, */ static void disas_fp_2src(DisasContext *s, uint32_t insn) { + int mos = extract32(insn, 29, 3); int type = extract32(insn, 22, 2); int rd = extract32(insn, 0, 5); int rn = extract32(insn, 5, 5); int rm = extract32(insn, 16, 5); int opcode = extract32(insn, 12, 4); - if (opcode > 8) { + if (opcode > 8 || mos) { unallocated_encoding(s); return; } @@ -6028,6 +6035,7 @@ static void handle_fp_3src_half(DisasContext *s, bool o0, bool o1, */ static void disas_fp_3src(DisasContext *s, uint32_t insn) { + int mos = extract32(insn, 29, 3); int type = extract32(insn, 22, 2); int rd = extract32(insn, 0, 5); int rn = extract32(insn, 5, 5); @@ -6036,6 +6044,11 @@ static void disas_fp_3src(DisasContext *s, uint32_t insn) bool o0 = extract32(insn, 15, 1); bool o1 = extract32(insn, 21, 1); + if (mos) { + unallocated_encoding(s); + return; + } + switch (type) { case 0: if (!fp_access_check(s)) { @@ -6105,12 +6118,19 @@ uint64_t vfp_expand_imm(int size, uint8_t imm8) static void disas_fp_imm(DisasContext *s, uint32_t insn) { int rd = extract32(insn, 0, 5); + int imm5 = extract32(insn, 5, 5); int imm8 = extract32(insn, 13, 8); int type = extract32(insn, 22, 2); + int mos = extract32(insn, 29, 3); uint64_t imm; TCGv_i64 tcg_res; TCGMemOp sz; + if (mos || imm5) { + unallocated_encoding(s); + return; + } + switch (type) { case 0: sz = MO_32;