[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Manual merge.



ChangeSet 1.1721, 2005/06/10 17:17:11+01:00, kaf24@xxxxxxxxxxxxxxxxxxxx

        Manual merge.



 seg_fixup.c |   79 ++++++++++++++++++++++++++++--------------------------------
 1 files changed, 37 insertions(+), 42 deletions(-)


diff -Nru a/xen/arch/x86/x86_32/seg_fixup.c b/xen/arch/x86/x86_32/seg_fixup.c
--- a/xen/arch/x86/x86_32/seg_fixup.c   2005-06-10 13:01:50 -04:00
+++ b/xen/arch/x86/x86_32/seg_fixup.c   2005-06-10 13:01:50 -04:00
@@ -27,7 +27,10 @@
 #include <xen/errno.h>
 #include <xen/mm.h>
 #include <xen/perfc.h>
+#include <asm/current.h>
 #include <asm/processor.h>
+#include <asm/regs.h>
+#include <asm/x86_emulate.h>
 
 /* Make the scary benign errors go away. */
 #undef  DPRINTK
@@ -105,7 +108,7 @@
  */
 int get_baselimit(u16 seg, unsigned long *base, unsigned long *limit)
 {
-    struct domain *d = current;
+    struct vcpu *d = current;
     unsigned long *table, a, b;
     int            ldt = !!(seg & 4);
     int            idx = (seg >> 3) & 8191;
@@ -113,14 +116,14 @@
     /* Get base and check limit. */
     if ( ldt )
     {
-        table = (unsigned long *)LDT_VIRT_START;
-        if ( idx >= d->mm.ldt_ents )
+        table = (unsigned long *)LDT_VIRT_START(d);
+        if ( idx >= d->arch.guest_context.ldt_ents )
             goto fail;
     }
     else /* gdt */
     {
-        table = (unsigned long *)GET_GDT_ADDRESS(d);
-        if ( idx >= GET_GDT_ENTRIES(d) )
+        table = (unsigned long *)GDT_VIRT_START(d);
+        if ( idx >= d->arch.guest_context.gdt_ents )
             goto fail;
     }
 
@@ -144,7 +147,7 @@
      * Anything that looks like a truncated segment we assume ought really
      * to be a 4GB segment. DANGER!
      */
-    if ( (PAGE_OFFSET - (*base + *limit)) < PAGE_SIZE )
+    if ( (GUEST_SEGMENT_MAX_ADDR - (*base + *limit)) < PAGE_SIZE )
         *limit = 0;
 
     return 1;
@@ -171,7 +174,7 @@
 
 int fixup_seg(u16 seg, unsigned long offset)
 {
-    struct domain *d = current;
+    struct vcpu *d = current;
     unsigned long *table, a, b, base, limit;
     int            ldt = !!(seg & 4);
     int            idx = (seg >> 3) & 8191;
@@ -179,21 +182,21 @@
     /* Get base and check limit. */
     if ( ldt )
     {
-        table = (unsigned long *)LDT_VIRT_START;
-        if ( idx >= d->mm.ldt_ents )
+        table = (unsigned long *)LDT_VIRT_START(d);
+        if ( idx >= d->arch.guest_context.ldt_ents )
         {
             DPRINTK("Segment %04x out of LDT range (%ld)\n",
-                    seg, d->mm.ldt_ents);
+                    seg, d->arch.guest_context.ldt_ents);
             goto fail;
         }
     }
     else /* gdt */
     {
-        table = (unsigned long *)GET_GDT_ADDRESS(d);
-        if ( idx >= GET_GDT_ENTRIES(d) )
+        table = (unsigned long *)GDT_VIRT_START(d);
+        if ( idx >= d->arch.guest_context.gdt_ents )
         {
-            DPRINTK("Segment %04x out of GDT range (%d)\n",
-                    seg, GET_GDT_ENTRIES(d));
+            DPRINTK("Segment %04x out of GDT range (%ld)\n",
+                    seg, d->arch.guest_context.gdt_ents);
             goto fail;
         }
     }
@@ -225,14 +228,14 @@
         if ( ((base + limit) < PAGE_SIZE) && (offset <= limit)  )
         {
             /* Flip to expands-up. */
-            limit = PAGE_OFFSET - base;
+            limit = GUEST_SEGMENT_MAX_ADDR - base;
             goto flip;
         }
     }
     else
     {
         /* Expands-up: All the way to Xen space? Assume 4GB if so. */
-        if ( ((PAGE_OFFSET - (base + limit)) < PAGE_SIZE) &&
+        if ( ((GUEST_SEGMENT_MAX_ADDR - (base + limit)) < PAGE_SIZE) &&
              (offset > limit) )
         {
             /* Flip to expands-down. */
@@ -258,31 +261,13 @@
     return 1;
 }
 
-/* Decode Reg field of a ModRM byte: return a pointer into a register block. */
-void *decode_reg(struct xen_regs *regs, u8 b)
-{
-    switch ( b & 7 )
-    {
-    case 0: return &regs->eax;
-    case 1: return &regs->ecx;
-    case 2: return &regs->edx;
-    case 3: return &regs->ebx;
-    case 4: return &regs->esp;
-    case 5: return &regs->ebp;
-    case 6: return &regs->esi;
-    case 7: return &regs->edi;
-    }
-
-    return NULL;
-}
-
 /*
  * Called from the general-protection fault handler to attempt to decode
  * and emulate an instruction that depends on 4GB segments.
  */
-int gpf_emulate_4gb(struct xen_regs *regs)
+int gpf_emulate_4gb(struct cpu_user_regs *regs)
 {
-    struct domain *d = current;
+    struct vcpu *d = current;
     trap_info_t   *ti;
     struct trap_bounce *tb;
     u8            modrm, mod, reg, rm, decode;
@@ -399,8 +384,8 @@
     }
 
     /* Decode Reg and R/M fields. */
-    regreg = decode_reg(regs, reg);
-    memreg = decode_reg(regs, rm);
+    regreg = decode_register(reg, regs, 0);
+    memreg = decode_register(rm,  regs, 0);
 
     /* Decode Mod field. */
     switch ( modrm >> 6 )
@@ -455,16 +440,16 @@
     perfc_incrc(seg_fixups);
 
     /* If requested, give a callback on otherwise unused vector 15. */
-    if ( VM_ASSIST(d, VMASST_TYPE_4gb_segments_notify) )
+    if ( VM_ASSIST(d->domain, VMASST_TYPE_4gb_segments_notify) )
     {
-        ti  = &d->thread.traps[15];
-        tb = &d->thread.trap_bounce;
+        ti  = &d->arch.guest_context.trap_ctxt[15];
+        tb  = &d->arch.trap_bounce;
         tb->flags      = TBF_EXCEPTION | TBF_EXCEPTION_ERRCODE;
         tb->error_code = pb - eip;
         tb->cs         = ti->cs;
         tb->eip        = ti->address;
         if ( TI_GET_IF(ti) )
-            d->shared_info->vcpu_data[0].evtchn_upcall_mask = 1;
+            tb->flags |= TBF_INTERRUPT;
     }
 
     return EXCRET_fault_fixed;
@@ -482,3 +467,13 @@
     propagate_page_fault((unsigned long)pb, 4);
     return EXCRET_fault_fixed;
 }
+
+/*
+ * Local variables:
+ * mode: C
+ * c-set-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.