SVM: move guest past HLT
Paolo Bonzini
maintainerPATCH 1/1 SVM: move guest past HLT
On AMD, the guest is not woken up from HLT by the interrupt or NMI vmexits. Therefore we have to fix up the RIP manually.
--- x86/svm_tests.c | 8 ++++++++ 1 file changed, 8 insertions(+)
x86/svm_tests.c +8 -0
@@ -1316,6 +1316,11 @@ static bool interrupt_finished(struct svm_test *test)return true; } +/* The guest is not woken up from HLT, unlike Intel. Fix that up. */ +if (get_test_stage (test) ==3 ) { + vmcb->save.rip++; + } +irq_enable (); asmvolatile ("nop" );irq_disable ();
@@ -1501,6 +1506,9 @@ static bool nmi_hlt_finished(struct svm_test *test)return true; } +/* The guest is not woken up from HLT, unlike Intel. Fix that up. */ + vmcb->save.rip++; +report (true,"NMI intercept while running guest" );break ;
Signature · 1 line
2.18.2
Quoted 13 lines · Paolo Bonzini
On AMD, the guest is not woken up from HLT by the interrupt or NMI vmexits. Therefore we have to fix up the RIP manually.
Signed-off-by Paolo Bonzini <[email protected]>--- x86/svm_tests.c | 8 ++++++++ 1 file changed, 8 insertions(+)x86/svm_tests.c +0
-0
x86/svm_tests.c static bool interrupt_finished(struct svm_test *test) · line 1319
Quoted 4 lines
x86/svm_tests.c +1
-0@@ -1316,6 +1316,11 @@ static bool interrupt_finished(struct svm_test *test)return true; } +/* The guest is not woken up from HLT, unlike Intel. Fix that up. */
The comment about "unlike Intel" isn't correct, or at least it's not always correct. Intercept NMIs/interrupts don't affect vmcs.GUEST_ACTIVITY, i.e. if the guest was in HLT before the exit then that's what will be recorded in the VMCS.
Quoted 20 lines
x86/svm_tests.c +7
-0+if (get_test_stage (test) ==3 ) { + vmcb->save.rip++; + } +irq_enable (); asmvolatile ("nop" );irq_disable ();@@ -1501,6 +1506,9 @@ static bool nmi_hlt_finished(struct svm_test *test)return true; } +/* The guest is not woken up from HLT, unlike Intel. Fix that up. */ + vmcb->save.rip++; +report (true,"NMI intercept while running guest" );break ;Signature · 1 line
2.18.2
Paolo Bonzini
maintainerQuoted 8 lines · Sean Christopherson
Quoted 2 lines
+ /* The guest is not woken up from HLT, unlike Intel. Fix that up. */
The comment about "unlike Intel" isn't correct, or at least it's not always correct. Intercept NMIs/interrupts don't affect vmcs.GUEST_ACTIVITY, i.e. if the guest was in HLT before the exit then that's what will be recorded in the VMCS.
Ok, I'll change it to "The guest is not woken up from HLT and RIP still points to it".
On Intel indeed it is not woken up either but vmx_tests.c has
if (vmx_get_test_stage() >= 2)
vmcs_write(GUEST_ACTV_STATE, ACTV_ACTIVE);Then it's not surprising that, when I fixed a bunch of nested AMD things to behave the same as in vmx/vmx.c, SVM broke and needed this patch.
Paolo