Keep track of the cpu that a vcpu's FP state was last loaded onto. This information is needed in order to tell whether a vcpu's latest FP state is already loaded on a cpu to avoid unnecessary reloading. The method follows the pattern used by thread_struct whereby an fpsimd_cpu field is added and updated when the state is loaded. Signed-off-by: Andrew Scull <ascull@xxxxxxxxxx> Cc: Dave Martin <Dave.Martin@xxxxxxx> --- arch/arm64/include/asm/kvm_host.h | 1 + arch/arm64/kvm/arm.c | 2 ++ arch/arm64/kvm/hyp/include/hyp/switch.h | 2 ++ 3 files changed, 5 insertions(+) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 8a559fa2f237..a01194371ae5 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -306,6 +306,7 @@ struct kvm_vcpu_arch { struct kvm_guest_debug_arch vcpu_debug_state; struct kvm_guest_debug_arch external_debug_state; + int fpsimd_cpu; struct user_fpsimd_state *host_fpsimd_state; /* hyp VA */ struct { diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index e3edea8379f3..87141c8d63e6 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -313,6 +313,8 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu) vcpu->arch.mmu_page_cache.gfp_zero = __GFP_ZERO; + vcpu->arch.fpsimd_cpu = NR_CPUS; + /* Set up the timer */ kvm_timer_vcpu_init(vcpu); diff --git a/arch/arm64/kvm/hyp/include/hyp/switch.h b/arch/arm64/kvm/hyp/include/hyp/switch.h index 8eb1f87f9119..1afee8557ddf 100644 --- a/arch/arm64/kvm/hyp/include/hyp/switch.h +++ b/arch/arm64/kvm/hyp/include/hyp/switch.h @@ -259,6 +259,8 @@ static inline bool __hyp_handle_fpsimd(struct kvm_vcpu *vcpu) if (!(read_sysreg(hcr_el2) & HCR_RW)) write_sysreg(__vcpu_sys_reg(vcpu, FPEXC32_EL2), fpexc32_el2); + vcpu->arch.fpsimd_cpu = smp_processor_id(); + vcpu->arch.flags |= KVM_ARM64_FP_ENABLED; return true; -- 2.30.1.766.gb4fecdf3b7-goog _______________________________________________ kvmarm mailing list kvmarm@xxxxxxxxxxxxxxxxxxxxx https://lists.cs.columbia.edu/mailman/listinfo/kvmarm