All of lore.kernel.org
 help / color / mirror / Atom feed
From: Duncan Sands <baldrick@free.fr>
To: Zachary Amsden <zamsden@redhat.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH x86 kvm] Fix register corruption in pvclock_scale_delta
Date: Tue, 30 Aug 2011 10:58:22 +0200	[thread overview]
Message-ID: <4E5CA62E.8060304@free.fr> (raw)

Hi Zachary, this patch can cause a compile failure if the compiler chooses to
use a memory location for mul_frac rather than a register (as allowed by the
"m" in the constraints):

   pvclock.s:229: Error: no instruction mnemonic suffix given and no register 
operands; can't size instruction

In this example the assembler is:

         #APP
         mul -48(%rbp) ; shrd $32, %rdx, %rax
         #NO_APP

A simple solution is to use mulq, as in the following patch:

Signed-off-by: Duncan Sands <baldrick@free.fr>

--- a/arch/x86/include/asm/pvclock.h
+++ b/arch/x86/include/asm/pvclock.h
@@ -44,7 +44,7 @@ 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 %[mul_frac] ; shrd $32, %[hi], %[lo]"
+               "mulq %[mul_frac] ; shrd $32, %[hi], %[lo]"
                 : [lo]"=a"(product),
                   [hi]"=d"(tmp)
                 : "0"(delta),

             reply	other threads:[~2011-08-30  9:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-30  8:58 Duncan Sands [this message]
2011-08-30 11:39 ` [PATCH x86 kvm] Fix register corruption in pvclock_scale_delta Avi Kivity
  -- strict thread matches above, loose matches on Subject: below --
2011-06-16  3:50 Zachary Amsden
2011-06-19 12:44 ` Avi Kivity
2011-06-22  9:35   ` Ian Campbell
2011-06-22  9:39     ` Avi Kivity
2011-06-22  9:40     ` Avi Kivity
2011-06-22  9:52       ` Ian Campbell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E5CA62E.8060304@free.fr \
    --to=baldrick@free.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zamsden@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.