From patchwork Tue Jan 8 22:31:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 155026 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp41796jaa; Tue, 8 Jan 2019 14:47:02 -0800 (PST) X-Google-Smtp-Source: ALg8bN7f0dj4d5NQ2nr6RAry95TgMLKUrVTvE76+wVA+WnYtbpLmHIOdhCNTj0i2d+XBVadBrz7T X-Received: by 2002:a1c:2457:: with SMTP id k84mr3124605wmk.139.1546987621927; Tue, 08 Jan 2019 14:47:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546987621; cv=none; d=google.com; s=arc-20160816; b=fxajgR5XIQllyI1W98J0BkvRpl4+xXQHUJgGjeCGnHB5gtnF93h1aoDU5c91BIvhsJ TfGGip6hVj6mr1vO4cKtfaPhgVUv9kPo0ql9UIdGP9X3vrdZkH3bTeTPa6GQ6W9KASOn 9c3ksMCk526RPgLwRi4DyXQsgBZ5hvk5aUmQtns+8uPBk68L/efnG+LsOZENZEc4nCFP PJWIkZHYEYFFePtnCqBwj3YjpwFWxvkOXg4LwpNTs7M8x3OgvrL0IIoG2jfP9bDynS6/ 4R8k+ossqiHhOOn4vkbGzbWDdoQqeVDjRVja/1blddF5ilofO7B99IGsNgbXSAIfKLoq lC6A== 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=WDCmraVytCVp2uFN73TTP/9xo07ZZ0ObLi7t4pJW3JA=; b=wLdEuBvbDqBvfh5X2Kdc3Zc7sjOVybwNo4YonSJ3ZeFHvl7tS62Y/bv7AmMYV+lOGY BOIByVBxHOQXbxQLG43uSSV9feZ5J/f8KskpqmmW6IxIROE55C2UNswpg14Xbszaw/1k X9V5qi4gsa3i1lfImCxp7S+pZrtOs2iFDI5FD2iSVzbGT3tI7au80QIfajRUNBN7IcRE TdTpN/fUUzUPDyXQIMHHJCOE6S3LsuiMxWxiMLmX6ykudtUarXUBAb4fbU/Ru6WMS2KH ful5Ni0fpHpxNNvm73wnG2Xb7ALB6+ZNc2xARLXUl8bNvGCBEiPp0LfHIR23e+XuezwL 3S2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jXBE5C17; 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 h185si1013112wme.5.2019.01.08.14.47.01 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 08 Jan 2019 14:47:01 -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=jXBE5C17; 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]:43203 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gh09E-0004dL-L4 for patch@linaro.org; Tue, 08 Jan 2019 17:47:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52695) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggzv5-00009q-B0 for qemu-devel@nongnu.org; Tue, 08 Jan 2019 17:32:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ggzv4-0004lD-D8 for qemu-devel@nongnu.org; Tue, 08 Jan 2019 17:32:23 -0500 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:34528) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ggzv3-0004b3-Gs for qemu-devel@nongnu.org; Tue, 08 Jan 2019 17:32:21 -0500 Received: by mail-pf1-x442.google.com with SMTP id h3so2625655pfg.1 for ; Tue, 08 Jan 2019 14:32:11 -0800 (PST) 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=WDCmraVytCVp2uFN73TTP/9xo07ZZ0ObLi7t4pJW3JA=; b=jXBE5C17wp/0FbJPVfp92h1OyAwVnbDKJzg4CA7KdrgYS0aF396XYH7OS4FoHiIw3O tmqxrC9mUL+MKx3OBGpsd/hcLEAHIZm/xxhmHT0EK75ZY1P4hZXOLEe6uxE5ObJpHDhx rVe1TTzylSkgXavjGoYqXEbaY816FY9m3eJfc= 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=WDCmraVytCVp2uFN73TTP/9xo07ZZ0ObLi7t4pJW3JA=; b=rHuhJ5K7HiYBPG1y8brVEhe5x3UbgKwBaktwfNKcvaAEi4Gl3fRrx/tC4qaRYlmy1G 7+IMFfWb6oWjwzekYZRbhnJ0cRceDbOhproyTz+1I14WfAJDWuj/LqxEtjyAY2GROT7V Mzcthk0tGuqJYeM8HrBPr+6Y/hR/62rUl6uz18/RCtnnOf8wXaYKHUYpO1rbAgDXqgY6 t/cicog1lSY+lS5tzsJec5m4K/lV943BqRkVMmEkahPi2+4Aakx5J4CTiBsg+vPvC5NF H3n47o+9+cg3UFS21P7CdhEcF8TPZpzfVQSGOpJHc3dUMr6Wlj9eyY0JBU0K+zCkkOKR Hl0g== X-Gm-Message-State: AJcUukdRj0O/tn85fDpze7HfeUkKHumwOxEBGfFPc1sBhP4u9qY6FTeE nJ3JnbRHB1UuxK/PWUi1xDn6Lqj33JI= X-Received: by 2002:a62:2082:: with SMTP id m2mr3429485pfj.163.1546986730269; Tue, 08 Jan 2019 14:32:10 -0800 (PST) Received: from cloudburst.lan (2001-44b8-2176-c800-8cc6-2630-7d99-5ef1.static.ipv6.internode.on.net. [2001:44b8:2176:c800:8cc6:2630:7d99:5ef1]) by smtp.gmail.com with ESMTPSA id w128sm100686177pfw.79.2019.01.08.14.32.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 Jan 2019 14:32:09 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 9 Jan 2019 08:31:11 +1000 Message-Id: <20190108223129.5570-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190108223129.5570-1-richard.henderson@linaro.org> References: <20190108223129.5570-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::442 Subject: [Qemu-devel] [PATCH v3 13/31] target/arm: Decode PAuth within disas_uncond_b_reg 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" Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/translate-a64.c | 82 +++++++++++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) -- 2.17.2 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index e601753032..fa50003f0b 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -1982,6 +1982,7 @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) { unsigned int opc, op2, op3, rn, op4; TCGv_i64 dst; + TCGv_i64 modifier; opc = extract32(insn, 21, 4); op2 = extract32(insn, 16, 5); @@ -1999,12 +2000,44 @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) case 2: /* RET */ switch (op3) { case 0: + /* BR, BLR, RET */ if (op4 != 0) { goto do_unallocated; } dst = cpu_reg(s, rn); break; + case 2: + case 3: + if (!dc_isar_feature(aa64_pauth, s)) { + goto do_unallocated; + } + if (opc == 2) { + /* RETAA, RETAB */ + if (rn != 0x1f || op4 != 0x1f) { + goto do_unallocated; + } + rn = 30; + modifier = cpu_X[31]; + } else { + /* BRAAZ, BRABZ, BLRAAZ, BLRABZ */ + if (op4 != 0x1f) { + goto do_unallocated; + } + modifier = new_tmp_a64_zero(s); + } + if (s->pauth_active) { + dst = new_tmp_a64(s); + if (op3 == 2) { + gen_helper_autia(dst, cpu_env, cpu_reg(s, rn), modifier); + } else { + gen_helper_autib(dst, cpu_env, cpu_reg(s, rn), modifier); + } + } else { + dst = cpu_reg(s, rn); + } + break; + default: goto do_unallocated; } @@ -2016,12 +2049,38 @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) } break; + case 8: /* BRAA */ + case 9: /* BLRAA */ + if (!dc_isar_feature(aa64_pauth, s)) { + goto do_unallocated; + } + if (op3 != 2 || op3 != 3) { + goto do_unallocated; + } + if (s->pauth_active) { + dst = new_tmp_a64(s); + modifier = cpu_reg_sp(s, op4); + if (op3 == 2) { + gen_helper_autia(dst, cpu_env, cpu_reg(s, rn), modifier); + } else { + gen_helper_autib(dst, cpu_env, cpu_reg(s, rn), modifier); + } + } else { + dst = cpu_reg(s, rn); + } + gen_a64_set_pc(s, dst); + /* BLRAA also needs to load return address */ + if (opc == 9) { + tcg_gen_movi_i64(cpu_reg(s, 30), s->pc); + } + break; + case 4: /* ERET */ if (s->current_el == 0) { goto do_unallocated; } switch (op3) { - case 0: + case 0: /* ERET */ if (op4 != 0) { goto do_unallocated; } @@ -2030,6 +2089,27 @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) offsetof(CPUARMState, elr_el[s->current_el])); break; + case 2: /* ERETAA */ + case 3: /* ERETAB */ + if (!dc_isar_feature(aa64_pauth, s)) { + goto do_unallocated; + } + if (rn != 0x1f || op4 != 0x1f) { + goto do_unallocated; + } + dst = tcg_temp_new_i64(); + tcg_gen_ld_i64(dst, cpu_env, + offsetof(CPUARMState, elr_el[s->current_el])); + if (s->pauth_active) { + modifier = cpu_X[31]; + if (op3 == 2) { + gen_helper_autia(dst, cpu_env, dst, modifier); + } else { + gen_helper_autib(dst, cpu_env, dst, modifier); + } + } + break; + default: goto do_unallocated; }