Re: [PATCH v2 08/12] KVM: SVM: Update AVIC settings when changing APIC mode

From: Maxim Levitsky
Date: Wed May 04 2022 - 07:49:52 EST


On Wed, 2022-05-04 at 14:46 +0300, Maxim Levitsky wrote:
> On Tue, 2022-05-03 at 20:04 +0700, Suravee Suthikulpanit wrote:
> > Maxim,
> >
> > On 5/3/22 12:13 AM, Maxim Levitsky wrote:
> > > > In the kvm/queue branch, I found a regression on nested SVM guest, where L2 guest cannot
> > > > launch. The bad commit is:
> > > >
> > > > commit a4cfff3f0f8c07f1f7873a82bdeb3995807dac8c (bisect)
> > > > Merge: 42dcbe7d8bac 8d5678a76689
> > > > Author: Paolo Bonzini<pbonzini@xxxxxxxxxx>
> > > > Date: Fri Apr 8 12:43:40 2022 -0400
> > > >
> > > > Merge branch 'kvm-older-features' into HEAD
> > > >
> > > > Merge branch for features that did not make it into 5.18:
> > > >
> > > > * New ioctls to get/set TSC frequency for a whole VM
> > > >
> > > > * Allow userspace to opt out of hypercall patching
> > > >
> > > > Nested virtualization improvements for AMD:
> > > >
> > > > * Support for "nested nested" optimizations (nested vVMLOAD/VMSAVE,
> > > > nested vGIF)
> > > >
> > > > * Allow AVIC to co-exist with a nested guest running
> > > >
> > > > * Fixes for LBR virtualizations when a nested guest is running,
> > > > and nested LBR virtualization support
> > > >
> > > > * PAUSE filtering for nested hypervisors
> > > >
> > > > Guest support:
> > > >
> > > > * Decoupling of vcpu_is_preempted from PV spinlocks
> > > >
> > > > Signed-off-by: Paolo Bonzini<pbonzini@xxxxxxxxxx>
> > > >
> > > > I am still working on the bisect into the merge commits.
> > > >
> > > > Regards,
> > > > Suravee
> > > >
> > > What happens when the guest can't launch? It sure works for me for kvm/queue
> > > from yesterday.
> > >
> > > I'll test again tomorrow.
> >
> > I have bisected it to this commit:
> >
> > commit 74fd41ed16fd71725e69e2cb90b755505326c2e6
> > Author: Maxim Levitsky <mlevitsk@xxxxxxxxxx>
> > Date: Tue Mar 22 19:40:47 2022 +0200
> >
> > KVM: x86: nSVM: support PAUSE filtering when L0 doesn't intercept PAUSE
> >
> > Expose the pause filtering and threshold in the guest CPUID
> > and support PAUSE filtering when possible:
> >
> > - If the L0 doesn't intercept PAUSE (cpu_pm=on), then allow L1 to
> > have full control over PAUSE filtering.
> >
> > - if the L1 doesn't intercept PAUSE, use host values and update
> > the adaptive count/threshold even when running nested.
> >
> > - Otherwise always exit to L1; it is not really possible to merge
> > the fields correctly. It is expected that in this case, userspace
> > will not enable this feature in the guest CPUID, to avoid having the
> > guest update both fields pointlessly.
> >
> > Signed-off-by: Maxim Levitsky <mlevitsk@xxxxxxxxxx>
> > Message-Id: <20220322174050.241850-4-mlevitsk@xxxxxxxxxx>
> > Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>
> >
> > I can revert this one or specify pause_filter_count=0 pause_filter_thresh=0,
> > and then I can boot the L2 guest.
> >
> > Regards,
> > Suravee
> >
>
> This is really wierd.
>
> Could you share the qemu command line for L1 and L2 guest, and as much as possible
> info on what happens when you boot L2? I tested latest kvm/queue and I don't see
> any issues with booting nested guest.
>
> Which hardware you test on? I test on Zen2 (3970X) mostly.
>
> How many vCPUs L2 has? Could you do a kvm trace of the L2, from L1,
> to see what it does prior to hang?


Also assuming that you boot the L2 with -cpu host, could you not expose these two
features to it?

-cpu host,pause-filter=off,pfthreshold=off

Best regards,
Maxim Levitsky


>
>
> Best regards,
> Maxim Levitsky
>
>