xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/time: fix scale_delta() inline assembly
@ 2012-11-26 15:23 Jan Beulich
  2012-11-26 16:10 ` Keir Fraser
  2012-11-26 16:31 ` Ian Campbell
  0 siblings, 2 replies; 14+ messages in thread
From: Jan Beulich @ 2012-11-26 15:23 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 1040 bytes --]

The way it was coded, it clobbered %rdx without telling the compiler.
This generally didn't cause any problems except when there are two back
to back invocations (as in plt_overflow()), as in that case the
compiler may validly assume that it can re-use for the second instance
the value loaded into %rdx before the first one.

Once at it, also properly relax the second operand of "mul" (there's no
need for it to be in %rdx, or a register at all), and switch away from
using explicit register names in the instruction operands.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -127,8 +127,9 @@ static inline u64 scale_delta(u64 delta,
         delta <<= scale->shift;
 
     asm (
-        "mul %%rdx ; shrd $32,%%rdx,%%rax"
-        : "=a" (product) : "0" (delta), "d" ((u64)scale->mul_frac) );
+        "mul %2 ; shrd $32,%1,%0"
+        : "=a" (product), "=d" (delta)
+        : "rm" (delta), "0" ((u64)scale->mul_frac) );
 
     return product;
 }




[-- Attachment #2: x86-time-scale-asm.patch --]
[-- Type: text/plain, Size: 1081 bytes --]

x86/time: fix scale_delta() inline assembly

The way it was coded, it clobbered %rdx without telling the compiler.
This generally didn't cause any problems except when there are two back
to back invocations (as in plt_overflow()), as in that case the
compiler may validly assume that it can re-use for the second instance
the value loaded into %rdx before the first one.

Once at it, also properly relax the second operand of "mul" (there's no
need for it to be in %rdx, or a register at all), and switch away from
using explicit register names in the instruction operands.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -127,8 +127,9 @@ static inline u64 scale_delta(u64 delta,
         delta <<= scale->shift;
 
     asm (
-        "mul %%rdx ; shrd $32,%%rdx,%%rax"
-        : "=a" (product) : "0" (delta), "d" ((u64)scale->mul_frac) );
+        "mul %2 ; shrd $32,%1,%0"
+        : "=a" (product), "=d" (delta)
+        : "rm" (delta), "0" ((u64)scale->mul_frac) );
 
     return product;
 }

[-- Attachment #3: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2012-11-26 19:23 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-26 15:23 [PATCH] x86/time: fix scale_delta() inline assembly Jan Beulich
2012-11-26 16:10 ` Keir Fraser
2012-11-26 16:43   ` Dan Magenheimer
2012-11-26 16:51     ` Sylvain Munaut
2012-11-26 16:59       ` Mats Petersson
2012-11-26 17:03       ` Jan Beulich
2012-11-26 17:12       ` Dan Magenheimer
2012-11-26 19:23         ` Keir Fraser
2012-11-26 16:53     ` Jan Beulich
2012-11-26 16:31 ` Ian Campbell
2012-11-26 16:43   ` Jan Beulich
2012-11-26 17:12     ` Ian Campbell
2012-11-26 19:22       ` Keir Fraser
2012-11-26 16:50   ` Mats Petersson

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).