From 7590636e686fd5fac7d83bb95e1a606df3ff424f Mon Sep 17 00:00:00 2001 From: Quentin Perret Date: Wed, 17 May 2023 14:20:57 +0000 Subject: [PATCH] ANDROID: arm64: Check FGT cap before touching HFGWTR_EL2 Writing to HFGWTR_EL2 is undefined on CPUs without the capability, so make sure not to touch the register when that is the case. Bug: 282917063 Bug: 282993310 Change-Id: I85211105d6b1fbee854b4f13f037b8573c5a211c Signed-off-by: Quentin Perret --- arch/arm64/kvm/hyp/nvhe/hyp-init.S | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-init.S b/arch/arm64/kvm/hyp/nvhe/hyp-init.S index 96940d81e002..9da86976d61d 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp-init.S +++ b/arch/arm64/kvm/hyp/nvhe/hyp-init.S @@ -95,9 +95,13 @@ SYM_CODE_START_LOCAL(___kvm_hyp_init) ldr x1, [x0, #NVHE_INIT_HCR_EL2] msr hcr_el2, x1 + mrs x1, ID_AA64MMFR0_EL1 + and x1, x1, #(0xf << ID_AA64MMFR0_EL1_FGT_SHIFT) + cbz x1, 1f ldr x1, [x0, #NVHE_INIT_HFGWTR_EL2] msr_s SYS_HFGWTR_EL2, x1 +1: ldr x1, [x0, #NVHE_INIT_VTTBR] msr vttbr_el2, x1