Skip to contentSkip to conversation

Revert "SVM: move guest past HLT"

RFC PATCH In review Vitaly Kuznetsov 2 participants 2 messages Jun 23, 2020 – Jun 24, 2020 KVM

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 Revert "SVM: move guest past HLT"

'nmi_hlt' test returns somewhat weird result:

...
PASS: direct NMI + hlt
PASS: NMI intercept while running guest
PASS: intercepted NMI + hlt
PASS: nmi_hlt
SUMMARY: 4 tests, 1 unexpected failures

Trying to investigate where the failure is coming from I was tweaking the code around and with tiny meaningless changes I was able to observe
#PF, #GP, #UD and other 'interesting' results. Compiler optimization
flags also change the outcome so there's obviously a corruption somewhere. Adding a meaningless 'nop' to the second 'asm volatile ("hlt");' in nmi_hlt_test() saves the day so it seems we erroneously advance RIP twice, the advancement in nmi_hlt_finished() is not needed.

The outcome, however, contradicts with the commit message in 7e7aa86f74 ("SVM: move guest past HLT"). With that commit reverted, all tests seem to pass but I'm not sure what issue the commit was trying to fix, thus RFC.

This reverts commit 7e7aa86f7418a8343de46583977f631e55fd02ed.

---
 x86/svm_tests.c | 8 --------
 1 file changed, 8 deletions(-)
x86/svm_tests.c +0 -8
index c1abd55646f2..977ead5235b8 100644
@@ -1362,11 +1362,6 @@ static bool interrupt_finished(struct svm_test *test)
             return true;
         }
 
-        /* The guest is not woken up from HLT and RIP still points to it.  */
-        if (get_test_stage(test) == 3) {
-            vmcb->save.rip++;
-        }
-
         irq_enable();
         asm volatile ("nop");
         irq_disable();
@@ -1553,9 +1548,6 @@ static bool nmi_hlt_finished(struct svm_test *test)
             return true;
         }
 
-        /* The guest is not woken up from HLT and RIP still points to it.  */
-        vmcb->save.rip++;
-
         report(true, "NMI intercept while running guest");
         break;
 
Signature · 1 line
2.25.4
maintainer
#1 lore raw
Quoted 17 lines · Vitaly Kuznetsov

'nmi_hlt' test returns somewhat weird result:

...
PASS: direct NMI + hlt
PASS: NMI intercept while running guest
PASS: intercepted NMI + hlt
PASS: nmi_hlt
SUMMARY: 4 tests, 1 unexpected failures

Trying to investigate where the failure is coming from I was tweaking the code around and with tiny meaningless changes I was able to observe
#PF, #GP, #UD and other 'interesting' results. Compiler optimization
flags also change the outcome so there's obviously a corruption somewhere. Adding a meaningless 'nop' to the second 'asm volatile ("hlt");' in nmi_hlt_test() saves the day so it seems we erroneously advance RIP twice, the advancement in nmi_hlt_finished() is not needed.

Quoted 6 lines

The outcome, however, contradicts with the commit message in 7e7aa86f74 ("SVM: move guest past HLT"). With that commit reverted, all tests seem to pass but I'm not sure what issue the commit was trying to fix, thus RFC.

This reverts commit 7e7aa86f7418a8343de46583977f631e55fd02ed.

Hmm it's possible that the commit was working around something bad in nested SVM in the middle of the development. I cannot see the unexpected failure, but reverting the patch does not seem to have any ill effect. I pushed the patch, thanks.

Paolo