From 484befbfcbe5289fa237a96c36a2da75ff3ff2ba Mon Sep 17 00:00:00 2001 From: Arvind Ram Prakash Date: Wed, 12 Mar 2025 16:45:05 -0500 Subject: [PATCH] fix(cpufeat): add feat_hcx check before enabling FEAT_MOPS This patch also checks for FEAT_HCX before enabling FEAT_MOPS when INIT_UNUSED_NS_EL1 = 1 and adds build dependency check. Signed-off-by: Arvind Ram Prakash Change-Id: Iff4a068aa392fc8d29e2e4da7a2e7df0b3104e65 --- Makefile | 8 ++++++++ lib/el3_runtime/aarch64/context_mgmt.c | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f45745345..e111be20a 100644 --- a/Makefile +++ b/Makefile @@ -1021,6 +1021,14 @@ ifeq (${ENABLE_SVE_FOR_SWD},1) endif endif +# Enabling FEAT_MOPS requires access to hcrx_el2 registers which is +# available only when FEAT_HCX is enabled. +ifneq (${ENABLE_FEAT_MOPS},0) + ifeq (${ENABLE_FEAT_HCX},0) + $(error "ENABLE_FEAT_MOPS requires ENABLE_FEAT_HCX") + endif +endif + # Enabling SVE for both the worlds typically requires the context # management of SVE registers. The only exception being SPMC at S-EL2. ifeq (${ENABLE_SVE_FOR_SWD}, 1) diff --git a/lib/el3_runtime/aarch64/context_mgmt.c b/lib/el3_runtime/aarch64/context_mgmt.c index c35aae93d..d870da492 100644 --- a/lib/el3_runtime/aarch64/context_mgmt.c +++ b/lib/el3_runtime/aarch64/context_mgmt.c @@ -905,7 +905,7 @@ static void manage_extensions_nonsecure_el2_unused(void) sme_init_el2_unused(); } - if (is_feat_mops_supported()) { + if (is_feat_mops_supported() && is_feat_hcx_supported()) { write_hcrx_el2(read_hcrx_el2() | HCRX_EL2_MSCEn_BIT); }