@@ -800,23 +800,20 @@ static void kvm_queue_exception_vmexit(struct kvm_vcpu *vcpu, unsigned int vecto
800
800
ex -> payload = payload ;
801
801
}
802
802
803
- static void kvm_multiple_exception (struct kvm_vcpu * vcpu ,
804
- unsigned nr , bool has_error , u32 error_code ,
805
- bool has_payload , unsigned long payload , bool reinject )
803
+ static void kvm_multiple_exception (struct kvm_vcpu * vcpu , unsigned int nr ,
804
+ bool has_error , u32 error_code ,
805
+ bool has_payload , unsigned long payload )
806
806
{
807
807
u32 prev_nr ;
808
808
int class1 , class2 ;
809
809
810
810
kvm_make_request (KVM_REQ_EVENT , vcpu );
811
811
812
812
/*
813
- * If the exception is destined for L2 and isn't being reinjected,
814
- * morph it to a VM-Exit if L1 wants to intercept the exception. A
815
- * previously injected exception is not checked because it was checked
816
- * when it was original queued, and re-checking is incorrect if _L1_
817
- * injected the exception, in which case it's exempt from interception.
813
+ * If the exception is destined for L2, morph it to a VM-Exit if L1
814
+ * wants to intercept the exception.
818
815
*/
819
- if (! reinject && is_guest_mode (vcpu ) &&
816
+ if (is_guest_mode (vcpu ) &&
820
817
kvm_x86_ops .nested_ops -> is_exception_vmexit (vcpu , nr , error_code )) {
821
818
kvm_queue_exception_vmexit (vcpu , nr , has_error , error_code ,
822
819
has_payload , payload );
@@ -825,28 +822,9 @@ static void kvm_multiple_exception(struct kvm_vcpu *vcpu,
825
822
826
823
if (!vcpu -> arch .exception .pending && !vcpu -> arch .exception .injected ) {
827
824
queue :
828
- if (reinject ) {
829
- /*
830
- * On VM-Entry, an exception can be pending if and only
831
- * if event injection was blocked by nested_run_pending.
832
- * In that case, however, vcpu_enter_guest() requests an
833
- * immediate exit, and the guest shouldn't proceed far
834
- * enough to need reinjection.
835
- */
836
- WARN_ON_ONCE (kvm_is_exception_pending (vcpu ));
837
- vcpu -> arch .exception .injected = true;
838
- if (WARN_ON_ONCE (has_payload )) {
839
- /*
840
- * A reinjected event has already
841
- * delivered its payload.
842
- */
843
- has_payload = false;
844
- payload = 0 ;
845
- }
846
- } else {
847
- vcpu -> arch .exception .pending = true;
848
- vcpu -> arch .exception .injected = false;
849
- }
825
+ vcpu -> arch .exception .pending = true;
826
+ vcpu -> arch .exception .injected = false;
827
+
850
828
vcpu -> arch .exception .has_error_code = has_error ;
851
829
vcpu -> arch .exception .vector = nr ;
852
830
vcpu -> arch .exception .error_code = error_code ;
@@ -887,29 +865,52 @@ static void kvm_multiple_exception(struct kvm_vcpu *vcpu,
887
865
888
866
void kvm_queue_exception (struct kvm_vcpu * vcpu , unsigned nr )
889
867
{
890
- kvm_multiple_exception (vcpu , nr , false, 0 , false, 0 , false );
868
+ kvm_multiple_exception (vcpu , nr , false, 0 , false, 0 );
891
869
}
892
870
EXPORT_SYMBOL_GPL (kvm_queue_exception );
893
871
894
- void kvm_requeue_exception (struct kvm_vcpu * vcpu , unsigned nr )
895
- {
896
- kvm_multiple_exception (vcpu , nr , false, 0 , false, 0 , true);
897
- }
898
- EXPORT_SYMBOL_GPL (kvm_requeue_exception );
899
872
900
873
void kvm_queue_exception_p (struct kvm_vcpu * vcpu , unsigned nr ,
901
874
unsigned long payload )
902
875
{
903
- kvm_multiple_exception (vcpu , nr , false, 0 , true, payload , false );
876
+ kvm_multiple_exception (vcpu , nr , false, 0 , true, payload );
904
877
}
905
878
EXPORT_SYMBOL_GPL (kvm_queue_exception_p );
906
879
907
880
static void kvm_queue_exception_e_p (struct kvm_vcpu * vcpu , unsigned nr ,
908
881
u32 error_code , unsigned long payload )
909
882
{
910
- kvm_multiple_exception (vcpu , nr , true, error_code ,
911
- true, payload , false);
883
+ kvm_multiple_exception (vcpu , nr , true, error_code , true, payload );
884
+ }
885
+
886
+ void kvm_requeue_exception (struct kvm_vcpu * vcpu , unsigned int nr ,
887
+ bool has_error_code , u32 error_code )
888
+ {
889
+
890
+ /*
891
+ * On VM-Entry, an exception can be pending if and only if event
892
+ * injection was blocked by nested_run_pending. In that case, however,
893
+ * vcpu_enter_guest() requests an immediate exit, and the guest
894
+ * shouldn't proceed far enough to need reinjection.
895
+ */
896
+ WARN_ON_ONCE (kvm_is_exception_pending (vcpu ));
897
+
898
+ /*
899
+ * Do not check for interception when injecting an event for L2, as the
900
+ * exception was checked for intercept when it was original queued, and
901
+ * re-checking is incorrect if _L1_ injected the exception, in which
902
+ * case it's exempt from interception.
903
+ */
904
+ kvm_make_request (KVM_REQ_EVENT , vcpu );
905
+
906
+ vcpu -> arch .exception .injected = true;
907
+ vcpu -> arch .exception .has_error_code = has_error_code ;
908
+ vcpu -> arch .exception .vector = nr ;
909
+ vcpu -> arch .exception .error_code = error_code ;
910
+ vcpu -> arch .exception .has_payload = false;
911
+ vcpu -> arch .exception .payload = 0 ;
912
912
}
913
+ EXPORT_SYMBOL_GPL (kvm_requeue_exception );
913
914
914
915
int kvm_complete_insn_gp (struct kvm_vcpu * vcpu , int err )
915
916
{
@@ -980,16 +981,10 @@ void kvm_inject_nmi(struct kvm_vcpu *vcpu)
980
981
981
982
void kvm_queue_exception_e (struct kvm_vcpu * vcpu , unsigned nr , u32 error_code )
982
983
{
983
- kvm_multiple_exception (vcpu , nr , true, error_code , false, 0 , false );
984
+ kvm_multiple_exception (vcpu , nr , true, error_code , false, 0 );
984
985
}
985
986
EXPORT_SYMBOL_GPL (kvm_queue_exception_e );
986
987
987
- void kvm_requeue_exception_e (struct kvm_vcpu * vcpu , unsigned nr , u32 error_code )
988
- {
989
- kvm_multiple_exception (vcpu , nr , true, error_code , false, 0 , true);
990
- }
991
- EXPORT_SYMBOL_GPL (kvm_requeue_exception_e );
992
-
993
988
/*
994
989
* Checks if cpl <= required_cpl; if true, return true. Otherwise queue
995
990
* a #GP and return false.
0 commit comments