From nobody Thu Nov 13 13:38:58 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158034265421755.88885158966298; Wed, 29 Jan 2020 16:04:14 -0800 (PST) Received: from localhost ([::1]:53612 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iwxJc-0006dt-QD for importer@patchew.org; Wed, 29 Jan 2020 19:04:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45096) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iwxC2-0003ZJ-JS for qemu-devel@nongnu.org; Wed, 29 Jan 2020 18:56:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iwxC1-0006ld-Di for qemu-devel@nongnu.org; Wed, 29 Jan 2020 18:56:22 -0500 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:38977) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iwxC1-0006ij-6x for qemu-devel@nongnu.org; Wed, 29 Jan 2020 18:56:21 -0500 Received: by mail-pf1-x442.google.com with SMTP id 84so490995pfy.6 for ; Wed, 29 Jan 2020 15:56:21 -0800 (PST) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id r3sm3953626pfg.145.2020.01.29.15.56.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jan 2020 15:56:19 -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=jzDTKnTCcjosfdRZyFi04xD1b88UR01u1kjrxtS41SA=; b=AGqYmsVMSzsv3p/264kaBpdo2suSuLYntk7knkTtT/+Ne2dXK3l5mHlaRqjg/s7C06 m4DRDvzx7/jEeTHNa25/UgklQ1KAkW70vulYgoYuGAO32yxKAMyi6mtrzfMgiO6aucdu zU+vDouFOUiGCeVzCpWH6EHzaBIQsLArjNdntCVC0qcAJ4mrixzySnHqsIhO6zNyBZ0z u+9UI3fIuoMnI14HPgOOayBhm+6b3JMUIBMFv7jDoUJkOYbhPlJ8AOeo0gfbBnA6iEs+ hoGWunfcbiGVAzQ2ijSTQzzINgk/H5iJNiOMh5VnYgUH1oKZDZC6paLbmeIyLb9vwkWw SsHA== 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=jzDTKnTCcjosfdRZyFi04xD1b88UR01u1kjrxtS41SA=; b=QYsJO+9bTVFarrT9i5w9uL/1aJgtej7TUmdpFL8xkoZGlhfxrTpX08GEztE+8S3Xy7 gtpT8mIAgoe6853ZgNwJ56PWMKrY11wxyj9+hG/HilasMkBBkBVgPm+YF4M+beSRDNak humiiCtEeV+/sRIgP/Hhw+2RT4KMpRz9S52fkayTlAHPOvxW2NaWpxki53f24qSLNNwX H7CYnIERT5F2UgmGcSIRY7ted0V7dlEVBf4alSHAYP0ZiHCEweIioGu6VNaCirylHKhj gnGPoBcKiBZ+QV8nBnCpsWKlyPIYuqg3O9t/h4oV9nX2yqnX3nFkFaXrgltbiBuD4Ff7 LJvQ== X-Gm-Message-State: APjAAAX/zjplxMMrBtPv6QK+LvrIlCqSqxo/p4iTvyAPggCWHBd9Nfpn ze+wgbyVMTs8reHIsmrYeum03IL6NLk= X-Google-Smtp-Source: APXvYqzXNNmVjkr/93Wao7Mxk9nXVX7k2ia8bawXveGhRBOIasthq7xyFDUMaVDxN6y5EoH9CywQLw== X-Received: by 2002:a63:3245:: with SMTP id y66mr1691237pgy.234.1580342179739; Wed, 29 Jan 2020 15:56:19 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 03/41] target/arm: Add CONTEXTIDR_EL2 Date: Wed, 29 Jan 2020 15:55:36 -0800 Message-Id: <20200129235614.29829-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200129235614.29829-1-richard.henderson@linaro.org> References: <20200129235614.29829-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::442 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) 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=C3=A9e Signed-off-by: Richard Henderson --- target/arm/debug_helper.c | 50 +++++++++++++++++++++++++++++---------- target/arm/helper.c | 11 +++++++++ 2 files changed, 49 insertions(+), 12 deletions(-) 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 =3D extract32(cpu->dbgdidr, 20, 4); int bt; uint32_t contextidr; + uint64_t hcr_el2; =20 /* * Links to unimplemented or non-context aware breakpoints are @@ -40,24 +41,44 @@ static bool linked_bp_matches(ARMCPU *cpu, int lbn) } =20 bt =3D 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 ASI= D), - * since we don't implement the optional v7 context ID masking. - */ - contextidr =3D extract64(env->cp15.contextidr_el[1], 0, 32); + hcr_el2 =3D arm_hcr_el2_eff(env); =20 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 =3D env->cp15.contextidr_el[2]; + break; + case 1: + contextidr =3D env->cp15.contextidr_el[1]; + break; + case 0: + if ((hcr_el2 & (HCR_E2H | HCR_TGE)) =3D=3D (HCR_E2H | HCR_TGE)= ) { + contextidr =3D env->cp15.contextidr_el[2]; + } else { + contextidr =3D env->cp15.contextidr_el[1]; + } + break; } - return (contextidr =3D=3D extract64(env->cp15.dbgbvr[lbn], 0, 32)); - case 5: /* linked address mismatch (reserved in AArch64) */ + break; + + case 7: /* linked contextidr_el1 match */ + contextidr =3D env->cp15.contextidr_el[1]; + break; + case 13: /* linked contextidr_el2 match */ + contextidr =3D 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; } =20 - 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 ASI= D), + * since we don't implement the optional v7 context ID masking. + */ + return contextidr =3D=3D (uint32_t)env->cp15.dbgbvr[lbn]; } =20 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 f5ce05fdf3..b3ba81dc0a 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -7089,6 +7089,17 @@ void register_cp_regs_for_features(ARMCPU *cpu) define_arm_cp_regs(cpu, lor_reginfo); } =20 + if (arm_feature(env, ARM_FEATURE_EL2) && cpu_isar_feature(aa64_vh, cpu= )) { + static const ARMCPRegInfo vhe_reginfo[] =3D { + { .name =3D "CONTEXTIDR_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .crn =3D 13, .crm =3D 0, .opc2 =3D= 1, + .access =3D PL2_RW, + .fieldoffset =3D 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)) { --=20 2.20.1