From patchwork Tue Dec 3 02:29:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 180660 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp937259ile; Mon, 2 Dec 2019 18:34:24 -0800 (PST) X-Google-Smtp-Source: APXvYqwUgRkkuqzv40LWYFvwsTOmIX/Wlvcw6f6l34Xsy8wQE3dj2VleDLyIqJClhgHq2pTavbUO X-Received: by 2002:a37:6313:: with SMTP id x19mr2928802qkb.231.1575340464198; Mon, 02 Dec 2019 18:34:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575340464; cv=none; d=google.com; s=arc-20160816; b=i+VM6V1bE9bR6YwruAAKlUz68c70WE7NbKnl4CdMgtSLHWtSspnOebBcTT3iUQx0ta xmdwdKyF4RrwIUCnFupt4pqi9MOKZEWRuP/RNhqDH3ybjzW236jkTmBe7VF9+cRIokbG sr65CsgbfIWHeN8DL5CT9/ohr8SrWIif6mqlsKjc6P42JJvEJCwqJT8eTgbWYgDVLj1H UnmqKdl9tIVhXlsLVitZoJDE6W05ToyhDI4Z9DMsVIyImvWmCbioxwtVLeJAoAuTfQNH CNEf6RIv6Ova3lONfAknW0N2j/GEVgSLAX103CRL7CStnPfcdbsClp52ZHmiS9siklwe yUFw== 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=+TWIlcZZrmEqGDmi7NHEaLblsjTyqMT3Bn6OGEgJfYE=; b=ZVDI52af7zdL2E4XfDDWn5AhSxItzw/FC+Pta0EeB6GPZJOOMgOWt6FO0q5edBQewv sdQbE5VlbvdFHjW4d5MoeWGMMudtNAqy+YhqA/OnU1L1/w8EJDpE7pDu/VKon5xLpJer 4UF3YrxZQtgzZJCS6cu/cTUzjDcFfVxr4orNNLIV/1Xsbrfe8hRt2Kr8P1m9iDDhiGwM WDV/qbhi+Jkv/AbqXU+Ab7bZ14MCdzukAuhFk4iwNx7Og7euHcl7H6iofYQzLSkaQeFs d89tN29yGMkYAAXV9+Bxt7LHfIPTfO9MJm+6FfCdK6IVU8xCmtg6IZz9CDzoanA4Fc19 b7mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=C7X7emm8; 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 r139si1212275qke.54.2019.12.02.18.34.24 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Dec 2019 18:34:24 -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=C7X7emm8; 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 ([::1]:47164 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iby19-00073k-32 for patch@linaro.org; Mon, 02 Dec 2019 21:34:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59248) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ibxwf-0002zN-SG for qemu-devel@nongnu.org; Mon, 02 Dec 2019 21:29:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ibxwe-0007yg-JJ for qemu-devel@nongnu.org; Mon, 02 Dec 2019 21:29:45 -0500 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:35150) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ibxwe-0007xM-Cx for qemu-devel@nongnu.org; Mon, 02 Dec 2019 21:29:44 -0500 Received: by mail-pf1-x441.google.com with SMTP id b19so991642pfo.2 for ; Mon, 02 Dec 2019 18:29:44 -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=+TWIlcZZrmEqGDmi7NHEaLblsjTyqMT3Bn6OGEgJfYE=; b=C7X7emm81rhXLpsyakilwuRbZmwY9k57/rLnqpPuLP2oDBHZC8kT1JZCo/QE/wgMya xmD1wwwYDIx9FomLmomyd93WLmzr9+kd4/AufCyVFxpl2ZbhULH3HtINeXSB2s0DAEdR 4Jvk84gsOsR9Y1QtadUN61vbAWhKI/S9O8tgcdjw+QxranMRoLpRLbuGLngHJLEQst4d yNZWjV5pgOWMsGZyo4dFrEIfMf5U0Mo7hMvomd0YMOYK1ONsW9INsO4+wIVixdQVo/B9 fRIVL4wYcWLVC5aX47qXeKiIahCGFTNilTJkNTpunc+Ym4ktvimSY9d7Pzbdfej+2lrs GTXA== 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=+TWIlcZZrmEqGDmi7NHEaLblsjTyqMT3Bn6OGEgJfYE=; b=L/3d7QPHTcJLrwkQfBdIxl+SR5ZeJxr93XL/XezPhpLMZ5IZ/9k8tAW1QZek4XZOK/ g2mqX+6COqZPB3wK98AwPmYiQklvj5ff2iVOuZg4oHz25ABk3GWwBC1ekrlynDxA9jsd 4ZwMbbCz8C65qcWiATwFejPhPuc6XLTynnVY4qn/OqdENXg7ao1kkUlNrUWdfxCfOY1U txOGKuH04uW3vfacRZoJBFZN5KQdlxn5zsBWcQXyZVEyHvKodXv5CnG4Ie2zmZwjRDEv ZFEDtSK11DG0CiYBcm985m79YWvRTmd67IE5h+NomhXxXIFPiyBud5oRdSi2KtY1dJaE ow6w== X-Gm-Message-State: APjAAAWy4LkF4DO782N5Zt610CcOHvGem/5XIbEWFg+gvs3BkZewaim0 N9I1U5/i9ku8xJIG5vMtJ7s3JhUiiiw= X-Received: by 2002:a63:184c:: with SMTP id 12mr2829694pgy.418.1575340183028; Mon, 02 Dec 2019 18:29:43 -0800 (PST) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q22sm873695pfg.170.2019.12.02.18.29.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2019 18:29:42 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 03/40] target/arm: Add CONTEXTIDR_EL2 Date: Mon, 2 Dec 2019 18:29:00 -0800 Message-Id: <20191203022937.1474-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191203022937.1474-1-richard.henderson@linaro.org> References: <20191203022937.1474-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::441 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, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Not all of the breakpoint types are supported, but those that only examine contextidr are extended to support the new register. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- target/arm/debug_helper.c | 50 +++++++++++++++++++++++++++++---------- target/arm/helper.c | 11 +++++++++ 2 files changed, 49 insertions(+), 12 deletions(-) -- 2.17.1 diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c index dde80273ff..2e3e90c6a5 100644 --- a/target/arm/debug_helper.c +++ b/target/arm/debug_helper.c @@ -20,6 +20,7 @@ static bool linked_bp_matches(ARMCPU *cpu, int lbn) int ctx_cmps = extract32(cpu->dbgdidr, 20, 4); int bt; uint32_t contextidr; + uint64_t hcr_el2; /* * Links to unimplemented or non-context aware breakpoints are @@ -40,24 +41,44 @@ static bool linked_bp_matches(ARMCPU *cpu, int lbn) } bt = extract64(bcr, 20, 4); - - /* - * We match the whole register even if this is AArch32 using the - * short descriptor format (in which case it holds both PROCID and ASID), - * since we don't implement the optional v7 context ID masking. - */ - contextidr = extract64(env->cp15.contextidr_el[1], 0, 32); + hcr_el2 = arm_hcr_el2_eff(env); switch (bt) { case 3: /* linked context ID match */ - if (arm_current_el(env) > 1) { - /* Context matches never fire in EL2 or (AArch64) EL3 */ + switch (arm_current_el(env)) { + default: + /* Context matches never fire in AArch64 EL3 */ return false; + case 2: + if (!(hcr_el2 & HCR_E2H)) { + /* Context matches never fire in EL2 without E2H enabled. */ + return false; + } + contextidr = env->cp15.contextidr_el[2]; + break; + case 1: + contextidr = env->cp15.contextidr_el[1]; + break; + case 0: + if ((hcr_el2 & (HCR_E2H | HCR_TGE)) == (HCR_E2H | HCR_TGE)) { + contextidr = env->cp15.contextidr_el[2]; + } else { + contextidr = env->cp15.contextidr_el[1]; + } + break; } - return (contextidr == extract64(env->cp15.dbgbvr[lbn], 0, 32)); - case 5: /* linked address mismatch (reserved in AArch64) */ + break; + + case 7: /* linked contextidr_el1 match */ + contextidr = env->cp15.contextidr_el[1]; + break; + case 13: /* linked contextidr_el2 match */ + contextidr = env->cp15.contextidr_el[2]; + break; + case 9: /* linked VMID match (reserved if no EL2) */ case 11: /* linked context ID and VMID match (reserved if no EL2) */ + case 15: /* linked full context ID match */ default: /* * Links to Unlinked context breakpoints must generate no @@ -66,7 +87,12 @@ static bool linked_bp_matches(ARMCPU *cpu, int lbn) return false; } - return false; + /* + * We match the whole register even if this is AArch32 using the + * short descriptor format (in which case it holds both PROCID and ASID), + * since we don't implement the optional v7 context ID masking. + */ + return contextidr == (uint32_t)env->cp15.dbgbvr[lbn]; } static bool bp_wp_matches(ARMCPU *cpu, int n, bool is_wp) diff --git a/target/arm/helper.c b/target/arm/helper.c index d81daadf45..b4d774632d 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6953,6 +6953,17 @@ void register_cp_regs_for_features(ARMCPU *cpu) define_arm_cp_regs(cpu, lor_reginfo); } + if (arm_feature(env, ARM_FEATURE_EL2) && cpu_isar_feature(aa64_vh, cpu)) { + static const ARMCPRegInfo vhe_reginfo[] = { + { .name = "CONTEXTIDR_EL2", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 4, .crn = 13, .crm = 0, .opc2 = 1, + .access = PL2_RW, + .fieldoffset = offsetof(CPUARMState, cp15.contextidr_el[2]) }, + REGINFO_SENTINEL + }; + define_arm_cp_regs(cpu, vhe_reginfo); + } + if (cpu_isar_feature(aa64_sve, cpu)) { define_one_arm_cp_reg(cpu, &zcr_el1_reginfo); if (arm_feature(env, ARM_FEATURE_EL2)) {