Skip to contentSkip to conversation

Fix register corruption in pvclock_scale_delta

PATCH In review Zachary Amsden 4 participants 6 messages Jun 16, 2011 – Jun 22, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix register corruption in pvclock_scale_delta

The 128-bit multiply in pvclock.h was missing an output constraint for EDX which caused a register corruption to appear. Thanks to Ulrich for diagnosing the EDX corruption and Avi for providing this fix (which now I am sending back to you Avi..)

Zach

Quoted 1 line

From Avi and Ulrich, fix constraints for 128-bit multiply

arch/x86/include/asm/pvclock.h +7 -2
index 31d84ac..a518c0a 100644
@@ -22,6 +22,8 @@ static inline u64 pvclock_scale_delta(u64 delta, u32 mul_frac, int shift)
 	u64 product;
 #ifdef __i386__
 	u32 tmp1, tmp2;
+#else
+	ulong tmp;
 #endif
 
 	if (shift < 0)
@@ -42,8 +44,11 @@ static inline u64 pvclock_scale_delta(u64 delta, u32 mul_frac, int shift)
 		: "a" ((u32)delta), "1" ((u32)(delta >> 32)), "2" (mul_frac) );
 #elif defined(__x86_64__)
 	__asm__ (
-		"mul %%rdx ; shrd $32,%%rdx,%%rax"
-		: "=a" (product) : "0" (delta), "d" ((u64)mul_frac) );
+		"mul %[mul_frac] ; shrd $32, %[hi], %[lo]"
+		: [lo]"=a"(product),
+		  [hi]"=d"(tmp)
+		: "0"(delta),
+		  [mul_frac]"rm"((u64)mul_frac));
 #else
 #error implement me!
 #endif
#1 lore raw
Quoted 1 line · Zachary Amsden

The 128-bit multiply in pvclock.h was missing an output constraint for EDX which caused a register corruption to appear. Thanks to Ulrich for diagnosing the EDX corruption and Avi for providing this fix (which now I am sending back to you Avi..)

Applied and queued, thanks.

Signature · 1 line
error compiling committee.c: too many arguments to function
#2 lore raw
Quoted 3 lines · Avi Kivity
Quoted 2 lines · Zachary Amsden

The 128-bit multiply in pvclock.h was missing an output constraint for EDX which caused a register corruption to appear.

Was there any particular symptom associated with corruption at that particular point or just general badness?

Quoted 5 lines

Thanks to Ulrich

Quoted 2 lines

for diagnosing the EDX corruption and Avi for providing this fix (which now I am sending back to you Avi..)

Applied and queued, thanks.

Seems like a stable candidate also?

Ian.

#3 lore raw
Quoted 8 lines · Ian Campbell
Quoted 3 lines · Avi Kivity
Quoted 2 lines · Zachary Amsden

The 128-bit multiply in pvclock.h was missing an output constraint for EDX which caused a register corruption to appear.

Was there any particular symptom associated with corruption at that particular point or just general badness?

Quoted 7 lines
Quoted 5 lines

Thanks to Ulrich

Quoted 2 lines

for diagnosing the EDX corruption and Avi for providing this fix (which now I am sending back to you Avi..)

Applied and queued, thanks.

Seems like a stable candidate also?

Yes. I see it's merged; Marcelo, can you backport it?

Signature · 1 line
error compiling committee.c: too many arguments to function
#4 lore raw
In reply to Ian Campbell
Quoted 8 lines · Ian Campbell
Quoted 3 lines · Avi Kivity
Quoted 2 lines · Zachary Amsden

The 128-bit multiply in pvclock.h was missing an output constraint for EDX which caused a register corruption to appear.

Was there any particular symptom associated with corruption at that particular point or just general badness?

Time went backwards and forwards as vcpus were migrated across cpus.

The problem was in the host, not the guest, so Xen should not be affected.

Signature · 1 line
error compiling committee.c: too many arguments to function
#5 lore raw
Quoted 11 lines · Avi Kivity
Quoted 8 lines · Ian Campbell
Quoted 3 lines · Avi Kivity
Quoted 2 lines · Zachary Amsden

The 128-bit multiply in pvclock.h was missing an output constraint for EDX which caused a register corruption to appear.

Was there any particular symptom associated with corruption at that particular point or just general badness?

Time went backwards and forwards as vcpus were migrated across cpus.

Oops!

Quoted 1 line

The problem was in the host, not the guest, so Xen should not be affected.

Good to know, thanks!

Ian.