fpsimd.c (4b4193256c8d3bc3a5397b5cd9494c2ad386317d) | fpsimd.c (83857371d4cbeff8551fa770e045be9c6b04715c) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * arch/arm64/kvm/fpsimd.c: Guest/host FPSIMD context coordination helpers 4 * 5 * Copyright 2018 Arm Limited 6 * Author: Dave Martin <Dave.Martin@arm.com> 7 */ 8#include <linux/irqflags.h> 9#include <linux/sched.h> 10#include <linux/thread_info.h> 11#include <linux/kvm_host.h> 12#include <asm/fpsimd.h> 13#include <asm/kvm_asm.h> | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * arch/arm64/kvm/fpsimd.c: Guest/host FPSIMD context coordination helpers 4 * 5 * Copyright 2018 Arm Limited 6 * Author: Dave Martin <Dave.Martin@arm.com> 7 */ 8#include <linux/irqflags.h> 9#include <linux/sched.h> 10#include <linux/thread_info.h> 11#include <linux/kvm_host.h> 12#include <asm/fpsimd.h> 13#include <asm/kvm_asm.h> |
14#include <asm/kvm_hyp.h> |
|
14#include <asm/kvm_mmu.h> 15#include <asm/sysreg.h> 16 17/* 18 * Called on entry to KVM_RUN unless this vcpu previously ran at least 19 * once and the most recent prior KVM_RUN for this vcpu was called from 20 * the same task as current (highly likely). 21 * --- 85 unchanged lines hidden (view full) --- 107 bool guest_has_sve = vcpu_has_sve(vcpu); 108 109 local_irq_save(flags); 110 111 if (vcpu->arch.flags & KVM_ARM64_FP_ENABLED) { 112 fpsimd_save_and_flush_cpu_state(); 113 114 if (guest_has_sve) | 15#include <asm/kvm_mmu.h> 16#include <asm/sysreg.h> 17 18/* 19 * Called on entry to KVM_RUN unless this vcpu previously ran at least 20 * once and the most recent prior KVM_RUN for this vcpu was called from 21 * the same task as current (highly likely). 22 * --- 85 unchanged lines hidden (view full) --- 108 bool guest_has_sve = vcpu_has_sve(vcpu); 109 110 local_irq_save(flags); 111 112 if (vcpu->arch.flags & KVM_ARM64_FP_ENABLED) { 113 fpsimd_save_and_flush_cpu_state(); 114 115 if (guest_has_sve) |
115 __vcpu_sys_reg(vcpu, ZCR_EL1) = read_sysreg_s(SYS_ZCR_EL12); | 116 __vcpu_sys_reg(vcpu, ZCR_EL1) = read_sysreg_el1(SYS_ZCR); |
116 } else if (host_has_sve) { 117 /* 118 * The FPSIMD/SVE state in the CPU has not been touched, and we 119 * have SVE (and VHE): CPACR_EL1 (alias CPTR_EL2) has been 120 * reset to CPACR_EL1_DEFAULT by the Hyp code, disabling SVE 121 * for EL0. To avoid spurious traps, restore the trap state 122 * seen by kvm_arch_vcpu_load_fp(): 123 */ 124 if (vcpu->arch.flags & KVM_ARM64_HOST_SVE_ENABLED) 125 sysreg_clear_set(CPACR_EL1, 0, CPACR_EL1_ZEN_EL0EN); 126 else 127 sysreg_clear_set(CPACR_EL1, CPACR_EL1_ZEN_EL0EN, 0); 128 } 129 130 update_thread_flag(TIF_SVE, 131 vcpu->arch.flags & KVM_ARM64_HOST_SVE_IN_USE); 132 133 local_irq_restore(flags); 134} | 117 } else if (host_has_sve) { 118 /* 119 * The FPSIMD/SVE state in the CPU has not been touched, and we 120 * have SVE (and VHE): CPACR_EL1 (alias CPTR_EL2) has been 121 * reset to CPACR_EL1_DEFAULT by the Hyp code, disabling SVE 122 * for EL0. To avoid spurious traps, restore the trap state 123 * seen by kvm_arch_vcpu_load_fp(): 124 */ 125 if (vcpu->arch.flags & KVM_ARM64_HOST_SVE_ENABLED) 126 sysreg_clear_set(CPACR_EL1, 0, CPACR_EL1_ZEN_EL0EN); 127 else 128 sysreg_clear_set(CPACR_EL1, CPACR_EL1_ZEN_EL0EN, 0); 129 } 130 131 update_thread_flag(TIF_SVE, 132 vcpu->arch.flags & KVM_ARM64_HOST_SVE_IN_USE); 133 134 local_irq_restore(flags); 135} |