SVM: do not generate "external interrupt exit" if other exit is pending
PATCH 1/1 SVM: do not generate "external interrupt exit" if other exit is pending
Nested SVM checks for external interrupt after injecting nested exception. In case there is external interrupt pending the code generates "external interrupt exit" and overwrites previous exit info. If previously injected exception already generated exit it will be lost.
arch/x86/kvm/svm.c +3 -0
@@ -1707,6 +1707,9 @@ static inline bool nested_svm_intr(struct vcpu_svm *svm)if (!(svm->vcpu.arch.hflags &HF_HIF_MASK ))return false; +if (svm->nested.exit_required) +return false; + svm->vmcb->control.exit_code =SVM_EXIT_INTR ; svm->vmcb->control.exit_info_1 =0 ; svm->vmcb->control.exit_info_2 =0 ;
--
Gleb.
Quoted 4 lines · Gleb Natapov
Nested SVM checks for external interrupt after injecting nested exception. In case there is external interrupt pending the code generates "external interrupt exit" and overwrites previous exit info. If previously injected exception already generated exit it will be lost.
Right. Have you seen specific mismehavior due to this problem? I am just curious how you found this :-)
And another question, can you put the reason for this "if(...) return" into an comment before the statement? The whole svm-emulation thing is complicated enough so that we should document it well in the code :-)
Joerg
Quoted 18 lines
Signed-off-by Gleb Natapov <[email protected]>arch/x86/kvm/svm.c +3
-1@@ -1707,6 +1707,9 @@ static inline bool nested_svm_intr(struct vcpu_svm *svm)if (!(svm->vcpu.arch.hflags &HF_HIF_MASK ))return false; +if (svm->nested.exit_required) +return false; + svm->vmcb->control.exit_code =SVM_EXIT_INTR ; svm->vmcb->control.exit_info_1 =0 ; svm->vmcb->control.exit_info_2 =0 ; --Gleb.
Quoted 8 lines · Joerg Roedel
Quoted 4 lines · Gleb Natapov
Nested SVM checks for external interrupt after injecting nested exception. In case there is external interrupt pending the code generates "external interrupt exit" and overwrites previous exit info. If previously injected exception already generated exit it will be lost.
Right. Have you seen specific mismehavior due to this problem? I am just curious how you found this :-)
Yes. Trying to make async page fault work with nested svm :) It was hard to fix with reproducible test case. I am not dreaming to fix it just by code review.
Quoted 4 lines
And another question, can you put the reason for this "if(...) return" into an comment before the statement? The whole svm-emulation thing is complicated enough so that we should document it well in the code :-)
Complicated is understatement. Will add a comment.
Quoted 12 lines
Joerg
Quoted 10 lines
Signed-off-by Gleb Natapov <[email protected]>arch/x86/kvm/svm.c +0
-0@@ -1707,6 +1707,9 @@ static inline bool nested_svm_intr(struct vcpu_svm *svm)if (!(svm->vcpu.arch.hflags &HF_HIF_MASK ))return false;
Quoted 8 lines
Quoted 8 lines
arch/x86/kvm/svm.c +3
-1+if (svm->nested.exit_required) +return false; + svm->vmcb->control.exit_code =SVM_EXIT_INTR ; svm->vmcb->control.exit_info_1 =0 ; svm->vmcb->control.exit_info_2 =0 ; --Gleb.
--
Gleb.
Quoted 7 lines · Gleb Natapov
Quoted 6 lines · Joerg Roedel
Quoted 4 lines · Gleb Natapov
Nested SVM checks for external interrupt after injecting nested exception. In case there is external interrupt pending the code generates "external interrupt exit" and overwrites previous exit info. If previously injected exception already generated exit it will be lost.
Quoted 5 lines
Quoted 2 lines
Right. Have you seen specific mismehavior due to this problem? I am just curious how you found this :-)
Yes. Trying to make async page fault work with nested svm :) It was hard to fix with reproducible test case. I am not dreaming to fix it just by code review.
Interesting. Hope this was the only problem and you have it working now?
Quoted 5 lines
Quoted 4 lines
And another question, can you put the reason for this "if(...) return" into an comment before the statement? The whole svm-emulation thing is complicated enough so that we should document it well in the code :-)
Complicated is understatement. Will add a comment.
Thanks, the most complicated thing is to get all the interrupt- exception- and event-reinjection thing right. You just fixed another bug there, thanks again :)
Joerg
Quoted 8 lines · Joerg Roedel
Quoted 7 lines · Gleb Natapov
Quoted 6 lines · Joerg Roedel
Quoted 4 lines · Gleb Natapov
Nested SVM checks for external interrupt after injecting nested exception. In case there is external interrupt pending the code generates "external interrupt exit" and overwrites previous exit info. If previously injected exception already generated exit it will be lost.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Right. Have you seen specific mismehavior due to this problem? I am just curious how you found this :-)
Yes. Trying to make async page fault work with nested svm :) It was hard to fix with reproducible test case. I am not dreaming to fix it just by code review.
Interesting. Hope this was the only problem and you have it working now?
Yes. Now my test case works.
--
Gleb.