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-changelog

[Xen-changelog] [xen-unstable] hvm: Some cleanups to vlapic emulation.

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] hvm: Some cleanups to vlapic emulation.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 19 Dec 2007 12:40:10 -0800
Delivery-date: Wed, 19 Dec 2007 12:40:44 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1198062845 0
# Node ID 181483b8e9590ed161d209c10276e9cc80b97431
# Parent  9d447ba0c99af9d6ad842b30079163cd05f1939a
hvm: Some cleanups to vlapic emulation.
Some of this was suggested by Dexuan Cui.
Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
 xen/arch/x86/hvm/vlapic.c |   41 ++++++++++++++++++++++-------------------
 1 files changed, 22 insertions(+), 19 deletions(-)

diff -r 9d447ba0c99a -r 181483b8e959 xen/arch/x86/hvm/vlapic.c
--- a/xen/arch/x86/hvm/vlapic.c Wed Dec 19 10:11:54 2007 +0000
+++ b/xen/arch/x86/hvm/vlapic.c Wed Dec 19 11:14:05 2007 +0000
@@ -472,7 +472,7 @@ static unsigned long vlapic_read(struct 
     struct vlapic *vlapic = vcpu_vlapic(v);
     unsigned int offset = address - vlapic_base_address(vlapic);
 
-    if ( offset > APIC_TDCR )
+    if ( offset > (APIC_TDCR + 0x3) )
         return 0;
 
     alignment = offset & 0x3;
@@ -535,7 +535,7 @@ static void vlapic_write(struct vcpu *v,
      * According to the IA32 Manual, all accesses should be 32 bits.
      * Some OSes do 8- or 16-byte accesses, however.
      */
-    val &= 0xffffffff;
+    val = (uint32_t)val;
     if ( len != 4 )
     {
         unsigned int tmp;
@@ -549,32 +549,27 @@ static void vlapic_write(struct vcpu *v,
         switch ( len )
         {
         case 1:
-            val = (tmp & ~(0xff << (8*alignment))) |
-                  ((val & 0xff) << (8*alignment));
+            val = ((tmp & ~(0xff << (8*alignment))) |
+                   ((val & 0xff) << (8*alignment)));
             break;
 
         case 2:
             if ( alignment & 1 )
-            {
-                gdprintk(XENLOG_ERR, "Uneven alignment error for "
-                         "2-byte vlapic access\n");
-                goto exit_and_crash;
-            }
-
-            val = (tmp & ~(0xffff << (8*alignment))) |
-                  ((val & 0xffff) << (8*alignment));
+                goto unaligned_exit_and_crash;
+            val = ((tmp & ~(0xffff << (8*alignment))) |
+                   ((val & 0xffff) << (8*alignment)));
             break;
 
         default:
             gdprintk(XENLOG_ERR, "Local APIC write with len = %lx, "
                      "should be 4 instead\n", len);
-        exit_and_crash:
-            domain_crash(v->domain);
-            return;
-        }
-    }
-
-    offset &= 0xff0;
+            goto exit_and_crash;
+        }
+    }
+    else if ( (offset & 0x3) != 0 )
+        goto unaligned_exit_and_crash;
+
+    offset &= ~0x3;
 
     switch ( offset )
     {
@@ -671,6 +666,14 @@ static void vlapic_write(struct vcpu *v,
                  "Local APIC Write to read-only register 0x%x\n", offset);
         break;
     }
+
+    return;
+
+ unaligned_exit_and_crash:
+    gdprintk(XENLOG_ERR, "Unaligned LAPIC write len=0x%lx at offset=0x%x.\n",
+             len, offset);
+ exit_and_crash:
+    domain_crash(v->domain);
 }
 
 static int vlapic_range(struct vcpu *v, unsigned long addr)

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] hvm: Some cleanups to vlapic emulation., Xen patchbot-unstable <=