public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
From: Jes Sorensen <jes@sgi.com>
To: linux-ia64@vger.kernel.org
Subject: Re: [patch] fix zero extending for mmio ld1/2/4 emulation in KVM
Date: Tue, 20 May 2008 11:13:50 +0000	[thread overview]
Message-ID: <4832B26E.2040907@sgi.com> (raw)
In-Reply-To: <4832A0A6.8050800@sgi.com>

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

Matthew Chapman wrote:
> Jes,
> 
> Glad you tracked it down.  Can I suggest rather than using memcpy, a
> more efficient way might be something like...
> 
> #define ZERO_EXTEND(x,bits) ((x) & (~0UL >> (64-(bits))))
> 
> *dest = ZERO_EXTEND(p->u.ioreq.data, 8*s);

Much nicer indeed!

Here's a pretty version - Tony will you apply this one instead.

Cheers,
Jes



[-- Attachment #2: mmio-zero-extend.diff --]
[-- Type: text/plain, Size: 820 bytes --]

Only copy in the data actually requested by the instruction emulation
and zero pad the destination register first. This avoids the problem
where emulated mmio access got garbled data from ld2.acq instructions
in the vga console driver.

Signed-off-by: Jes Sorensen <jes@sgi.com>

---
 arch/ia64/kvm/mmio.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: linux-2.6.git/arch/ia64/kvm/mmio.c
===================================================================
--- linux-2.6.git.orig/arch/ia64/kvm/mmio.c
+++ linux-2.6.git/arch/ia64/kvm/mmio.c
@@ -159,7 +159,8 @@
 
 	if (p->u.ioreq.state == STATE_IORESP_READY) {
 		if (dir == IOREQ_READ)
-			*dest = p->u.ioreq.data;
+			/* it's necessary to ensure zero extending */
+			*dest = p->u.ioreq.data & (~0UL >> (64-(s*8)));
 	} else
 		panic_vm(vcpu);
 out:

  parent reply	other threads:[~2008-05-20 11:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-20  9:57 [patch] fix zero extending for mmio ld1/2/4 emulation in KVM Jes Sorensen
2008-05-20 10:33 ` Matthew Chapman
2008-05-20 11:13 ` Jes Sorensen [this message]
2008-05-21  9:46 ` Zhang, Xiantao
2008-05-21 10:05 ` Avi Kivity
2008-05-22  3:45 ` Isaku Yamahata
2008-05-22  8:08 ` Jes Sorensen
2008-05-22 15:16 ` Xu, Anthony
2008-05-22 15:23 ` Jes Sorensen

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=4832B26E.2040907@sgi.com \
    --to=jes@sgi.com \
    --cc=linux-ia64@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox