From nobody Tue Feb 10 02:28:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547123034689216.78426730524552; Thu, 10 Jan 2019 04:23:54 -0800 (PST) Received: from localhost ([127.0.0.1]:57522 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghZNJ-0000AD-5z for importer@patchew.org; Thu, 10 Jan 2019 07:23:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56112) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghZHf-0004bc-Mj for qemu-devel@nongnu.org; Thu, 10 Jan 2019 07:18:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ghZHe-0007he-PN for qemu-devel@nongnu.org; Thu, 10 Jan 2019 07:18:03 -0500 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]:45642) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ghZHe-0007gy-Ir for qemu-devel@nongnu.org; Thu, 10 Jan 2019 07:18:02 -0500 Received: by mail-pf1-x42d.google.com with SMTP id g62so5212170pfd.12 for ; Thu, 10 Jan 2019 04:18:02 -0800 (PST) Received: from cloudburst.twiddle.net (c220-239-117-135.belrs4.nsw.optusnet.com.au. [220.239.117.135]) by smtp.gmail.com with ESMTPSA id h74sm140934699pfd.35.2019.01.10.04.17.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Jan 2019 04:18:00 -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=PRWaIbFhaCG50KtAhIfgw4/3zpMsZFNNO0ITZ9DcBeA=; b=NzarwsFOGde2+MjQqUPVg6cvBcCLs77h03WkxcnrLtGvYjPr5NedwlCyHwbH0bP6i6 MQhxNcH2TCOEQJzoJOAs4ONEK6rvceU3jr68kNE62UTtGnJOZla/mOuLAi3yCApg+ozr TlTdt3RyQrRhWOG9dmxKCm9kkbDmygsbfZMSg= 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=PRWaIbFhaCG50KtAhIfgw4/3zpMsZFNNO0ITZ9DcBeA=; b=supVwv2XXS65utpM4i6ys7LeRbKv6rXxRgtcPVLqlUs5T9mUpTVtZRlgINi6PJ5qAK PCVHw0a54ikKP5pfCTsFd5e0sCtUjXaYZHgtTmZ/GXNbvSHCZgXhk5CStvrSq/ypYgN4 huSkLrHo/NHiNmdHbFX2LMQ2zLS7tc0d8+acPTe4rWMHZUMK44Ea5wx5PpMY4cTjzd93 wJecE2G0JlRfkSSXuRggIjoZacwJ4EfsI16QRYIzwUmtq84JBkPS9h4tuv5vhzq8uWft OAwnqmpmVIfsXiouk2YFEaRkl5a7H2bSDrId5qyZwxitGuBdcnN0+91Pn7mWUbNwUUMz 33OQ== X-Gm-Message-State: AJcUukd74Cbyb/dpH2leTmPEOUCLvbT4PymbrrDPiOjCzWqCe4sDtRde aYV7sKaUHgAghDDIr0IE4UgWvCDsZLVBQg== X-Google-Smtp-Source: ALg8bN6LtAByo5WsynrHCswj2sOxMCS/RSzVvplvjJ0gZn0kTulNgf1FWICytX2+kgqsczBKVYJxTw== X-Received: by 2002:a62:710a:: with SMTP id m10mr9977016pfc.69.1547122681193; Thu, 10 Jan 2019 04:18:01 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 10 Jan 2019 23:17:32 +1100 Message-Id: <20190110121736.23448-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190110121736.23448-1-richard.henderson@linaro.org> References: <20190110121736.23448-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::42d Subject: [Qemu-devel] [PATCH 07/11] target/arm: Set btype for indirect branches 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/arm/translate-a64.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index f319fa000e..5f0ecb297f 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -138,6 +138,19 @@ static void reset_btype(DisasContext *s) } } =20 +static void set_btype(DisasContext *s, int val) +{ + TCGv_i32 tcg_val; + + /* BTYPE is a 2-bit field, and 0 should be done with reset_btype. */ + tcg_debug_assert(val >=3D 1 && val <=3D 3); + + tcg_val =3D tcg_const_i32(val); + tcg_gen_st_i32(tcg_val, cpu_env, offsetof(CPUARMState, btype)); + tcg_temp_free_i32(tcg_val); + s->btype =3D -1; +} + void aarch64_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf, int flags) { @@ -1985,6 +1998,7 @@ static void disas_exc(DisasContext *s, uint32_t insn) static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) { unsigned int opc, op2, op3, rn, op4; + unsigned btype_mod =3D 2; TCGv_i64 dst; TCGv_i64 modifier; =20 @@ -2002,6 +2016,7 @@ static void disas_uncond_b_reg(DisasContext *s, uint3= 2_t insn) case 0: /* BR */ case 1: /* BLR */ case 2: /* RET */ + btype_mod =3D opc; switch (op3) { case 0: /* BR, BLR, RET */ @@ -2045,7 +2060,6 @@ static void disas_uncond_b_reg(DisasContext *s, uint3= 2_t insn) default: goto do_unallocated; } - gen_a64_set_pc(s, dst); /* BLR also needs to load return address */ if (opc =3D=3D 1) { @@ -2061,6 +2075,7 @@ static void disas_uncond_b_reg(DisasContext *s, uint3= 2_t insn) if (op3 !=3D 2 || op3 !=3D 3) { goto do_unallocated; } + btype_mod =3D opc & 1; if (s->pauth_active) { dst =3D new_tmp_a64(s); modifier =3D cpu_reg_sp(s, op4); @@ -2144,6 +2159,26 @@ static void disas_uncond_b_reg(DisasContext *s, uint= 32_t insn) return; } =20 + switch (btype_mod) { + case 0: /* BR */ + if (dc_isar_feature(aa64_bti, s)) { + /* BR to {x16,x17} or !guard -> 1, else 3. */ + set_btype(s, rn =3D=3D 16 || rn =3D=3D 17 || !s->guarded_page = ? 1 : 3); + } + break; + + case 1: /* BLR */ + if (dc_isar_feature(aa64_bti, s)) { + /* BLR sets BTYPE to 2, regardless of source guarded page. */ + set_btype(s, 2); + } + break; + + default: /* RET or none of the above. */ + /* BTYPE will be set to 0 by normal end-of-insn processing. */ + break; + } + s->base.is_jmp =3D DISAS_JUMP; } =20 --=20 2.17.2