Skip to content

Commit 8559211

Browse files
Alexandru EliseiMarc Zyngier
authored andcommitted
KVM: arm64: VHE: Compute fgt traps before activating them
On VHE, the Fine Grain Traps registers are written to hardware in kvm_arch_vcpu_load()->..->__activate_traps_hfgxtr(), but the fgt array is computed later, in kvm_vcpu_load_fgt(). This can lead to zero being written to the FGT registers the first time a VCPU is loaded. Also, any changes to the fgt array will be visible only after the VCPU is scheduled out, and then back in, which is not the intended behaviour. Fix it by computing the fgt array just before the fgt traps are written to hardware. Fixes: fb10ddf ("KVM: arm64: Compute per-vCPU FGTs at vcpu_load()") Signed-off-by: Alexandru Elisei <[email protected]> Reviewed-by: Oliver Upton <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Marc Zyngier <[email protected]>
1 parent 0f559cd commit 8559211

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/arm64/kvm/arm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,7 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
624624
kvm_timer_vcpu_load(vcpu);
625625
kvm_vgic_load(vcpu);
626626
kvm_vcpu_load_debug(vcpu);
627+
kvm_vcpu_load_fgt(vcpu);
627628
if (has_vhe())
628629
kvm_vcpu_load_vhe(vcpu);
629630
kvm_arch_vcpu_load_fp(vcpu);
@@ -642,7 +643,6 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
642643
vcpu->arch.hcr_el2 |= HCR_TWI;
643644

644645
vcpu_set_pauth_traps(vcpu);
645-
kvm_vcpu_load_fgt(vcpu);
646646

647647
if (is_protected_kvm_enabled()) {
648648
kvm_call_hyp_nvhe(__pkvm_vcpu_load,

0 commit comments

Comments
 (0)