From patchwork Mon Mar 2 17:58:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 184097 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp2680438ile; Mon, 2 Mar 2020 09:59:17 -0800 (PST) X-Google-Smtp-Source: ADFU+vtyQhWADphvhrirHPuGHuR1Xd1tN4Jg94/B13lPOAra2mFp5ZVA/a2+6VR52244Z/U1SA4L X-Received: by 2002:a05:620a:10b3:: with SMTP id h19mr446673qkk.440.1583171956976; Mon, 02 Mar 2020 09:59:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583171956; cv=none; d=google.com; s=arc-20160816; b=pf2EEBb1kzIvhDbqzFDHKrdNhoKZSfAoKttytIRUpnvtxZoL84jD76/FP/l77cq29n XFN7oDReiRSXew0wLQbuHk6gEgad37GaszT/M/w0gMYISgms6uCg1MtYSVFTVaWOjnDT pisy9r/cjd8qzRe/xFcO1lfxHHCc665bvr1M26C/EqQ0tExZT58L7xznU1omToK2Uj+k yVp3/hBibDexVzu7nJTl7X0+lw0yJvJT8tSaDgtmkfzqbxYuSWTyhg7eul8xubbqFNy/ t8psOa8pP2GtxKsyKOSE0iHrPEPY1WafK5ldy7FTfT1bu0KwvgVl2ccLmrwwM7GVRCsy PBxg== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Xb4MZkBU7c3SsPvbbpOINi23WCHWKuPEyPWHI7rJrJg=; b=sHQoySBjIPH2o9mt0ELSxtNmOT7+QfmvqN7G6Og6+cqbE3C+W+NWbDujrKPz4LKt5+ 4MtTXZP9q1DYPT/IybFHnnRDiMA94FxLe9xDoSY11bdjlBs2fpwRABT1tDvzIG35whim YgSRZ7YhSgUJwvqI3bBiarmFV8Bp0QzmRKJo6DGtoHVZkfrCakSQmL1arXyHRSSyNVY1 yycvGEx3uZACOFT5j+CZAnJbv94gJA8QaKlJ6tYhEHclaOVEkjvLieYLLUUTReYdNjmI xIwOtCMVczMaurRKqXG7i9bSAw2q3ZpgB3fU6yAIHnf0fn+/vXG6jmQ/YnlswTXqEDej 7qHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lzo2x0RU; 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=pass (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 y3si6325081qto.362.2020.03.02.09.59.16 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Mar 2020 09:59: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=pass header.i=@linaro.org header.s=google header.b=lzo2x0RU; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:36322 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j8pLY-0007ZI-BU for patch@linaro.org; Mon, 02 Mar 2020 12:59:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39090) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j8pKw-0006dW-Q6 for qemu-devel@nongnu.org; Mon, 02 Mar 2020 12:58:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j8pKv-0007ZT-NB for qemu-devel@nongnu.org; Mon, 02 Mar 2020 12:58:38 -0500 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:42568) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j8pKv-0007Z9-IA for qemu-devel@nongnu.org; Mon, 02 Mar 2020 12:58:37 -0500 Received: by mail-pg1-x542.google.com with SMTP id h8so173094pgs.9 for ; Mon, 02 Mar 2020 09:58:37 -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 :mime-version:content-transfer-encoding; bh=Xb4MZkBU7c3SsPvbbpOINi23WCHWKuPEyPWHI7rJrJg=; b=lzo2x0RUxzilhpgFVTN4QYmyqJjuqg1RBfGHJzW9ioWN2CpVjgwp/jz/psxx9r+m/2 rdPP2kEKvlq2CfqxQAWsYlAZQUP4AE6HJYBS3dOSu1pfEDMhMQdITg/SjJG3TuuWQRYn fAun+xHZNpHxWDep7FcS8owD75Wn0VDVMau4w2c1nM+Lvw1xOI3NVMaiRKTk3lti1hJ5 BaphvzV1T5ZuuYLC5wWPDWQhm8hvf2/pHshDIVIW6Qedcfhs2NB4wzgNFfgRc22T4kF5 cyucm2PRyh8xygFz8amS86X7NP4+reSephwQs36H/X4zDMo4BFGwjpr2kSK/63PCHUDe TExw== 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:mime-version:content-transfer-encoding; bh=Xb4MZkBU7c3SsPvbbpOINi23WCHWKuPEyPWHI7rJrJg=; b=PXi1+sFGhetszmkVrVRdRy3VQHvE2NR5SJO7Z1qaAAVZSDkURgqzMgvq2M/s+mWoO4 EsHjWkyBjMFgnQxwAHJCqWd2zxhodD+V+Yj59Cyx76Af5KN6fHOojBn5M6UxcWPcxu6X Bdgi2HnxbXv3MdKAn6VC1E9UPunK3uox0JIl/+4gsmRaWwt8IJcK1aOMMbVrWjf9j6Y/ YicjF7uE9BGHZsg28WOPkaSUBhn1bNaUswxhy+kkn1NgJztgJHfhApK5zX/+KTtBpRa/ 9zMa2GEUnr08tRTbgtUCKByko9nw3OAJ2yg0lwT5j+Jb7nVU8aLh3tMaGuRpxx3Ogqa9 kQhw== X-Gm-Message-State: ANhLgQ0uS7xkYWjtopZE6Coj7i5/1vHeMyARKm06FEOsMogZUTgIeT8O EHFchbnx3oiumFduLAB5w1o68L9Ag+s= X-Received: by 2002:a63:d0b:: with SMTP id c11mr103192pgl.296.1583171916269; Mon, 02 Mar 2020 09:58:36 -0800 (PST) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id s18sm99510pjp.24.2020.03.02.09.58.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Mar 2020 09:58:35 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 4/9] target/arm: Apply TBI to ESR_ELx in helper_exception_return Date: Mon, 2 Mar 2020 09:58:24 -0800 Message-Id: <20200302175829.2183-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200302175829.2183-1-richard.henderson@linaro.org> References: <20200302175829.2183-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::542 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We missed this case within AArch64.ExceptionReturn. Signed-off-by: Richard Henderson --- target/arm/helper-a64.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) -- 2.20.1 Reviewed-by: Peter Maydell diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index 509ae93069..123ce50e7a 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -1031,6 +1031,8 @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc) "AArch32 EL%d PC 0x%" PRIx32 "\n", cur_el, new_el, env->regs[15]); } else { + int tbii; + env->aarch64 = 1; spsr &= aarch64_pstate_valid_mask(&env_archcpu(env)->isar); pstate_write(env, spsr); @@ -1038,8 +1040,27 @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc) env->pstate &= ~PSTATE_SS; } aarch64_restore_sp(env, new_el); - env->pc = new_pc; helper_rebuild_hflags_a64(env, new_el); + + /* + * Apply TBI to the exception return address. We had to delay this + * until after we selected the new EL, so that we could select the + * correct TBI+TBID bits. This is made easier by waiting until after + * the hflags rebuild, since we can pull the composite TBII field + * from there. + */ + tbii = FIELD_EX32(env->hflags, TBFLAG_A64, TBII); + if ((tbii >> extract64(new_pc, 55, 1)) & 1) { + /* TBI is enabled. */ + int core_mmu_idx = cpu_mmu_index(env, false); + if (regime_has_2_ranges(core_to_aa64_mmu_idx(core_mmu_idx))) { + new_pc = sextract64(new_pc, 0, 56); + } else { + new_pc = extract64(new_pc, 0, 56); + } + } + env->pc = new_pc; + qemu_log_mask(CPU_LOG_INT, "Exception return from AArch64 EL%d to " "AArch64 EL%d PC 0x%" PRIx64 "\n", cur_el, new_el, env->pc);