Hypercalls can modify arbitrary regions of memory. Make sure to indicate this
in the clobber list. This fixes a hang when using KVM_GUEST kernel built with
GCC 4.3.0.
This was originally spotted and analyzed by Marcelo.
Since v1, I've also added a "m" constraint for the inputs to the hypercall.
This was suggested by Christian since it's not entirely clear whether a memory
clobber will force the data to be in memory before the asm statement. In the
very least, it helps to be more conservative.
Signed-off-by: Anthony Liguori <[EMAIL PROTECTED]>
diff --git a/include/asm-x86/kvm_para.h b/include/asm-x86/kvm_para.h
index bfd9900..a621f10 100644
--- a/include/asm-x86/kvm_para.h
+++ b/include/asm-x86/kvm_para.h
@@ -71,7 +71,8 @@ static inline long kvm_hypercall0(unsigned int nr)
long ret;
asm volatile(KVM_HYPERCALL
: "=a"(ret)
- : "a"(nr));
+ : "a"(nr)
+ : "memory");
return ret;
}
@@ -80,7 +81,9 @@ static inline long kvm_hypercall1(unsigned int nr, unsigned
long p1)
long ret;
asm volatile(KVM_HYPERCALL
: "=a"(ret)
- : "a"(nr), "b"(p1));
+ : "a"(nr), "b"(p1),
+ "m"(*(char *)p1)
+ : "memory");
return ret;
}
@@ -90,7 +93,9 @@ static inline long kvm_hypercall2(unsigned int nr, unsigned
long p1,
long ret;
asm volatile(KVM_HYPERCALL
: "=a"(ret)
- : "a"(nr), "b"(p1), "c"(p2));
+ : "a"(nr), "b"(p1), "c"(p2),
+ "m"(*(char *)p1), "m"(*(char *)p2)
+ : "memory");
return ret;
}
@@ -100,7 +105,9 @@ static inline long kvm_hypercall3(unsigned int nr, unsigned
long p1,
long ret;
asm volatile(KVM_HYPERCALL
: "=a"(ret)
- : "a"(nr), "b"(p1), "c"(p2), "d"(p3));
+ : "a"(nr), "b"(p1), "c"(p2), "d"(p3),
+ "m"(*(char *)p1), "m"(*(char *)p2), "m"(*(char *)p3)
+ : "memory");
return ret;
}
@@ -111,7 +118,10 @@ static inline long kvm_hypercall4(unsigned int nr,
unsigned long p1,
long ret;
asm volatile(KVM_HYPERCALL
: "=a"(ret)
- : "a"(nr), "b"(p1), "c"(p2), "d"(p3), "S"(p4));
+ : "a"(nr), "b"(p1), "c"(p2), "d"(p3), "S"(p4),
+ "m"(*(char *)p1), "m"(*(char *)p2), "m"(*(char *)p3),
+ "m"(*(char *)p4)
+ : "memory");
return ret;
}
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html