kvm_reset_vcpu - sets core registers and sys_regs to reset value @vcpu: The VCPU pointer
This function sets the registers on the virtual CPU struct to their architecturally defined reset values, except for registers whose reset is deferred until kvm_arm_vcpu_finalize().
Note: This function can be called from two paths: The KVM_ARM_VCPU_INIT ioctl or as part of handling a request issued by another VCPU in the PSCI handling code. In the first case, the VCPU will not be loaded, and in the second case the VCPU will be loaded. Because this function operates purely on the memory-backed values of system registers, we want to do a full put if we were loaded (handling a request) and load the values back at the end of the function. Otherwise we leave the state alone. In both cases, we disable preemption around the vcpu reset as we would otherwise race with preempt notifiers which also call put/load.
193 struct vcpu_reset_state reset_state;
197 spin_lock(&vcpu->arch.mp_state_lock);
198 reset_state = vcpu->arch.reset_state;
199 vcpu->arch.reset_state.reset =
false;
200 spin_unlock(&vcpu->arch.mp_state_lock);
206 loaded = (vcpu->cpu != -1);
210 if (!kvm_arm_vcpu_sve_finalized(vcpu)) {
211 if (vcpu_has_feature(vcpu, KVM_ARM_VCPU_SVE))
217 if (vcpu_has_feature(vcpu, KVM_ARM_VCPU_PTRAUTH_ADDRESS) ||
218 vcpu_has_feature(vcpu, KVM_ARM_VCPU_PTRAUTH_GENERIC))
221 if (vcpu_el1_is_32bit(vcpu))
223 else if (vcpu_has_nv(vcpu))
229 memset(vcpu_gp_regs(vcpu), 0,
sizeof(*vcpu_gp_regs(vcpu)));
230 memset(&vcpu->arch.ctxt.fp_regs, 0,
sizeof(vcpu->arch.ctxt.fp_regs));
231 vcpu->arch.ctxt.spsr_abt = 0;
232 vcpu->arch.ctxt.spsr_und = 0;
233 vcpu->arch.ctxt.spsr_irq = 0;
234 vcpu->arch.ctxt.spsr_fiq = 0;
235 vcpu_gp_regs(vcpu)->pstate = pstate;
244 if (reset_state.reset) {
245 unsigned long target_pc = reset_state.pc;
248 if (vcpu_mode_is_32bit(vcpu) && (target_pc & 1)) {
250 vcpu_set_thumb(vcpu);
255 kvm_vcpu_set_be(vcpu);
257 *vcpu_pc(vcpu) = target_pc;
258 vcpu_set_reg(vcpu, 0, reset_state.r0);
void kvm_timer_vcpu_reset(struct kvm_vcpu *vcpu)
void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
void kvm_pmu_vcpu_reset(struct kvm_vcpu *vcpu)
#define VCPU_RESET_PSTATE_EL1
static void kvm_vcpu_enable_ptrauth(struct kvm_vcpu *vcpu)
#define VCPU_RESET_PSTATE_EL2
static void kvm_vcpu_reset_sve(struct kvm_vcpu *vcpu)
static void kvm_vcpu_enable_sve(struct kvm_vcpu *vcpu)
#define VCPU_RESET_PSTATE_SVC
void kvm_reset_sys_regs(struct kvm_vcpu *vcpu)