@@ -364,8 +364,8 @@ static void svm_set_interrupt_shadow(struct kvm_vcpu *vcpu, int mask)
364364 svm -> vmcb -> control .int_state |= SVM_INTERRUPT_SHADOW_MASK ;
365365
366366}
367- static bool svm_can_emulate_instruction (struct kvm_vcpu * vcpu , int emul_type ,
368- void * insn , int insn_len );
367+ static int svm_check_emulate_instruction (struct kvm_vcpu * vcpu , int emul_type ,
368+ void * insn , int insn_len );
369369
370370static int __svm_skip_emulated_instruction (struct kvm_vcpu * vcpu ,
371371 bool commit_side_effects )
@@ -391,7 +391,7 @@ static int __svm_skip_emulated_instruction(struct kvm_vcpu *vcpu,
391391 * right thing and treats "can't emulate" as outright failure
392392 * for EMULTYPE_SKIP.
393393 */
394- if (! svm_can_emulate_instruction (vcpu , EMULTYPE_SKIP , NULL , 0 ))
394+ if (svm_check_emulate_instruction (vcpu , EMULTYPE_SKIP , NULL , 0 ) != X86EMUL_CONTINUE )
395395 return 0 ;
396396
397397 if (unlikely (!commit_side_effects ))
@@ -4727,15 +4727,15 @@ static void svm_enable_smi_window(struct kvm_vcpu *vcpu)
47274727}
47284728#endif
47294729
4730- static bool svm_can_emulate_instruction (struct kvm_vcpu * vcpu , int emul_type ,
4731- void * insn , int insn_len )
4730+ static int svm_check_emulate_instruction (struct kvm_vcpu * vcpu , int emul_type ,
4731+ void * insn , int insn_len )
47324732{
47334733 bool smep , smap , is_user ;
47344734 u64 error_code ;
47354735
47364736 /* Emulation is always possible when KVM has access to all guest state. */
47374737 if (!sev_guest (vcpu -> kvm ))
4738- return true ;
4738+ return X86EMUL_CONTINUE ;
47394739
47404740 /* #UD and #GP should never be intercepted for SEV guests. */
47414741 WARN_ON_ONCE (emul_type & (EMULTYPE_TRAP_UD |
@@ -4747,14 +4747,14 @@ static bool svm_can_emulate_instruction(struct kvm_vcpu *vcpu, int emul_type,
47474747 * to guest register state.
47484748 */
47494749 if (sev_es_guest (vcpu -> kvm ))
4750- return false ;
4750+ return X86EMUL_RETRY_INSTR ;
47514751
47524752 /*
47534753 * Emulation is possible if the instruction is already decoded, e.g.
47544754 * when completing I/O after returning from userspace.
47554755 */
47564756 if (emul_type & EMULTYPE_NO_DECODE )
4757- return true ;
4757+ return X86EMUL_CONTINUE ;
47584758
47594759 /*
47604760 * Emulation is possible for SEV guests if and only if a prefilled
@@ -4780,9 +4780,11 @@ static bool svm_can_emulate_instruction(struct kvm_vcpu *vcpu, int emul_type,
47804780 * success (and in practice it will work the vast majority of the time).
47814781 */
47824782 if (unlikely (!insn )) {
4783- if (!(emul_type & EMULTYPE_SKIP ))
4784- kvm_queue_exception (vcpu , UD_VECTOR );
4785- return false;
4783+ if (emul_type & EMULTYPE_SKIP )
4784+ return X86EMUL_RETRY_INSTR ;
4785+
4786+ kvm_queue_exception (vcpu , UD_VECTOR );
4787+ return X86EMUL_PROPAGATE_FAULT ;
47864788 }
47874789
47884790 /*
@@ -4793,7 +4795,7 @@ static bool svm_can_emulate_instruction(struct kvm_vcpu *vcpu, int emul_type,
47934795 * table used to translate CS:RIP resides in emulated MMIO.
47944796 */
47954797 if (likely (insn_len ))
4796- return true ;
4798+ return X86EMUL_CONTINUE ;
47974799
47984800 /*
47994801 * Detect and workaround Errata 1096 Fam_17h_00_0Fh.
@@ -4851,6 +4853,7 @@ static bool svm_can_emulate_instruction(struct kvm_vcpu *vcpu, int emul_type,
48514853 kvm_inject_gp (vcpu , 0 );
48524854 else
48534855 kvm_make_request (KVM_REQ_TRIPLE_FAULT , vcpu );
4856+ return X86EMUL_PROPAGATE_FAULT ;
48544857 }
48554858
48564859resume_guest :
@@ -4868,7 +4871,7 @@ static bool svm_can_emulate_instruction(struct kvm_vcpu *vcpu, int emul_type,
48684871 * doesn't explicitly define "ignored", i.e. doing nothing and letting
48694872 * the guest spin is technically "ignoring" the access.
48704873 */
4871- return false ;
4874+ return X86EMUL_RETRY_INSTR ;
48724875}
48734876
48744877static bool svm_apic_init_signal_blocked (struct kvm_vcpu * vcpu )
@@ -5028,7 +5031,7 @@ static struct kvm_x86_ops svm_x86_ops __initdata = {
50285031 .vm_copy_enc_context_from = sev_vm_copy_enc_context_from ,
50295032 .vm_move_enc_context_from = sev_vm_move_enc_context_from ,
50305033
5031- .can_emulate_instruction = svm_can_emulate_instruction ,
5034+ .check_emulate_instruction = svm_check_emulate_instruction ,
50325035
50335036 .apic_init_signal_blocked = svm_apic_init_signal_blocked ,
50345037
0 commit comments