Re: [kvm-unit-tests PATCH 08/16] svm: add nested shutdown test.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2022-10-20 at 19:06 +0000, Sean Christopherson wrote:
> On Thu, Oct 20, 2022, Maxim Levitsky wrote:
> > On Thu, 2022-10-20 at 18:23 +0300, Maxim Levitsky wrote:
> > > +static void svm_shutdown_intercept_test(void)
> > > +{
> > > +       void* unmapped_address = alloc_vpage();
> > > +
> > > +       /*
> > > +        * Test that shutdown vm exit doesn't crash L0
> > > +        *
> > > +        * Test both native and emulated triple fault
> > > +        * (due to exception merging)
> > > +        */
> > > +
> > > +
> > > +       /*
> > > +        * This will usually cause native SVM_EXIT_SHUTDOWN
> > > +        * (KVM usually doesn't intercept #PF)
> > > +        * */
> > > +       test_set_guest(shutdown_intercept_test_guest);
> > > +       vmcb->save.idtr.base = (u64)unmapped_address;
> > > +       vmcb->control.intercept |= (1ULL << INTERCEPT_SHUTDOWN);
> > > +       svm_vmrun();
> > > +       report (vmcb->control.exit_code == SVM_EXIT_SHUTDOWN, "shutdown (BP->PF->DF->TRIPLE_FAULT) test passed");
> > > +
> > > +       /*
> > > +        * This will usually cause emulated SVM_EXIT_SHUTDOWN
> > > +        * (KVM usually intercepts #UD)
> > > +        */
> > > +       test_set_guest(shutdown_intercept_test_guest2);
> > > +       vmcb_ident(vmcb);
> > > +       vmcb->save.idtr.limit = 0;
> > > +       vmcb->control.intercept |= (1ULL << INTERCEPT_SHUTDOWN);
> > > +       svm_vmrun();
> > > +       report (vmcb->control.exit_code == SVM_EXIT_SHUTDOWN, "shutdown (UD->DF->TRIPLE_FAULT) test passed");
> > > +}
> > > +
> > >  struct svm_test svm_tests[] = {
> > >         { "null", default_supported, default_prepare,
> > >           default_prepare_gif_clear, null_test,
> > > @@ -3382,6 +3432,7 @@ struct svm_test svm_tests[] = {
> > >         TEST(svm_intr_intercept_mix_smi),
> > >         TEST(svm_tsc_scale_test),
> > >         TEST(pause_filter_test),
> > > +       TEST(svm_shutdown_intercept_test),
> > >         { NULL, NULL, NULL, NULL, NULL, NULL, NULL }
> > >  };
> > 
> > Note that on unpatched KVM, this test will cause a kernel panic on the host
> > if run.
> > 
> > I sent a patch today with a fix for this.
> 
> I'm confused.  The KVM patches address a bug where KVM screws up if the SHUTDOWN
> (or INIT) is _not_ intercepted by L1, but the test here does intercept SHUTDOWN.
> Are there more bugs lurking in KVM, or am I missing something?

Yes you don't miss anything - it was a last minute change that I forgot about:

If you let shutdown to not be intercepted, and even if KVM works correclty,
it will still kill qemu, and thus not run other subtests of this test.

The test will still 'pass' silently, something that should be IMHO fixed, the test runner
should check the exit status of qemu or in some other way detect that qemu got shutdown instead
of returning normally.

I decided to make this test in selftests, which also has a bonus of not crashing the host kernel,
since the selftest will come after the fix.

And the above test checks it the other way around which is still a good test IMHO
(I do need to update the commit message though).

Best regards,
	Maxim Levitsky.



> 





[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux