diff options
Diffstat (limited to 'arch/arm64/kvm/handle_exit.c')
| -rw-r--r-- | arch/arm64/kvm/handle_exit.c | 33 | 
1 files changed, 21 insertions, 12 deletions
diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c index 9beaca03343..182415e1a95 100644 --- a/arch/arm64/kvm/handle_exit.c +++ b/arch/arm64/kvm/handle_exit.c @@ -30,38 +30,47 @@ typedef int (*exit_handle_fn)(struct kvm_vcpu *, struct kvm_run *);  static int handle_hvc(struct kvm_vcpu *vcpu, struct kvm_run *run)  { -	if (kvm_psci_call(vcpu)) +	int ret; + +	ret = kvm_psci_call(vcpu); +	if (ret < 0) { +		kvm_inject_undefined(vcpu);  		return 1; +	} -	kvm_inject_undefined(vcpu); -	return 1; +	return ret;  }  static int handle_smc(struct kvm_vcpu *vcpu, struct kvm_run *run)  { -	if (kvm_psci_call(vcpu)) -		return 1; -  	kvm_inject_undefined(vcpu);  	return 1;  }  /** - * kvm_handle_wfi - handle a wait-for-interrupts instruction executed by a guest + * kvm_handle_wfx - handle a wait-for-interrupts or wait-for-event + *		    instruction executed by a guest + *   * @vcpu:	the vcpu pointer   * - * Simply call kvm_vcpu_block(), which will halt execution of + * WFE: Yield the CPU and come back to this vcpu when the scheduler + * decides to. + * WFI: Simply call kvm_vcpu_block(), which will halt execution of   * world-switches and schedule other host processes until there is an   * incoming IRQ or FIQ to the VM.   */ -static int kvm_handle_wfi(struct kvm_vcpu *vcpu, struct kvm_run *run) +static int kvm_handle_wfx(struct kvm_vcpu *vcpu, struct kvm_run *run)  { -	kvm_vcpu_block(vcpu); +	if (kvm_vcpu_get_hsr(vcpu) & ESR_EL2_EC_WFI_ISS_WFE) +		kvm_vcpu_on_spin(vcpu); +	else +		kvm_vcpu_block(vcpu); +  	return 1;  }  static exit_handle_fn arm_exit_handlers[] = { -	[ESR_EL2_EC_WFI]	= kvm_handle_wfi, +	[ESR_EL2_EC_WFI]	= kvm_handle_wfx,  	[ESR_EL2_EC_CP15_32]	= kvm_handle_cp15_32,  	[ESR_EL2_EC_CP15_64]	= kvm_handle_cp15_64,  	[ESR_EL2_EC_CP14_MR]	= kvm_handle_cp14_access, @@ -82,7 +91,7 @@ static exit_handle_fn kvm_get_exit_handler(struct kvm_vcpu *vcpu)  	if (hsr_ec >= ARRAY_SIZE(arm_exit_handlers) ||  	    !arm_exit_handlers[hsr_ec]) { -		kvm_err("Unkown exception class: hsr: %#08x\n", +		kvm_err("Unknown exception class: hsr: %#08x\n",  			(unsigned int)kvm_vcpu_get_hsr(vcpu));  		BUG();  	}  | 
