From patchwork Tue Jan 8 22:31:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 155037 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp48857jaa; Tue, 8 Jan 2019 14:56:52 -0800 (PST) X-Google-Smtp-Source: ALg8bN4GtRoHFSWW5GxaKz7u77AEYkU+So6nlEvrlBVL96AVG5mSO0m6tGDlet377Q3ZT36T6g+7 X-Received: by 2002:a7b:c1d7:: with SMTP id a23mr3025867wmj.48.1546988212896; Tue, 08 Jan 2019 14:56:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546988212; cv=none; d=google.com; s=arc-20160816; b=b0L9dDO2+XI7cLQfbRvDMzaAagcWKqGY5daw/RW4EN7FpRqfUksqrzZ1uQbiH7fTzc G8UfNCEskWgsi4LZGfv2Yu4E643VPo79WfpfcyxNLlS30ovK+FzPoDNaCOhveDkkDhgn JNlvEpiDGzomWhHhkYk1P9mviCGCGF3h/ARvA15Y0daIrFJscEgUHWuRS06gyCoM5f/E qsE3sROLEu4uRfww8xaUnmP0LCw9Pq3FMlrn6KutuTqjuwaNK8kvb+YKtx1invRPmNVs wUSQktjsU472HznDJuvjNzytuphzVXE/+6+NADETZWEXVubLrkvNgv+v7tgAjjzDPvNj fCRQ== 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=2VgmoHz6byq88BRycDcyAZYok0dhpwf74ougs9E4uA8=; b=nS0NAZLs6EjawizeMua9PyA+uocm3MO3f3sfbSHc+PZwGCF+TRG33aPwxRfQLBHSqP 1ZUUm9uUrBMeNYpLgWjnD4YxKAQ738s6RWQrgppGOFw9JQhZJOr1o1Hi/8LIS6kgSEwe 0ajaNFpyU8p6e0X82To3xSBG4laHQH+NMILqIWWiduwFDc7lOfnTmlrCcqVvLwrdTPjF DxYKELUTx4J884TyiWtdXF3mgEYIZXxWn1uneC3JrkaEMwQFFxH1eMS+iDyQyUUNwj22 TfsqYJWE1rSJmPno7OmxYp7/f9y/Vnac/lOVZCLEHaIvs2LYLse+D3BddR70jFoIyGQn H4uQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GkWQjAP0; 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 200si7650034wmm.114.2019.01.08.14.56.52 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 08 Jan 2019 14:56:52 -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=GkWQjAP0; 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]:45796 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gh0Il-0006NJ-Ox for patch@linaro.org; Tue, 08 Jan 2019 17:56:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53209) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggzvf-0000rT-JV for qemu-devel@nongnu.org; Tue, 08 Jan 2019 17:33:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ggzve-0005UH-Gz for qemu-devel@nongnu.org; Tue, 08 Jan 2019 17:32:59 -0500 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:46912) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ggzve-0005Sp-AJ for qemu-devel@nongnu.org; Tue, 08 Jan 2019 17:32:58 -0500 Received: by mail-pf1-x441.google.com with SMTP id c73so2590359pfe.13 for ; Tue, 08 Jan 2019 14:32:58 -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=2VgmoHz6byq88BRycDcyAZYok0dhpwf74ougs9E4uA8=; b=GkWQjAP0XwjNhj2A1v2Tp8GLovn25sLkhk1SGdtGJka8X2abZO1LZ/dCXAfBfP7OxA 16EKbgmTgISxNSW6F6ksBMzMn30nIFH6b13gpoQw+h/W/L5gCKk7PF1ACnQy+HUmgjLW 2dYkPkMNKymKMwZlXYX+UMLDeRt3+67OIyUiU= 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=2VgmoHz6byq88BRycDcyAZYok0dhpwf74ougs9E4uA8=; b=JnXWPq7UJrx4jPfu6BSbMNfjL5zvC/LbvNc3UgBFFh9At87dcwjUPjqvAYFTepvhwT tBafqbit82AvZsZkT3rW/DNqGyYf9T8lUhqdqdTBeXCacEQ4hzqVFWkQWl4WpvT8SDIx MzZoXV8YP/u0rpGQ99naNHOqXYPQndPupAYQTpEcquk0OuaUn7ODlRnaJI3iU8Fq+Sdu pjAy6rbA/Cb8PIzkiRZxNP6+IwXwHMKQoTrg/1xLWoBnx0glKKsD8AnLq6npqgEB12Dw VzRyDJL+yA7UT8UcpQlDJehkvKlYJl5o4Qydxa3DxPzHBjnJ3MgY3Mps6TCE/8KeDlxA voig== X-Gm-Message-State: AJcUukffR6bf4xJJbMlBj/LgwzgGrPyLZ58RA0xqiKUE12gZDJIKRQmv HwZn+9PnbCI0KJX6tdKJljDvQWPEDhw= X-Received: by 2002:a62:1a44:: with SMTP id a65mr3614473pfa.30.1546986777011; Tue, 08 Jan 2019 14:32:57 -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.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 Jan 2019 14:32:56 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 9 Jan 2019 08:31:29 +1000 Message-Id: <20190108223129.5570-32-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::441 Subject: [Qemu-devel] [PATCH v3 31/31] target/arm: Tidy TBI handling in gen_a64_set_pc 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" We can perform this with fewer operations. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson ---- v3: Update for tbii = tbi1:tbi0. --- target/arm/translate-a64.c | 62 +++++++++++++------------------------- 1 file changed, 21 insertions(+), 41 deletions(-) -- 2.17.2 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index ee92533469..c398da9214 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -261,7 +261,7 @@ void gen_a64_set_pc_im(uint64_t val) /* Load the PC from a generic TCG variable. * * If address tagging is enabled via the TCR TBI bits, then loading - * an address into the PC will clear out any tag in the it: + * an address into the PC will clear out any tag in it: * + for EL2 and EL3 there is only one TBI bit, and if it is set * then the address is zero-extended, clearing bits [63:56] * + for EL0 and EL1, TBI0 controls addresses with bit 55 == 0 @@ -280,54 +280,34 @@ static void gen_a64_set_pc(DisasContext *s, TCGv_i64 src) int tbi = s->tbii; if (s->current_el <= 1) { - /* Test if NEITHER or BOTH TBI values are set. If so, no need to - * examine bit 55 of address, can just generate code. - * If mixed, then test via generated code - */ - if (tbi == 3) { - TCGv_i64 tmp_reg = tcg_temp_new_i64(); - /* Both bits set, sign extension from bit 55 into [63:56] will - * cover both cases - */ - tcg_gen_shli_i64(tmp_reg, src, 8); - tcg_gen_sari_i64(cpu_pc, tmp_reg, 8); - tcg_temp_free_i64(tmp_reg); - } else if (tbi == 0) { - /* Neither bit set, just load it as-is */ - tcg_gen_mov_i64(cpu_pc, src); - } else { - TCGv_i64 tcg_tmpval = tcg_temp_new_i64(); - TCGv_i64 tcg_bit55 = tcg_temp_new_i64(); - TCGv_i64 tcg_zero = tcg_const_i64(0); + if (tbi != 0) { + /* Sign-extend from bit 55. */ + tcg_gen_sextract_i64(cpu_pc, src, 0, 56); - tcg_gen_andi_i64(tcg_bit55, src, (1ull << 55)); + if (tbi != 3) { + TCGv_i64 tcg_zero = tcg_const_i64(0); - if (tbi == 1) { - /* tbi0==1, tbi1==0, so 0-fill upper byte if bit 55 = 0 */ - tcg_gen_andi_i64(tcg_tmpval, src, - 0x00FFFFFFFFFFFFFFull); - tcg_gen_movcond_i64(TCG_COND_EQ, cpu_pc, tcg_bit55, tcg_zero, - tcg_tmpval, src); - } else { - /* tbi0==0, tbi1==1, so 1-fill upper byte if bit 55 = 1 */ - tcg_gen_ori_i64(tcg_tmpval, src, - 0xFF00000000000000ull); - tcg_gen_movcond_i64(TCG_COND_NE, cpu_pc, tcg_bit55, tcg_zero, - tcg_tmpval, src); + /* + * The two TBI bits differ. + * If tbi0, then !tbi1: only use the extension if positive. + * if !tbi0, then tbi1: only use the extension if negative. + */ + tcg_gen_movcond_i64(tbi == 1 ? TCG_COND_GE : TCG_COND_LT, + cpu_pc, cpu_pc, tcg_zero, cpu_pc, src); + tcg_temp_free_i64(tcg_zero); } - tcg_temp_free_i64(tcg_zero); - tcg_temp_free_i64(tcg_bit55); - tcg_temp_free_i64(tcg_tmpval); + return; } - } else { /* EL > 1 */ + } else { if (tbi != 0) { /* Force tag byte to all zero */ - tcg_gen_andi_i64(cpu_pc, src, 0x00FFFFFFFFFFFFFFull); - } else { - /* Load unmodified address */ - tcg_gen_mov_i64(cpu_pc, src); + tcg_gen_extract_i64(cpu_pc, src, 0, 56); + return; } } + + /* Load unmodified address */ + tcg_gen_mov_i64(cpu_pc, src); } typedef struct DisasCompare64 {