* [PATCH 1/2] x86, lib: Add a wbinvd helper for an arbitrary cpu set
@ 2010-11-24 17:44 Borislav Petkov
2010-11-24 17:44 ` [PATCH 2/2] kvm: Use wbinvd library functions Borislav Petkov
2010-11-24 17:49 ` [PATCH 1/2] x86, lib: Add a wbinvd helper for an arbitrary cpu set H. Peter Anvin
0 siblings, 2 replies; 4+ messages in thread
From: Borislav Petkov @ 2010-11-24 17:44 UTC (permalink / raw)
To: hpa, mingo, tglx, Avi Kivity, Marcelo Tosatti
Cc: x86, kvm, linux-kernel, Borislav Petkov
From: Borislav Petkov <borislav.petkov@amd.com>
Add a wbinvd helper for an arbitrary set of CPUs.
Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
---
arch/x86/include/asm/smp.h | 4 +++-
arch/x86/lib/cache-smp.c | 12 ++++++++++++
2 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
index 4c2f63c..f7805f1 100644
--- a/arch/x86/include/asm/smp.h
+++ b/arch/x86/include/asm/smp.h
@@ -141,6 +141,7 @@ void native_cpu_die(unsigned int cpu);
void native_play_dead(void);
void play_dead_common(void);
void wbinvd_on_cpu(int cpu);
+void wbinvd_on_cpus(const struct cpumask *);
int wbinvd_on_all_cpus(void);
void native_send_call_func_ipi(const struct cpumask *mask);
@@ -155,7 +156,8 @@ static inline int num_booting_cpus(void)
return cpumask_weight(cpu_callout_mask);
}
#else /* !CONFIG_SMP */
-#define wbinvd_on_cpu(cpu) wbinvd()
+#define wbinvd_on_cpu(cpu) wbinvd()
+#define wbinvd_on_cpus(mask) wbinvd()
static inline int wbinvd_on_all_cpus(void)
{
wbinvd();
diff --git a/arch/x86/lib/cache-smp.c b/arch/x86/lib/cache-smp.c
index a3c6688..7778d56 100644
--- a/arch/x86/lib/cache-smp.c
+++ b/arch/x86/lib/cache-smp.c
@@ -12,6 +12,18 @@ void wbinvd_on_cpu(int cpu)
}
EXPORT_SYMBOL(wbinvd_on_cpu);
+void wbinvd_on_cpus(const struct cpumask *mask)
+{
+ int this_cpu = get_cpu();
+
+ if (cpumask_test_cpu(this_cpu, mask))
+ wbinvd();
+
+ smp_call_function_many(mask, __wbinvd, NULL, 1);
+ put_cpu();
+}
+EXPORT_SYMBOL(wbinvd_on_cpus);
+
int wbinvd_on_all_cpus(void)
{
return on_each_cpu(__wbinvd, NULL, 1);
--
1.7.3.1.50.g1e633
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] kvm: Use wbinvd library functions
2010-11-24 17:44 [PATCH 1/2] x86, lib: Add a wbinvd helper for an arbitrary cpu set Borislav Petkov
@ 2010-11-24 17:44 ` Borislav Petkov
2010-11-24 17:49 ` [PATCH 1/2] x86, lib: Add a wbinvd helper for an arbitrary cpu set H. Peter Anvin
1 sibling, 0 replies; 4+ messages in thread
From: Borislav Petkov @ 2010-11-24 17:44 UTC (permalink / raw)
To: hpa, mingo, tglx, Avi Kivity, Marcelo Tosatti
Cc: x86, kvm, linux-kernel, Borislav Petkov
From: Borislav Petkov <borislav.petkov@amd.com>
Replace local wbinvd helpers with equivalent x86 library functions.
Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
---
arch/x86/kvm/x86.c | 14 +++-----------
1 files changed, 3 insertions(+), 11 deletions(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index cdac9e5..8063ac0 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -50,6 +50,7 @@
#include <asm/debugreg.h>
#include <asm/msr.h>
+#include <asm/smp.h>
#include <asm/desc.h>
#include <asm/mtrr.h>
#include <asm/mce.h>
@@ -2029,11 +2030,6 @@ out:
return r;
}
-static void wbinvd_ipi(void *garbage)
-{
- wbinvd();
-}
-
static bool need_emulate_wbinvd(struct kvm_vcpu *vcpu)
{
return vcpu->kvm->arch.iommu_domain &&
@@ -2047,8 +2043,7 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
if (kvm_x86_ops->has_wbinvd_exit())
cpumask_set_cpu(cpu, vcpu->arch.wbinvd_dirty_mask);
else if (vcpu->cpu != -1 && vcpu->cpu != cpu)
- smp_call_function_single(vcpu->cpu,
- wbinvd_ipi, NULL, 1);
+ wbinvd_on_cpu(vcpu->cpu);
}
kvm_x86_ops->vcpu_load(vcpu, cpu);
@@ -3978,10 +3973,7 @@ int kvm_emulate_wbinvd(struct kvm_vcpu *vcpu)
return X86EMUL_CONTINUE;
if (kvm_x86_ops->has_wbinvd_exit()) {
- preempt_disable();
- smp_call_function_many(vcpu->arch.wbinvd_dirty_mask,
- wbinvd_ipi, NULL, 1);
- preempt_enable();
+ wbinvd_on_cpus(vcpu->arch.wbinvd_dirty_mask);
cpumask_clear(vcpu->arch.wbinvd_dirty_mask);
}
wbinvd();
--
1.7.3.1.50.g1e633
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] x86, lib: Add a wbinvd helper for an arbitrary cpu set
2010-11-24 17:44 [PATCH 1/2] x86, lib: Add a wbinvd helper for an arbitrary cpu set Borislav Petkov
2010-11-24 17:44 ` [PATCH 2/2] kvm: Use wbinvd library functions Borislav Petkov
@ 2010-11-24 17:49 ` H. Peter Anvin
2010-11-24 18:22 ` Borislav Petkov
1 sibling, 1 reply; 4+ messages in thread
From: H. Peter Anvin @ 2010-11-24 17:49 UTC (permalink / raw)
To: Borislav Petkov
Cc: mingo, tglx, Avi Kivity, Marcelo Tosatti, x86, kvm, linux-kernel,
Borislav Petkov
On 11/24/2010 09:44 AM, Borislav Petkov wrote:
> From: Borislav Petkov <borislav.petkov@amd.com>
>
> Add a wbinvd helper for an arbitrary set of CPUs.
>
Are there any expected users of this other than KVM?
-hpa
--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] x86, lib: Add a wbinvd helper for an arbitrary cpu set
2010-11-24 17:49 ` [PATCH 1/2] x86, lib: Add a wbinvd helper for an arbitrary cpu set H. Peter Anvin
@ 2010-11-24 18:22 ` Borislav Petkov
0 siblings, 0 replies; 4+ messages in thread
From: Borislav Petkov @ 2010-11-24 18:22 UTC (permalink / raw)
To: H. Peter Anvin
Cc: mingo, tglx, Avi Kivity, Marcelo Tosatti, x86, kvm, linux-kernel
On Wed, Nov 24, 2010 at 12:49:06PM -0500, H. Peter Anvin wrote:
> On 11/24/2010 09:44 AM, Borislav Petkov wrote:
> > From: Borislav Petkov <borislav.petkov@amd.com>
> >
> > Add a wbinvd helper for an arbitrary set of CPUs.
> >
>
> Are there any expected users of this other than KVM?
Not that I know of. I had an earlier version for kvm which did
for_each_cpu(cpu, mask)
wbinvd_on_cpu(cpu)
but decided to add wbinvd_on_cpus() for completeness. Let me know what
your preference is.
Thanks.
--
Regards/Gruss,
Boris.
Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach
General Managers: Alberto Bozzo, Andrew Bowd
Registration: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-11-24 18:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-24 17:44 [PATCH 1/2] x86, lib: Add a wbinvd helper for an arbitrary cpu set Borislav Petkov
2010-11-24 17:44 ` [PATCH 2/2] kvm: Use wbinvd library functions Borislav Petkov
2010-11-24 17:49 ` [PATCH 1/2] x86, lib: Add a wbinvd helper for an arbitrary cpu set H. Peter Anvin
2010-11-24 18:22 ` Borislav Petkov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).