Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp540341lqp; Fri, 5 Apr 2024 01:02:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWk070YSJPXZxPkl3P+ZrIcXKP2t6K3UY0a5oMNLFvX6yruAoh5lpznCImwANyWEa6X379Jfoj/9YdTxLgSGm6A8jL14cpIqART1+L8iw== X-Google-Smtp-Source: AGHT+IGyqhSmcaqLGEWBRq02WKekNlw4yfom/4fz7Nzqe8kAo3YzXTGxwzZCazj3yNS5nriIt/LD X-Received: by 2002:a50:9556:0:b0:56b:ddcb:bb67 with SMTP id v22-20020a509556000000b0056bddcbbb67mr780735eda.2.1712304171055; Fri, 05 Apr 2024 01:02:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712304171; cv=pass; d=google.com; s=arc-20160816; b=QABXx3YuNj2mHZLA3/vLyz+/f/AZX7aPORkWfRoSqAFvA07Lrqxuys/NZaFVYaxh1u hfYpusNWkqj0gzOLofZvKBOgvSHSCGJXpawwrQW5iukCIma/5hQQ5egJLa8FmetlVIpK gwJWSlS/JyRLRAwm3oUxskNXM3tmGPkvXI9La11ogRbKCmiCJMC1u4PQMQzbWqi/O1xP joIkqiMbaMv9mNqmdxwSiSk6NtGGnVFF36G5osC6paYnVGfpxWX79cBXDJS+LY1zwYFM Ns/a6xvi1WiTC04Q/eDg/gQfl2b5k+YDsaOHL+/M08F2dWiUzqKQ79Ik79daXHUXRYYB tSgQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=b8En/AfmXAOJPQ3115ZIByIFZv4DXoQEWKD57zsn2fA=; fh=Bp8sAfpmdjftGzR2Hh8bfdOyf/FrWKFQA1SL63hwuv8=; b=CIx5D6fUlTpOZxiFhoL54skxDLitSNYNigyBESIr6yoTW9NUqkQOBGiJ4/IYyrVBat f+PXIK0xVJuHhARpHb8LE9zQcKrgtplzexbkc7Aei8WJITtvyovYvm1aXBM6ZJs/vGKG S2GIuhsQ2EXfU8TimC6af+rrm0RwkL0Vxyd4PXJVZQXHzGJBoqeF+CpYSmuyhSn0rKHh 7WBpo1D05tflTRAzgLW/F057HVSPJFjz7kYQ57XLNYwVOOjkeKch4dQjHa4dEfIpo68n zUJ8lb0dpuuhGU2tLayA1caiuT6JlIGqNJ/GTRJLaIFafyJEDYSiiDf6caS54xRiTyD5 RX+g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-132625-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132625-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id y9-20020a056402270900b0056e0bca6a63si502213edd.550.2024.04.05.01.02.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 01:02:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-132625-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-132625-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132625-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id F147A1F23775 for ; Fri, 5 Apr 2024 08:02:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6F53F1465AF; Fri, 5 Apr 2024 08:00:56 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D153E142E81; Fri, 5 Apr 2024 08:00:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712304055; cv=none; b=AwRHH5OGOassAg3SK8of8t5lGJH9b3Z32dmcnuY+hQfoNQ0/FeOso4DLGLmL9ZIOUDa1B3ZR9wyyPq3zAawXVxtSDkuu5/cvm0MqNDxSP0xH2vHLJ1yv4IFk+d/i+mN9ZyO/SPdcs035EjuslMQ66p+ZTWVJ2NJ3w+h3mD5fnFU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712304055; c=relaxed/simple; bh=iSwZRZL9c5VQt+IMlIUvW9RR22JtUFl2SybvCS3S/38=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hXrkkw0j0Y+P+2U8O6OwgP7AOTkweTyCraUnZ4EbVCWjU/AXkM0WFqYrEjGh2IwQRwrQFIqAiUqvGFsaBhlfHFz/oLboY/+FRs1F6I9JhyC8UgHTPQnW5dod55WM/HP7hTSeVRXlX46MeoIZw5stDoCQv1iIzwmb7fYODBUHKVA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E3CFC1007; Fri, 5 Apr 2024 01:01:23 -0700 (PDT) Received: from a077893.blr.arm.com (a077893.blr.arm.com [10.162.41.6]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id EB97B3F64C; Fri, 5 Apr 2024 01:00:48 -0700 (PDT) From: Anshuman Khandual To: linux-arm-kernel@lists.infradead.org Cc: Anshuman Khandual , Jonathan Corbet , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Catalin Marinas , Will Deacon , Mark Brown , Mark Rutland , kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Subject: [RFC 7/8] arm64/boot: Enable EL2 requirements for FEAT_Debugv8p9 Date: Fri, 5 Apr 2024 13:30:07 +0530 Message-Id: <20240405080008.1225223-8-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240405080008.1225223-1-anshuman.khandual@arm.com> References: <20240405080008.1225223-1-anshuman.khandual@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Fine grained trap control for MDSELR_EL1 register needs to be configured in HDFGRTR2_EL2, and HDFGWTR2_EL2 registers when kernel enters at EL1, but EL2 is also present. This adds a new helper __init_el2_fgt2() initializing this new FEAT_FGT2 based fine grained registers. MDCR_EL2.EBWE needs to be enabled for additional (beyond 16) breakpoint and watchpoint exceptions when kernel enters at EL1, but EL2 is also present. This updates __init_el2_debug() as required for FEAT_Debugv8p9. While here, also update booting.rst with MDCR_EL3 and SCR_EL3 requirements. Cc: Catalin Marinas Cc: Will Deacon Cc: Jonathan Corbet Cc: Marc Zyngier Cc: Oliver Upton Cc: linux-arm-kernel@lists.infradead.org Cc: linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: kvmarm@lists.linux.dev Signed-off-by: Anshuman Khandual --- Documentation/arch/arm64/booting.rst | 19 +++++++++++++++++++ arch/arm64/include/asm/el2_setup.h | 27 +++++++++++++++++++++++++++ arch/arm64/include/asm/kvm_arm.h | 1 + 3 files changed, 47 insertions(+) diff --git a/Documentation/arch/arm64/booting.rst b/Documentation/arch/arm64/booting.rst index b57776a68f15..e69d972018cf 100644 --- a/Documentation/arch/arm64/booting.rst +++ b/Documentation/arch/arm64/booting.rst @@ -285,6 +285,12 @@ Before jumping into the kernel, the following conditions must be met: - SCR_EL3.FGTEn (bit 27) must be initialised to 0b1. + For CPUs with the Fine Grained Traps (FEAT_FGT2) extension present: + + - If EL3 is present and the kernel is entered at EL2: + + - SCR_EL3.FGTEn2 (bit 59) must be initialised to 0b1. + For CPUs with support for HCRX_EL2 (FEAT_HCX) present: - If EL3 is present and the kernel is entered at EL2: @@ -319,6 +325,19 @@ Before jumping into the kernel, the following conditions must be met: - ZCR_EL2.LEN must be initialised to the same value for all CPUs the kernel will execute on. + For CPUs with FEAT_Debugv8p9 extension present: + + - If the kernel is entered at EL1 and EL2 is present: + + - HDFGRTR2_EL2.nMDSELR_EL1 (bit 5) must be initialized to 0b1 + - HDFGWTR2_EL2.nMDSELR_EL1 (bit 5) must be initialized to 0b1 + - MDCR_EL2.EBWE (bit 43) must be initialized to 0b1 + + - If EL3 is present: + + - MDCR_EL3.TDA (bit 9) must be initialized to 0b0 + - MDCR_EL3.EBWE (bit 43) must be initialized to 0b1 + For CPUs with the Scalable Matrix Extension (FEAT_SME): - If EL3 is present: diff --git a/arch/arm64/include/asm/el2_setup.h b/arch/arm64/include/asm/el2_setup.h index b7afaa026842..0425067a93d9 100644 --- a/arch/arm64/include/asm/el2_setup.h +++ b/arch/arm64/include/asm/el2_setup.h @@ -96,6 +96,14 @@ // to own it. .Lskip_trace_\@: + mrs x1, id_aa64dfr0_el1 + ubfx x1, x1, #ID_AA64DFR0_EL1_DebugVer_SHIFT, #4 + cmp x1, #ID_AA64DFR0_EL1_DebugVer_V8P9 + b.lt .Lskip_dbg_v8p9_\@ + + mov x0, #MDCR_EL2_EBWE + orr x2, x2, x0 +.Lskip_dbg_v8p9_\@: msr mdcr_el2, x2 // Configure debug traps .endm @@ -203,6 +211,24 @@ .Lskip_fgt_\@: .endm +.macro __init_el2_fgt2 + mrs x1, id_aa64mmfr0_el1 + ubfx x1, x1, #ID_AA64MMFR0_EL1_FGT_SHIFT, #4 + cmp x1, #ID_AA64MMFR0_EL1_FGT_FGT2 + b.lt .Lskip_fgt2_\@ + + mrs x1, id_aa64dfr0_el1 + ubfx x1, x1, #ID_AA64DFR0_EL1_DebugVer_SHIFT, #4 + cmp x1, #ID_AA64DFR0_EL1_DebugVer_V8P9 + b.lt .Lskip_dbg_v8p9_\@ + + mov_q x0, HDFGWTR2_EL2_nMDSELR_EL1 + msr_s SYS_HDFGWTR2_EL2, x0 + msr_s SYS_HDFGRTR2_EL2, x0 +.Lskip_dbg_v8p9_\@: +.Lskip_fgt2_\@: +.endm + .macro __init_el2_nvhe_prepare_eret mov x0, #INIT_PSTATE_EL1 msr spsr_el2, x0 @@ -228,6 +254,7 @@ __init_el2_nvhe_idregs __init_el2_cptr __init_el2_fgt + __init_el2_fgt2 .endm #ifndef __KVM_NVHE_HYPERVISOR__ diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h index e01bb5ca13b7..9d77dfc43e08 100644 --- a/arch/arm64/include/asm/kvm_arm.h +++ b/arch/arm64/include/asm/kvm_arm.h @@ -306,6 +306,7 @@ BIT(11)) /* Hyp Debug Configuration Register bits */ +#define MDCR_EL2_EBWE (UL(1) << 43) #define MDCR_EL2_E2TB_MASK (UL(0x3)) #define MDCR_EL2_E2TB_SHIFT (UL(24)) #define MDCR_EL2_HPMFZS (UL(1) << 36) -- 2.25.1