From patchwork Fri Dec 14 05:23:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 153745 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1673129ljp; Thu, 13 Dec 2018 21:28:07 -0800 (PST) X-Google-Smtp-Source: AFSGD/XgFrSjvOR9BKOC5rLw6StZWS5FCq5EvtZDrPLEqApYoErobQJfFZMWR4vb2hdvdGrhQZVu X-Received: by 2002:a0c:fa8f:: with SMTP id o15mr1497692qvn.135.1544765287637; Thu, 13 Dec 2018 21:28:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544765287; cv=none; d=google.com; s=arc-20160816; b=mOfouVMKU4A8DbzJV8P5TN3hvAZ4GNh9fBWFrRnaXhF+Edvnmt8t4x6UWqnuBBe+hU aBixFBBtlabvavlwOs3pbyJjAvMPo7dKwsXzgRFEuMRdU+fMtwcNgESmDHbNs+25eqlU IajNru0bwro/WkS8VUUSCD5+o7iVKtVS0aeYzXPni3veMlQcS3R6n3lQA5oPqQewlN9R FIc9IQgndgdE0NhhVduCXKVzxWNZbzIlt/TstwJRBNb6tRfYfwzVSFrZzqP8qTtHdxUK +SuaQzc+HhyFaWIsOSh/2w/Drg7YQLLDNPG4Txsb+VqLbHGKxepnIVSJ8rkCrlB/zYys st4Q== 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=ibadInM9T3RbGOG0kOgkioR76NG5vSTRyjFmOZT3e1M=; b=JlemQTS9Ou7kPjD2Kg9l2Uyt58jUDtphwgshx5Zx40VEL/B1wO/3jT0Wt2JupJgr7X M+lm5Wth2Pqm9/z2+p9reqcjPcW479ALH2bF947ICA6OEa0bAGFxZG3pBh3Sig/23UUr tFOaQvojAZvhfRbUo0xHDYB6JWTQTOxJcrh0Mb14bVu9+TKRviIHXhuET92uaEbdiWeV F5cUOf63+GgnLQJM2wjJ5THkxUMNlPpJU7PKO7D2gtk9VIp/AwAkPVhrbobxFKMx5H39 NvPedVnkQmZLVZ4w5zMhsi+fiG8oimvvCiO7+SLRBdHnUJQGR1wB1RH9+AgM3ypR0o+q QemQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=G2FyXZk5; 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 a103si273019qkh.5.2018.12.13.21.28.07 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 13 Dec 2018 21:28:07 -0800 (PST) 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=G2FyXZk5; 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]:59450 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXg19-00077f-2z for patch@linaro.org; Fri, 14 Dec 2018 00:28:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55755) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXfxi-0004TQ-Fx for qemu-devel@nongnu.org; Fri, 14 Dec 2018 00:24:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXfxc-0005Of-9O for qemu-devel@nongnu.org; Fri, 14 Dec 2018 00:24:32 -0500 Received: from mail-ot1-x342.google.com ([2607:f8b0:4864:20::342]:45883) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXfxc-0005OX-3g for qemu-devel@nongnu.org; Fri, 14 Dec 2018 00:24:28 -0500 Received: by mail-ot1-x342.google.com with SMTP id 32so4274299ota.12 for ; Thu, 13 Dec 2018 21:24:28 -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=ibadInM9T3RbGOG0kOgkioR76NG5vSTRyjFmOZT3e1M=; b=G2FyXZk5IaBTItH2bFlTAdbIuCghqoWFITr6oD9zN7Wkku1wsOVuYeVFuPXuAgmgDc NQyWbZygE8j1djJviIGQOdz2pNWKYcFoJxW8tUxrZwa2/f5s+t5AjYkJDC6nt9OYdrWr wiAOUhnNYdPyli4OjyXPUcyEdQvU4qmQQTDCY= 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=ibadInM9T3RbGOG0kOgkioR76NG5vSTRyjFmOZT3e1M=; b=QDUNv+g1z4VkjWZgJDPAIqxvx3nzTDPUdd7VHxotGvYao9W4VB/ftUn7oSX/gJlUaf 9kbEeGOjVqyx8T9NdR1bDVPB+5uHyXgvc9w2qnWBpBr+LUfqxLk9mBhhH1zUt8dXzqFb p3RGdiiCQaJdg5QZZUA8MK+MyhnPW+ctmzwK2tj1G0Pf1KpGVrF1TDT15Up5TQbbkIW8 oN3MXOQK5pliqoBXP4RvjiG0QtqgP5oBWvNhRAjaDaPWQZYMLdARDGTtuQGehhGEL6U6 NDZ0hvycfUK/i/CMhkWERdYFY932J+kvQpAkA2eX3ufPHgfkLqLrKCqrC3Sea5Sy0OnF fOeg== X-Gm-Message-State: AA+aEWb6vmLeQqFcc49ZlFxql6Ji9KCIAuke60aJvDweXZu0TOgnHvk6 cUIMtcWe13wbHaNvUcMnKyxNe6NyJpjqpA== X-Received: by 2002:a9d:7059:: with SMTP id x25mr1204767otj.35.1544765067129; Thu, 13 Dec 2018 21:24:27 -0800 (PST) Received: from cloudburst.twiddle.net ([187.217.227.243]) by smtp.gmail.com with ESMTPSA id r1sm1845379oti.44.2018.12.13.21.24.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Dec 2018 21:24:26 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 13 Dec 2018 23:23:55 -0600 Message-Id: <20181214052410.11863-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181214052410.11863-1-richard.henderson@linaro.org> References: <20181214052410.11863-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::342 Subject: [Qemu-devel] [PATCH v2 12/27] 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" Signed-off-by: Richard Henderson --- target/arm/translate-a64.c | 82 +++++++++++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) -- 2.17.2 Reviewed-by: Peter Maydell diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 30086a5d7f..e62d248894 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; }