WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] Re: [Xen-staging] [xen-unstable] [HVM] Prevent usb d

To: Keir Fraser <keir@xxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] Re: [Xen-staging] [xen-unstable] [HVM] Prevent usb driver crashes in Windows
From: Alex Williamson <alex.williamson@xxxxxx>
Date: Mon, 18 Jun 2007 15:52:52 -0600
Cc: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Mon, 18 Jun 2007 14:51:09 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <200706061926.l56JQLeH009994@xxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: HP OSLO R&D
References: <200706061926.l56JQLeH009994@xxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
On Wed, 2007-06-06 at 20:26 +0100, Xen staging patchbot-unstable wrote: 
> +/*
> + * Replace the standard byte memcpy with a word memcpy for appropriately 
> sized
> + * memory copy operations.  Some users (USB-UHCI) can not tolerate the 
> possible
> + * word tearing that can result from a guest concurrently writing a memory
> + * structure while the qemu device model is modifying the same location.
> + * Forcing a word-sized read/write prevents the guest from seeing a partially
> + * written word-sized atom.
> + */
> +void memcpy_words(void *dst, void *src, size_t n)
> +{
> +    while (n >= sizeof(long)) {
> +        *((long *)dst)++ = *((long *)src)++;
> +        n -= sizeof(long);
> +    }

The above requires 8-byte alignment on 64bit boxes, not the 4-byte
alignment USB provides.  This generates lots of unaligned accesses on
ia64 and probably slows things down on x64 as well.  How about the patch
below?  Thanks,

        Alex

Signed-off-by: Alex Williamson <alex.williamson@xxxxxx>
---

diff -r 7d4c40c21690 tools/ioemu/target-i386-dm/exec-dm.c
--- a/tools/ioemu/target-i386-dm/exec-dm.c      Mon Jun 18 13:50:42 2007 -0600
+++ b/tools/ioemu/target-i386-dm/exec-dm.c      Mon Jun 18 15:43:27 2007 -0600
@@ -445,11 +445,11 @@ extern unsigned long logdirty_bitmap_siz
  */
 void memcpy_words(void *dst, void *src, size_t n)
 {
-    while (n >= sizeof(long)) {
-        *((long *)dst) = *((long *)src);
-        dst = ((long *)dst) + 1;
-        src = ((long *)src) + 1;
-        n -= sizeof(long);
+    while (n > sizeof(int)) {
+        *((int *)dst) = *((int *)src);
+        dst = ((int *)dst) + 1;
+        src = ((int *)src) + 1;
+        n -= sizeof(int);
     }
 
     if (n & 4) {



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] Re: [Xen-staging] [xen-unstable] [HVM] Prevent usb driver crashes in Windows, Alex Williamson <=