pKVM sets a protected vCPU's HCR_EL2, MDCR_EL2 and HCRX_EL2 at EL2 from the VM's ID registers, but never computes its fine-grained traps, which stay 0. That traps every register with a negative-polarity trap bit, so a feature such as S1PIE can't be advertised to a protected VM. Link config.c into nVHE hyp and compute the VM's FGU masks and the vCPU's fine-grained traps there, under vm_table_lock, once the ID registers are set. Build hyp without the latent_entropy plugin, which adds a reference to config.c's __init functions that hyp can't resolve. This also restores the AmpereOne AC03_CPU_38 masking of a protected vCPU's TCR_EL1 writes, which was lost when the erratum's trap moved into the per-vCPU fine-grained traps. Fixes: fb10ddf35c1cc ("KVM: arm64: Compute per-vCPU FGTs at vcpu_load()") Signed-off-by: Fuad Tabba --- arch/arm64/kvm/hyp/nvhe/Makefile | 4 +++- arch/arm64/kvm/hyp/nvhe/pkvm.c | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/hyp/nvhe/Makefile b/arch/arm64/kvm/hyp/nvhe/Makefile index 56a7e2c05f73a..2980f1af90166 100644 --- a/arch/arm64/kvm/hyp/nvhe/Makefile +++ b/arch/arm64/kvm/hyp/nvhe/Makefile @@ -12,7 +12,8 @@ asflags-y := -D__KVM_NVHE_HYPERVISOR__ -D__DISABLE_EXPORTS ccflags-y := -D__KVM_NVHE_HYPERVISOR__ -D__DISABLE_EXPORTS -D__DISABLE_TRACE_MMIO__ ccflags-y += -fno-stack-protector \ -DDISABLE_BRANCH_PROFILING \ - $(DISABLE_KSTACK_ERASE) + $(DISABLE_KSTACK_ERASE) \ + $(DISABLE_LATENT_ENTROPY_PLUGIN) hostprogs := gen-hyprel HOST_EXTRACFLAGS += -I$(objtree)/include @@ -27,6 +28,7 @@ hyp-obj-y := timer-sr.o sysreg-sr.o debug-sr.o switch.o tlb.o hyp-init.o host.o cache.o setup.o mm.o mem_protect.o sys_regs.o pkvm.o stacktrace.o ffa.o hyp-obj-y += ../vgic-v3-sr.o ../aarch32.o ../vgic-v2-cpuif-proxy.o ../entry.o \ ../hyp-entry.o ../exception.o ../pgtable.o ../vgic-v5-sr.o +hyp-obj-y += ../../config.o hyp-obj-y += ../../../kernel/smccc-call.o hyp-obj-$(CONFIG_LIST_HARDENED) += list_debug.o hyp-obj-$(CONFIG_NVHE_EL2_TRACING) += clock.o trace.o events.o diff --git a/arch/arm64/kvm/hyp/nvhe/pkvm.c b/arch/arm64/kvm/hyp/nvhe/pkvm.c index fba8dfe6389d6..465d963d6ff57 100644 --- a/arch/arm64/kvm/hyp/nvhe/pkvm.c +++ b/arch/arm64/kvm/hyp/nvhe/pkvm.c @@ -206,6 +206,8 @@ static int pkvm_vcpu_init_traps(struct pkvm_hyp_vcpu *hyp_vcpu) pvm_init_traps_hcr(vcpu); pvm_init_traps_mdcr(vcpu); vcpu_set_hcrx(vcpu); + kvm_init_fgu(vcpu->kvm); + kvm_vcpu_load_fgt(vcpu); return 0; } -- 2.47.3