Subject: [PATCH 4/4] kvmppc: convert wrteei to wrtee as kvm guest optimization

From: [email-masked]
Date: Tue, 19 Aug 2008 12:36:44 +0200

From: Christian Ehrhardt <[email-masked]>

Dependent on the already existing CONFIG_KVM_GUEST config option this patch
changes wrteei to wrtee allowing the hypervisor to rewrite those to nontrapping
instructions. Maybe we should split the kvm guest otpimizations in two parts
one for the overhead free optimizations and on for the rest that might add
some complexity for non virtualized execution (like this one).

Signed-off-by: Christian Ehrhardt <[email-masked]>
---

[diffstat]
 hw_irq.h |   12 ++++++++++++
 1 file changed, 12 insertions(+)

[diff]
diff --git a/include/asm-powerpc/hw_irq.h b/include/asm-powerpc/hw_irq.h
--- a/include/asm-powerpc/hw_irq.h
+++ b/include/asm-powerpc/hw_irq.h
@@ -72,7 +72,11 @@
 static inline void local_irq_disable(void)
 {
 #ifdef CONFIG_BOOKE
+#ifdef CONFIG_KVM_GUEST
+	__asm__ __volatile__("wrtee %0": : "r"(0) :"memory");
+#else
 	__asm__ __volatile__("wrteei 0": : :"memory");
+#endif
 #else
 	unsigned long msr;
 	__asm__ __volatile__("": : :"memory");
@@ -84,7 +88,11 @@
 static inline void local_irq_enable(void)
 {
 #ifdef CONFIG_BOOKE
+#ifdef CONFIG_KVM_GUEST
+	__asm__ __volatile__("wrtee %0": : "r"(MSR_EE) :"memory");
+#else
 	__asm__ __volatile__("wrteei 1": : :"memory");
+#endif
 #else
 	unsigned long msr;
 	__asm__ __volatile__("": : :"memory");
@@ -99,7 +107,11 @@
 	msr = mfmsr();
 	*flags = msr;
 #ifdef CONFIG_BOOKE
+#ifdef CONFIG_KVM_GUEST
+	__asm__ __volatile__("wrtee %0": : "r"(0) :"memory");
+#else
 	__asm__ __volatile__("wrteei 0": : :"memory");
+#endif
 #else
 	SET_MSR_EE(msr & ~MSR_EE);
 #endif