From 8691a0dae0010b6fb8a09cf36947490bafc62d2c Mon Sep 17 00:00:00 2001 From: Quentin Perret Date: Wed, 7 Jun 2023 09:40:26 +0000 Subject: [PATCH] ANDROID: KVM: arm64: Initialize hfgwtr_el2 correctly With FEAT_FGT, most bits in hfgwtr_el2 must be set to 1 to enable trapping of MSR writes of certain registers. However, there is a notable (and arguably curious) exception for nSMPRI_EL1 and nTPIDR2_EL0 which must be set to 1 to _disable_ trapping of the corresponding SME registers. Make sure to initialize hfgwtr_el2 in the pKVM init params accordingly to avoid accidentally enabling certain traps on hardware that supports FEAT_FGT and FEAT_SME. Bug: 282917063 Bug: 282993310 Change-Id: Ia96fa6856b4e7ef98b3cea4f03fcbc0ee03f10c5 Tested-by: Nick Desaulniers Signed-off-by: Quentin Perret --- arch/arm64/kvm/arm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 4131f0662a0a..a219e6ddf4f5 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -1687,6 +1687,7 @@ static void cpu_prepare_hyp_mode(int cpu) else params->hcr_el2 = HCR_HOST_NVHE_FLAGS; params->vttbr = params->vtcr = 0; + params->hfgwtr_el2 = HFGxTR_EL2_nSMPRI_EL1_MASK | HFGxTR_EL2_nTPIDR2_EL0_MASK; /* * Flush the init params from the data cache because the struct will