From patchwork Mon Dec 3 20:38:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 152746 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp7275808ljp; Mon, 3 Dec 2018 12:47:31 -0800 (PST) X-Google-Smtp-Source: AFSGD/VptZ+TdLtGiQ6mLN0MBTGtv2jnJ+mDHwgGUWqOiep14XyOewcaNvVKarVyeN9q6mF8meBD X-Received: by 2002:ac8:6c3:: with SMTP id j3mr16674199qth.84.1543870051906; Mon, 03 Dec 2018 12:47:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543870051; cv=none; d=google.com; s=arc-20160816; b=YZeZT1nncPW12katweQkE26jbQKEMFKqQDcFDol6EqcKyC80iDjEk9k6YIlXw+ysCF Kv3bBfE9vlohvAYNIiDkbv9Jl//rccJIgEgIcxHl0wiAnrr4zqGfjxHz7eq8FEkhl2Lh oPU7+PjVjs3d4KlvaLCJBsY5On4BzBgEp27K4rnJcwh4vwoWHetO7t6zEyfsH4rHkF53 lpR6iLu+wuT0hrlJYInVOBx3IvuJnmu8UhwBtCxQWRlrxklw4AwdLS4tVkPGjm6KErl4 GVWgN0I+u28pcuD2pfcIKmrhiBiMKOsaNorAODYBncHLEIUWu/2fn2r2tYcwNjmKZ5va iY7A== 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=8zBIr54yy4Wx+NC0wja/S07a0aK29AJFkz7XU3SN6ps=; b=oMe5+7yxYLLsSkzaAOZ6UiyWMJMH29zlIbyy+/aLlUt3uH01hg/rrjYY5pW1PffIMa dNq2OdQdXYJyB+5k9s73AC80DPe65qybTEDlLfhiCbNFYIlqpGw3RTH+QK7dPr5TRP4W Wvh0XPjBW/u1Yxwp2ndOrqFwTW0RvmrPeEQI2F+xH8CBxpAgwLD01zmXLTVQpRA8sBWU /TLFCanniEcqCdzxyLCac37r6CMRogBjD8wk1bivW2gEU3NSvdbyF5+rUs/uLjie6C6b gILjDuRHBUraPKxhX665JL1q7nLKcQcU22iUUxkTIYU94tWgpoE9ncF5+IeLbvewF2Bj +drQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TavhSzEl; 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 m36si6223442qvc.170.2018.12.03.12.47.31 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 03 Dec 2018 12:47:31 -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=TavhSzEl; 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]:52403 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gTv7r-00067T-Bu for patch@linaro.org; Mon, 03 Dec 2018 15:47:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42445) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gTuzc-00069u-QV for qemu-devel@nongnu.org; Mon, 03 Dec 2018 15:39:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gTuzb-0005vW-PO for qemu-devel@nongnu.org; Mon, 03 Dec 2018 15:39:00 -0500 Received: from mail-oi1-x241.google.com ([2607:f8b0:4864:20::241]:36566) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gTuzb-0005uJ-Jc for qemu-devel@nongnu.org; Mon, 03 Dec 2018 15:38:59 -0500 Received: by mail-oi1-x241.google.com with SMTP id x23so12216596oix.3 for ; Mon, 03 Dec 2018 12:38:59 -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=8zBIr54yy4Wx+NC0wja/S07a0aK29AJFkz7XU3SN6ps=; b=TavhSzEls7W/F6E/cQ4bpa5mim0XK5pQdcFn9iCKcNqTdsDR0h5h0f6gbox7E71PYT 2DhvAVF4YHEpsjFZyC8x4th2D33uXczHcde5qj2BTNIswOWkViX5K0vwo8KsYtfr2llr bv+z1a341YclE0dldmFdyYBFx+4OqZEu8/yaY= 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=8zBIr54yy4Wx+NC0wja/S07a0aK29AJFkz7XU3SN6ps=; b=svoBmi0sfr0+NIGrJ2FhhqQZe1ez2Ai1HzI/v3e7rC/ZO6K+fsz7xsINIRn1j9m5lV ANcewt0kP/klz8VZ5i/fv/AQrZWgRaf4IU68L6YKGhpcCTJAKuxzjIYo0re00esifJIs HtJRHjI1IiNUHccFv7x69LtGrAgjZWjx+2NwKpEAdYOeIEO0UL0HdAQzMxW6MdZz7uzU JB4CVwmYca5Jb0oviAZn9wtBH6u1i4gRUQk6Oh+jg/RLjH+mOh/LWARRO7nBdFdDmSLo 65zPFFIh+QgNiUnm4TewGSt35Gj1K4mLb3iAdXtPhETsA3EAgz7sxj2NIuZ99fK/IWVf 2cpw== X-Gm-Message-State: AA+aEWbv3uJjCSswhDt8XfGKiLKZSAqgtA+UOou0eXJzd3OcElnT5Acd WKtUZovcZ9BU/uMWHEjpXZpncl8yTT4= X-Received: by 2002:aca:5a06:: with SMTP id o6mr11158118oib.341.1543869538514; Mon, 03 Dec 2018 12:38:58 -0800 (PST) Received: from cloudburst.twiddle.net (172.189-204-159.bestel.com.mx. [189.204.159.172]) by smtp.gmail.com with ESMTPSA id m133sm6330063oib.52.2018.12.03.12.38.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 Dec 2018 12:38:57 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 3 Dec 2018 14:38:39 -0600 Message-Id: <20181203203839.757-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181203203839.757-1-richard.henderson@linaro.org> References: <20181203203839.757-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::241 Subject: [Qemu-devel] [PATCH v2 10/10] target/arm: Implement the ARMv8.2-AA32HPD extension 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" The bulk of the work here, beyond base HPD, is defining the TTBCR2 register. In addition we must check TTBCR.T2E, which is not present (RES0) for AArch64. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/cpu.h | 9 +++++++++ target/arm/cpu.c | 4 ++++ target/arm/helper.c | 37 +++++++++++++++++++++++++++++-------- 3 files changed, 42 insertions(+), 8 deletions(-) -- 2.17.2 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index ba0c368292..15daa2c050 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1548,6 +1548,15 @@ FIELD(ID_ISAR6, FHM, 8, 4) FIELD(ID_ISAR6, SB, 12, 4) FIELD(ID_ISAR6, SPECRES, 16, 4) +FIELD(ID_MMFR4, SPECSEI, 0, 4) +FIELD(ID_MMFR4, AC2, 4, 4) +FIELD(ID_MMFR4, XNX, 8, 4) +FIELD(ID_MMFR4, CNP, 12, 4) +FIELD(ID_MMFR4, HPDS, 16, 4) +FIELD(ID_MMFR4, LSM, 20, 4) +FIELD(ID_MMFR4, CCIDX, 24, 4) +FIELD(ID_MMFR4, EVT, 28, 4) + FIELD(ID_AA64ISAR0, AES, 4, 4) FIELD(ID_AA64ISAR0, SHA1, 8, 4) FIELD(ID_AA64ISAR0, SHA2, 12, 4) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 60411f6bfe..0b185f8d30 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1932,6 +1932,10 @@ static void arm_max_initfn(Object *obj) t = cpu->isar.id_isar6; t = FIELD_DP32(t, ID_ISAR6, DP, 1); cpu->isar.id_isar6 = t; + + t = cpu->id_mmfr4; + t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* AA32HPD */ + cpu->id_mmfr4 = t; } #endif } diff --git a/target/arm/helper.c b/target/arm/helper.c index 9bb3e364d4..5df7a9e637 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -2733,6 +2733,7 @@ static void vmsa_ttbcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { ARMCPU *cpu = arm_env_get_cpu(env); + TCR *tcr = raw_ptr(env, ri); if (arm_feature(env, ARM_FEATURE_LPAE)) { /* With LPAE the TTBCR could result in a change of ASID @@ -2740,6 +2741,8 @@ static void vmsa_ttbcr_write(CPUARMState *env, const ARMCPRegInfo *ri, */ tlb_flush(CPU(cpu)); } + /* Preserve the high half of TCR_EL1, set via TTBCR2. */ + value = deposit64(tcr->raw_tcr, 0, 32, value); vmsa_ttbcr_raw_write(env, ri, value); } @@ -2842,6 +2845,16 @@ static const ARMCPRegInfo vmsa_cp_reginfo[] = { REGINFO_SENTINEL }; +/* Note that unlike TTBCR, writing to TTBCR2 does not require flushing + * qemu tlbs nor adjusting cached masks. + */ +static const ARMCPRegInfo ttbcr2_reginfo = { + .name = "TTBCR2", .cp = 15, .opc1 = 0, .crn = 2, .crm = 0, .opc2 = 3, + .access = PL1_RW, .type = ARM_CP_ALIAS, + .bank_fieldoffsets = { offsetofhigh32(CPUARMState, cp15.tcr_el[3]), + offsetofhigh32(CPUARMState, cp15.tcr_el[1]) }, +}; + static void omap_ticonfig_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { @@ -5540,6 +5553,10 @@ void register_cp_regs_for_features(ARMCPU *cpu) } else { define_arm_cp_regs(cpu, vmsa_pmsa_cp_reginfo); define_arm_cp_regs(cpu, vmsa_cp_reginfo); + /* TTCBR2 is introduced with ARMv8.2-A32HPD. */ + if (FIELD_EX32(cpu->id_mmfr4, ID_MMFR4, HPDS) != 0) { + define_one_arm_cp_reg(cpu, &ttbcr2_reginfo); + } } if (arm_feature(env, ARM_FEATURE_THUMB2EE)) { define_arm_cp_regs(cpu, t2ee_cp_reginfo); @@ -9891,12 +9908,14 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, if (tg == 2) { /* 16KB pages */ stride = 11; } - if (aarch64) { - if (el > 1) { - hpd = extract64(tcr->raw_tcr, 24, 1); - } else { - hpd = extract64(tcr->raw_tcr, 41, 1); - } + if (aarch64 && el > 1) { + hpd = extract64(tcr->raw_tcr, 24, 1); + } else { + hpd = extract64(tcr->raw_tcr, 41, 1); + } + if (!aarch64) { + /* For aarch32, hpd0 is not enabled without t2e as well. */ + hpd &= extract64(tcr->raw_tcr, 6, 1); } } else { /* We should only be here if TTBR1 is valid */ @@ -9913,8 +9932,10 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, if (tg == 1) { /* 16KB pages */ stride = 11; } - if (aarch64) { - hpd = extract64(tcr->raw_tcr, 42, 1); + hpd = extract64(tcr->raw_tcr, 42, 1); + if (!aarch64) { + /* For aarch32, hpd1 is not enabled without t2e as well. */ + hpd &= extract64(tcr->raw_tcr, 6, 1); } }