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

From: Kirill A. Shutemov
Date: Fri Jan 10 2025 - 03:24:43 EST


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.

--
Kiryl Shutsemau / Kirill A. Shutemov