mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
synced 2025-08-30 21:52:21 +00:00

Extract KVM's open-coded calls to do writeback caches on multiple CPUs to common library helpers for both WBINVD and WBNOINVD (KVM will use both). Put the onus on the caller to check for a non-empty mask to simplify the SMP=n implementation, e.g. so that it doesn't need to check that the one and only CPU in the system is present in the mask. [sean: move to lib, add SMP=n helpers, clarify usage] Signed-off-by: Zheyun Shen <szy0127@sjtu.edu.cn> Signed-off-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com> Acked-by: Kai Huang <kai.huang@intel.com> Link: https://lore.kernel.org/r/20250128015345.7929-2-szy0127@sjtu.edu.cn Link: https://lore.kernel.org/20250522233733.3176144-5-seanjc@google.com
45 lines
823 B
C
45 lines
823 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
#include <asm/paravirt.h>
|
|
#include <linux/smp.h>
|
|
#include <linux/export.h>
|
|
|
|
static void __wbinvd(void *dummy)
|
|
{
|
|
wbinvd();
|
|
}
|
|
|
|
void wbinvd_on_cpu(int cpu)
|
|
{
|
|
smp_call_function_single(cpu, __wbinvd, NULL, 1);
|
|
}
|
|
EXPORT_SYMBOL(wbinvd_on_cpu);
|
|
|
|
void wbinvd_on_all_cpus(void)
|
|
{
|
|
on_each_cpu(__wbinvd, NULL, 1);
|
|
}
|
|
EXPORT_SYMBOL(wbinvd_on_all_cpus);
|
|
|
|
void wbinvd_on_cpus_mask(struct cpumask *cpus)
|
|
{
|
|
on_each_cpu_mask(cpus, __wbinvd, NULL, 1);
|
|
}
|
|
EXPORT_SYMBOL_GPL(wbinvd_on_cpus_mask);
|
|
|
|
static void __wbnoinvd(void *dummy)
|
|
{
|
|
wbnoinvd();
|
|
}
|
|
|
|
void wbnoinvd_on_all_cpus(void)
|
|
{
|
|
on_each_cpu(__wbnoinvd, NULL, 1);
|
|
}
|
|
EXPORT_SYMBOL_GPL(wbnoinvd_on_all_cpus);
|
|
|
|
void wbnoinvd_on_cpus_mask(struct cpumask *cpus)
|
|
{
|
|
on_each_cpu_mask(cpus, __wbnoinvd, NULL, 1);
|
|
}
|
|
EXPORT_SYMBOL_GPL(wbnoinvd_on_cpus_mask);
|