From patchwork Sat Aug 3 18:47:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170485 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2343357ile; Sat, 3 Aug 2019 11:52:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqyMdi2455lwuyU2ih/25K/iwQZZLwfv8caikyTzLVjroPrS3GrvC3oi8iGW62QRneIz3gsK X-Received: by 2002:a0c:d94e:: with SMTP id t14mr99121061qvj.18.1564858370279; Sat, 03 Aug 2019 11:52:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858370; cv=none; d=google.com; s=arc-20160816; b=K0hw4VOqXmpkHZfDcS5y8yIP7/nVLR/JTWaJSUA8bsTQO3CHNvomnah2VZHyBMRmIm knydahhSwS6hUUFkA4t6k6PjHU/8W4vj/rk2FBXYJMHN4y23JhDUj9tJmN2u5npXf86n eqdLl0SV9pqaJFWmzB1k7bq9oHE0nqf53F/jB8oOsnVmhWUjw63TwDAOXoOqdCLGdZ10 VwL6GvCtja2gQXaK434gg6T8muUcUOjfqxm3l3WoW6UpI60ql87Pnrg7dok52/cl09nV aPt/qn/v9+fahn93Wqe0YYkWVgGX0gPES/KqicEQhST7VLcZUCYGBhLSIk0VCv/jrucL 9wsw== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=BmJBoz3ocCwfjPIQpLnVRF2wr3dk36b5G/HujhxQoNg=; b=UXfquYo4jedlrPKGUGGz5+yEbpc/txGBR5GoujNYRkjyAqPPG0Gmuv40BNG6GB7FRJ IIPUfNzu6vEJ424ABLyqVsAKUVVo4jjt8dQbT209sm2IBI5kE9VX4TAgNVD5prfqbTx2 1F8NKallA6AXirYQZTvxObOc59jsY++9B+QLK/Eahpw9T0KPpqMsFnZT/eWgnvB/62ud e6/dTYc4kAiOtuN0gXpiqYrexSakfrQg4seEkdo7AYQFALngV8JTpV65092L5vv4BKJL J9AFOkoW+N8EKawwGUmzyj4udlZ0pA/fFDUl/bbmwz8h5yOzJoppD7bfpaFRDM+Ae2Zt iyDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XOuKwYgo; 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 d26si49549585qvd.200.2019.08.03.11.52.50 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 11:52:50 -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=XOuKwYgo; 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]:41422 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz97-0007xg-Ti for patch@linaro.org; Sat, 03 Aug 2019 14:52:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60690) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz4k-0006EG-6L for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz4i-0007B1-06 for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:18 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:37966) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz4h-00079z-3Y for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:15 -0400 Received: by mail-pl1-x641.google.com with SMTP id az7so34857647plb.5 for ; Sat, 03 Aug 2019 11:48:13 -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 :mime-version:content-transfer-encoding; bh=BmJBoz3ocCwfjPIQpLnVRF2wr3dk36b5G/HujhxQoNg=; b=XOuKwYgouGDpkaX6L6Uu/ztO4LamAjukWRR1TU+AbO+9d8EmzEJYGDgd3wbWL+1eQn FoDehmYmUS91lcRg8bfPfB94G6o/PJLpxhj86ESqDCIBvqYfIH3+AH9bJvaa+UdX7iPk jvuhHyVBQD1BGOx1IIU+wgGZN8QBO/0omjs6XaXVN7XIdVAHGJE8Qnc7KKnvmQV+/jyF FLW5nklHtdH2xKYULu3K82i8NFlqdfNFh2giImdOFsgyivibizZVPqg62mqkrvHKEIF4 Vq7/+zZCwlmLTqkj/DomwraVUncNHLrHbGLpQc1/lczLH+39ypVYm5oRoVo0WJvRuhQZ bXSw== 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=BmJBoz3ocCwfjPIQpLnVRF2wr3dk36b5G/HujhxQoNg=; b=eek/sgSSHBqLoqQ61ey7tPAVSrFCZqSMNbcg0P1ROrCa0tFSGpp172eQqKLnRH32MO zJv53T8xwScPcXCmDMPh26VqINfIoGk2pquaQL6LJWvp3ZYi9Ro2Op8uXh5/egakL9T7 5qMSrdjJHTslIU9onrw0Yx6yzYmiqmsKI70QI0eplGGrIRgbSMadYCdvoZQ7VezPm+bl nUGmmxXOWp3erhG5dfAU0urwN4/XOlOwr/aui4dx5WL0UUVVxldJrrdPf6xlPIIPfFnZ dxOQ88d++/rgbT2d/EA837q2HgNZD2yAkmm2A+ka5Q/ptUOUpoxmaFVYWLbB05FD18AX lGiw== X-Gm-Message-State: APjAAAV5fIwryGzznebbwrsmIkyhh2nUIUfGORQCFXEYv6rAGyfwgEJc zDE6q2fq8BnEqjeyEm6bShQNuGqO/NM= X-Received: by 2002:a17:902:bc83:: with SMTP id bb3mr140601680plb.56.1564858092641; Sat, 03 Aug 2019 11:48:12 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.11 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:34 -0700 Message-Id: <20190803184800.8221-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-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::641 Subject: [Qemu-devel] [PATCH v3 08/34] 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, qemu-arm@nongnu.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 9a18ecf8f6..8baeb3f319 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)) {