From patchwork Fri Jul 19 21:03:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 169280 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp4326483ilk; Fri, 19 Jul 2019 14:07:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqzOk7YVE7sNC247sbwO7GnIrfLMp5LD86n0e9Foyip9SoZbd2le/NRhWFVQD1+h+kI1SSgL X-Received: by 2002:a50:b1db:: with SMTP id n27mr48943576edd.62.1563570440792; Fri, 19 Jul 2019 14:07:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563570440; cv=none; d=google.com; s=arc-20160816; b=KfLLHIL9ojIwPb/1GVbagTh1U1q+vSlSOpM8FVRmc+urbxxtkQLW4zjrm6bhNsvi4N 2ACwKgSrpsagN8YYXx/wDooDrt2uHU51BW5GOnLKA+W+cr9USTNaDhkR2AxMl4w1xwjZ ET+NE0ilL9ylvp8mpz1RcN6SkG37HvPPZYgyhpdIUZpKkThQeEs3Wfp6H6AchEsBRo5v rfH038IriDkpVfkEF+qd1UN5VHPYBLl21MTrlrGcbDEGuxX9GtlJXFKQ6QdoPVo6rCkE JC5RQnxUxwGqgP7J1tzsMVeyA53GvVVO54iIvRmkZ8NfyWNkb9BdsfP9nr8ayPqJn6bu 5EeQ== 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=HVWcOf4G2zu+00boFsNQK0A4cfcZIeDQ0O/gtXTZHjo=; b=olpetp1TFiq+7rscZ0yimIoWtKoTFili/nJASgp7PHAXG0toFEUe2OgRWJfH32KFfz 9ctwZ2JoZ/TPR2uL4PlWBqbg5JJe4IUMJbQvSUoaAcZE6nw0Mzfj8rpw0HIQnfsHYxMl haAr+4f8VIw/I+j2sdqcqPgOeuBs8oiGLl+fdKIl/+0VZsaqOREyQiSeyM9uI3EzmHZ2 Cjz9p3EUtKkZ12ba9snr7h9Qp20Q07LHJvLdImkzJvOaqH6CobishIyAa9AHXOS9C/sA OdZc6+tbS8qe4W81uiCq0xsFSwGU/FY053RyuMg4Xu15asQt6mrhUXMRVEx9auFvsHHI h+XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="HnaKW/jB"; 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 b10si768282ejq.174.2019.07.19.14.07.20 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Jul 2019 14:07:20 -0700 (PDT) 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="HnaKW/jB"; 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]:48284 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hoa63-0000SG-FI for patch@linaro.org; Fri, 19 Jul 2019 17:07:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55440) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hoa3k-0000Nk-0O for qemu-devel@nongnu.org; Fri, 19 Jul 2019 17:04:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hoa3i-0005gu-0U for qemu-devel@nongnu.org; Fri, 19 Jul 2019 17:04:55 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:37453) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hoa3h-00058D-Af for qemu-devel@nongnu.org; Fri, 19 Jul 2019 17:04:53 -0400 Received: by mail-pl1-x642.google.com with SMTP id b3so16185826plr.4 for ; Fri, 19 Jul 2019 14:03:39 -0700 (PDT) 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=HVWcOf4G2zu+00boFsNQK0A4cfcZIeDQ0O/gtXTZHjo=; b=HnaKW/jBNwlFcHkFGUJqmMDsIlrMH5AoRiGR3gKU3LCNpmbCz1R2CnGMDgH/68iiAN 7cN1I6WMhvvfIT+djZHfBM27Kl3oaNl+IewziHdjQ7iSKBhDxPZo2qfSs8rpT1MEXkP8 qp303JUUw/tK/epNipWWHsiwIobroVbaj5Hkw4kaaVbZnoC7iJYYJum2vJjMjsi0/AVG 2md0ORVD4DP2eprk2KcsI7WXGetjA0vO81jbEOJh7xoO+QFCQJWas/++pSUzJomDHcu7 /z+Ko/MgRIe4XqZ+pTYvHY7nejtibHYA4WS1dcOJdslc9MTzKaoOkMiQLZZMsukuEJLv TRDQ== 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=HVWcOf4G2zu+00boFsNQK0A4cfcZIeDQ0O/gtXTZHjo=; b=CPyAUOHmmfRBDmWNvS8MccbqWyTnvy5PJX5spyq+cdzvVPD0AaZugaRpA4nJ6X1Y9q FJYcOg4SuyJkcKxLLzIS3OJ1QIXilRMIrITKMHbX8aDa8KgioaLwLofkI6PFnvNdmwC3 zb2ZLltTuiaCrKDQ01imK7sFTGe7eWyoY4uH4vptvLNIr5X7R3YSkIhPrsO5+ZxpXscY I2IUI+xb5AwKAicII7DVGK2r+VuNSHj4ALocTWICaX9Dzo5q8A4t9vyWmcCRLViLe9Op 0F22bsua/GaG/cMYjQaqJVopg1uZ1gj7rjR9k3tEYVbHmy8adQ1TTeokR+cZ0EdthoLl dMtg== X-Gm-Message-State: APjAAAU6wIHNm2rck+xlgMPE/sBe5JLcj2bxQA36z6l7R4sOv4psHO4k YHTbXrK8LPwAz3z3xjFlBf224/besOY= X-Received: by 2002:a17:902:3181:: with SMTP id x1mr57910135plb.135.1563570218077; Fri, 19 Jul 2019 14:03:38 -0700 (PDT) Received: from localhost.localdomain (97-126-117-207.tukw.qwest.net. [97.126.117.207]) by smtp.gmail.com with ESMTPSA id i6sm32724751pgi.40.2019.07.19.14.03.37 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 19 Jul 2019 14:03:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 19 Jul 2019 14:03:10 -0700 Message-Id: <20190719210326.15466-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190719210326.15466-1-richard.henderson@linaro.org> References: <20190719210326.15466-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::642 Subject: [Qemu-devel] [PATCH for-4.2 08/24] target/arm: Add CONTEXTIDR_EL2 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, beata.michalska@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. 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 Reviewed-by: Alex Bennée 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 0a55096770..d1bf31ab74 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6801,6 +6801,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)) {