From nobody Tue May 7 09:42:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508974174840118.7086781029085; Wed, 25 Oct 2017 16:29:34 -0700 (PDT) Received: from localhost ([::1]:50315 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7V6x-0004UA-9n for importer@patchew.org; Wed, 25 Oct 2017 19:29:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59971) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7V69-00049u-TK for qemu-devel@nongnu.org; Wed, 25 Oct 2017 19:28:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e7V66-0002hg-Pz for qemu-devel@nongnu.org; Wed, 25 Oct 2017 19:28:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:48282) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e7V5q-0002Gu-A1; Wed, 25 Oct 2017 19:28:14 -0400 Received: from [10.149.184.130] (162-198-228-33.lightspeed.wlfrct.sbcglobal.net [162.198.228.33]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CB7F421912; Wed, 25 Oct 2017 23:28:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CB7F421912 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=sstabellini@kernel.org Date: Wed, 25 Oct 2017 16:28:12 -0700 (PDT) From: Stefano Stabellini X-X-Sender: sstabellini@sstabellini-ThinkPad-X260 To: peter.maydell@linaro.org Message-ID: User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 198.145.29.99 Subject: [Qemu-devel] [PATCH v2] don't hardcode EL1 in extended_addresses_enabled 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: qemu-arm@nongnu.org, sstabellini@kernel.org, qemu-devel@nongnu.org, julien.grall@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: TEXT/PLAIN; charset="utf-8" extended_addresses_enabled calls arm_el_is_aa64, hardcoding exception level 1. Instead, add an additional "el" argument to extended_addresses_enabled. The caller will pass the right value. In most cases, it will be arm_current_el(env). However, arm_debug_excp_handler will use arm_debug_target_el(env), as the target el for a debug trap can be different from the current el. Signed-off-by: Stefano Stabellini diff --git a/target/arm/helper.c b/target/arm/helper.c index 96113fe..2298428 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -500,7 +500,7 @@ static void contextidr_write(CPUARMState *env, const AR= MCPRegInfo *ri, ARMCPU *cpu =3D arm_env_get_cpu(env); =20 if (raw_read(env, ri) !=3D value && !arm_feature(env, ARM_FEATURE_PMSA) - && !extended_addresses_enabled(env)) { + && !extended_addresses_enabled(env, arm_current_el(env))) { /* For VMSA (when not using the LPAE long descriptor page table * format) this register includes the ASID, so do a TLB flush. * For PMSA it is purely a process ID and no action is needed. @@ -2162,7 +2162,7 @@ static uint64_t do_ats_write(CPUARMState *env, uint64= _t value, =20 ret =3D get_phys_addr(env, value, access_type, mmu_idx, &phys_addr, &attrs, &prot, &page_size, &fsr, &fi); - if (extended_addresses_enabled(env)) { + if (extended_addresses_enabled(env, arm_current_el(env))) { /* fsr is a DFSR/IFSR value for the long descriptor * translation table format, but with WnR always clear. * Convert it to a 64-bit PAR. diff --git a/target/arm/internals.h b/target/arm/internals.h index 43106a2..6792df2 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -217,10 +217,10 @@ static inline unsigned int arm_pamax(ARMCPU *cpu) * This is always the case if our translation regime is 64 bit, * but depends on TTBCR.EAE for 32 bit. */ -static inline bool extended_addresses_enabled(CPUARMState *env) +static inline bool extended_addresses_enabled(CPUARMState *env, unsigned i= nt el) { - TCR *tcr =3D &env->cp15.tcr_el[arm_is_secure(env) ? 3 : 1]; - return arm_el_is_aa64(env, 1) || + TCR *tcr =3D &env->cp15.tcr_el[el]; + return arm_el_is_aa64(env, el) || (arm_feature(env, ARM_FEATURE_LPAE) && (tcr->raw_tcr & TTBCR_EA= E)); } diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c index 3914145..4f46eb8 100644 --- a/target/arm/op_helper.c +++ b/target/arm/op_helper.c @@ -1378,7 +1378,7 @@ void arm_debug_excp_handler(CPUState *cs) =20 cs->watchpoint_hit =3D NULL; =20 - if (extended_addresses_enabled(env)) { + if (extended_addresses_enabled(env, arm_debug_target_el(env)))= { env->exception.fsr =3D (1 << 9) | 0x22; } else { env->exception.fsr =3D 0x2; @@ -1402,7 +1402,7 @@ void arm_debug_excp_handler(CPUState *cs) return; } =20 - if (extended_addresses_enabled(env)) { + if (extended_addresses_enabled(env, arm_debug_target_el(env))) { env->exception.fsr =3D (1 << 9) | 0x22; } else { env->exception.fsr =3D 0x2;