Re: [PATCH v2 2/2] KVM: SEV: Prefer WBNOINVD over WBINVD for cache maintenance efficiency

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

 



On Fri, Jan 10, 2025 at 12:23 AM Kirill A. Shutemov
<kirill.shutemov@xxxxxxxxxxxxxxx> wrote:
>
> On Thu, Jan 09, 2025 at 10:55:33PM +0000, Kevin Loughlin wrote:
> > @@ -710,6 +711,14 @@ static void sev_clflush_pages(struct page *pages[], unsigned long npages)
> >       }
> >  }
> >
> > +static void sev_wb_on_all_cpus(void)
> > +{
> > +     if (boot_cpu_has(X86_FEATURE_WBNOINVD))
> > +             wbnoinvd_on_all_cpus();
> > +     else
> > +             wbinvd_on_all_cpus();
>
> I think the X86_FEATURE_WBNOINVD check should be inside wbnoinvd().
> wbnoinvd() should fallback to WBINVD if the instruction is not supported
> rather than trigger #UD.

I debated this as well and am open to doing it that way. One argument
against silently falling back to WBINVD within wbnoinvd() (in general,
not referring to this specific case) is that frequent WBINVD can cause
soft lockups, whereas WBNOINVD is much less likely to do so. As such,
there are potentially use cases where falling back to WBINVD would be
undesirable (and would potentially be non-obvious behavior to the
programmer calling wbnoinvd()), hence why I left the decision outside
wbnoinvd().

That said, open to either way, especially since that "potential" use
case doesn't apply here; just lemme know if you still have a strong
preference for doing the check within wbnoinvd().





[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