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

[Xen-changelog] Avoid field duplication between vcpu_guest_context and arch_exec_domain



ChangeSet 1.1393, 2005/04/28 19:04:45+01:00, kaf24@xxxxxxxxxxxxxxxxxxxx

        Avoid field duplication between vcpu_guest_context and arch_exec_domain
        structures. The latter now includes the former as a sub-field.
        Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>



 linux-2.6.11-xen-sparse/arch/xen/i386/kernel/smpboot.c |    6 
 linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/entry.S |    6 
 tools/libxc/xc_linux_build.c                           |    6 
 tools/libxc/xc_plan9_build.c                           |    4 
 tools/libxc/xc_vmx_build.c                             |    8 
 xen/arch/x86/dom0_ops.c                                |   48 +---
 xen/arch/x86/domain.c                                  |  176 +++++++----------
 xen/arch/x86/domain_build.c                            |    9 
 xen/arch/x86/i387.c                                    |    8 
 xen/arch/x86/mm.c                                      |   10 
 xen/arch/x86/traps.c                                   |   46 ++--
 xen/arch/x86/vmx.c                                     |    8 
 xen/arch/x86/x86_32/asm-offsets.c                      |   18 +
 xen/arch/x86/x86_32/mm.c                               |    4 
 xen/arch/x86/x86_32/seg_fixup.c                        |    6 
 xen/arch/x86/x86_32/traps.c                            |   12 -
 xen/arch/x86/x86_64/asm-offsets.c                      |   12 -
 xen/arch/x86/x86_64/entry.S                            |    6 
 xen/arch/x86/x86_64/mm.c                               |   13 -
 xen/arch/x86/x86_64/traps.c                            |    6 
 xen/include/asm-x86/domain.h                           |   32 ---
 xen/include/asm-x86/ldt.h                              |    2 
 xen/include/asm-x86/processor.h                        |   16 -
 xen/include/asm-x86/x86_64/current.h                   |    6 
 xen/include/public/arch-x86_32.h                       |   21 +-
 xen/include/public/arch-x86_64.h                       |   36 +--
 26 files changed, 231 insertions(+), 294 deletions(-)


diff -Nru a/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/smpboot.c 
b/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/smpboot.c
--- a/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/smpboot.c    2005-04-28 
15:04:24 -04:00
+++ b/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/smpboot.c    2005-04-28 
15:04:24 -04:00
@@ -876,7 +876,7 @@
        ctxt.user_regs.eflags = (1<<9) | (1<<2) | (idle->thread.io_pl<<12);
 
        /* FPU is set up to default initial state. */
-       memset(ctxt.fpu_ctxt, 0, sizeof(ctxt.fpu_ctxt));
+       memset(&ctxt.fpu_ctxt, 0, sizeof(ctxt.fpu_ctxt));
 
        /* Virtual IDT is empty at start-of-day. */
        for ( i = 0; i < 256; i++ )
@@ -903,8 +903,8 @@
        }
 
        /* Ring 1 stack is the initial stack. */
-       ctxt.kernel_ss  = __KERNEL_DS;
-       ctxt.kernel_esp = idle->thread.esp;
+       ctxt.kernel_ss = __KERNEL_DS;
+       ctxt.kernel_sp = idle->thread.esp;
 
        /* Callback handlers. */
        ctxt.event_callback_cs     = __KERNEL_CS;
diff -Nru a/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/entry.S 
b/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/entry.S
--- a/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/entry.S    2005-04-28 
15:04:24 -04:00
+++ b/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/entry.S    2005-04-28 
15:04:25 -04:00
@@ -50,7 +50,7 @@
 
 
 EVENT_MASK      = (CS+4)
-ECF_IN_SYSCALL  = (1<<8)
+VGCF_IN_SYSCALL = (1<<8)
         
 /*
  * Copied from arch/xen/i386/kernel/entry.S
@@ -169,7 +169,7 @@
          *     struct switch_to_user {
          *        u64 rax, r11, rcx, flags, rip, cs, rflags, rsp, ss;
          *     } PACKED;
-         * #define ECF_IN_SYSCALL (1<<8) 
+         * #define VGCF_IN_SYSCALL (1<<8) 
          */
         .macro SWITCH_TO_USER flag
         movl $0,%gs:pda_kernel_mode     # change to user mode
@@ -275,7 +275,7 @@
        jnz  sysret_careful 
         XEN_UNBLOCK_EVENTS(%rsi)                
        RESTORE_ARGS 0,8,0
-        SWITCH_TO_USER ECF_IN_SYSCALL
+        SWITCH_TO_USER VGCF_IN_SYSCALL
 
        /* Handle reschedules */
        /* edx: work, edi: workmask */  
diff -Nru a/tools/libxc/xc_linux_build.c b/tools/libxc/xc_linux_build.c
--- a/tools/libxc/xc_linux_build.c      2005-04-28 15:04:24 -04:00
+++ b/tools/libxc/xc_linux_build.c      2005-04-28 15:04:24 -04:00
@@ -412,7 +412,7 @@
     ctxt->user_regs.eflags = (1<<9) | (1<<2);
 
     /* FPU is set up to default initial state. */
-    memset(ctxt->fpu_ctxt, 0, sizeof(ctxt->fpu_ctxt));
+    memset(&ctxt->fpu_ctxt, 0, sizeof(ctxt->fpu_ctxt));
 
     /* Virtual IDT is empty at start-of-day. */
     for ( i = 0; i < 256; i++ )
@@ -432,8 +432,8 @@
     ctxt->gdt_ents = 0;
 
     /* Ring 1 stack is the initial stack. */
-    ctxt->kernel_ss  = FLAT_KERNEL_DS;
-    ctxt->kernel_esp = vstartinfo_start + 2*PAGE_SIZE;
+    ctxt->kernel_ss = FLAT_KERNEL_DS;
+    ctxt->kernel_sp = vstartinfo_start + 2*PAGE_SIZE;
 
     /* No debugging. */
     memset(ctxt->debugreg, 0, sizeof(ctxt->debugreg));
diff -Nru a/tools/libxc/xc_plan9_build.c b/tools/libxc/xc_plan9_build.c
--- a/tools/libxc/xc_plan9_build.c      2005-04-28 15:04:24 -04:00
+++ b/tools/libxc/xc_plan9_build.c      2005-04-28 15:04:24 -04:00
@@ -498,7 +498,7 @@
        ctxt->user_regs.eflags = (1 << 9) | (1 << 2);
 
        /* FPU is set up to default initial state. */
-       memset(ctxt->fpu_ctxt, 0, sizeof (ctxt->fpu_ctxt));
+       memset(&ctxt->fpu_ctxt, 0, sizeof(ctxt->fpu_ctxt));
 
        /* Virtual IDT is empty at start-of-day. */
        for (i = 0; i < 256; i++) {
@@ -519,7 +519,7 @@
        /* Ring 1 stack is the initial stack. */
        /* put stack at top of second page */
        ctxt->kernel_ss = FLAT_KERNEL_DS;
-       ctxt->kernel_esp = ctxt->user_regs.esp;
+       ctxt->kernel_sp = ctxt->user_regs.esp;
 
        /* No debugging. */
        memset(ctxt->debugreg, 0, sizeof (ctxt->debugreg));
diff -Nru a/tools/libxc/xc_vmx_build.c b/tools/libxc/xc_vmx_build.c
--- a/tools/libxc/xc_vmx_build.c        2005-04-28 15:04:24 -04:00
+++ b/tools/libxc/xc_vmx_build.c        2005-04-28 15:04:24 -04:00
@@ -565,9 +565,9 @@
     if ( image != NULL )
         free(image);
 
-    ctxt->flags = ECF_VMX_GUEST;
+    ctxt->flags = VGCF_VMX_GUEST;
     /* FPU is set up to default initial state. */
-    memset(ctxt->fpu_ctxt, 0, sizeof(ctxt->fpu_ctxt));
+    memset(&ctxt->fpu_ctxt, 0, sizeof(ctxt->fpu_ctxt));
 
     /* Virtual IDT is empty at start-of-day. */
     for ( i = 0; i < 256; i++ )
@@ -588,8 +588,8 @@
 
     /* Ring 1 stack is the initial stack. */
 /*
-    ctxt->kernel_ss  = FLAT_KERNEL_DS;
-    ctxt->kernel_esp = vstartinfo_start;
+    ctxt->kernel_ss = FLAT_KERNEL_DS;
+    ctxt->kernel_sp = vstartinfo_start;
 */
     /* No debugging. */
     memset(ctxt->debugreg, 0, sizeof(ctxt->debugreg));
diff -Nru a/xen/arch/x86/dom0_ops.c b/xen/arch/x86/dom0_ops.c
--- a/xen/arch/x86/dom0_ops.c   2005-04-28 15:04:24 -04:00
+++ b/xen/arch/x86/dom0_ops.c   2005-04-28 15:04:24 -04:00
@@ -383,10 +383,8 @@
 #endif
 #endif
 
-    c->flags = 0;
-    memcpy(&c->user_regs, 
-           &ed->arch.user_regs,
-           sizeof(ed->arch.user_regs));
+    memcpy(c, &ed->arch.guest_context, sizeof(*c));
+
     /* IOPL privileges are virtualised -- merge back into returned eflags. */
     BUG_ON((c->user_regs.eflags & EF_IOPL) != 0);
     c->user_regs.eflags |= ed->arch.iopl << 12;
@@ -398,30 +396,22 @@
 #endif
 #endif
 
+    c->flags = 0;
     if ( test_bit(EDF_DONEFPUINIT, &ed->ed_flags) )
-        c->flags |= ECF_I387_VALID;
-    if ( KERNEL_MODE(ed, &ed->arch.user_regs) )
-        c->flags |= ECF_IN_KERNEL;
+        c->flags |= VGCF_I387_VALID;
+    if ( KERNEL_MODE(ed, &ed->arch.guest_context.user_regs) )
+        c->flags |= VGCF_IN_KERNEL;
 #ifdef CONFIG_VMX
     if (VMX_DOMAIN(ed))
-        c->flags |= ECF_VMX_GUEST;
+        c->flags |= VGCF_VMX_GUEST;
 #endif
-    memcpy(&c->fpu_ctxt,
-           &ed->arch.i387,
-           sizeof(ed->arch.i387));
-    memcpy(&c->trap_ctxt,
-           ed->arch.traps,
-           sizeof(ed->arch.traps));
+
 #ifdef ARCH_HAS_FAST_TRAP
     if ( (ed->arch.fast_trap_desc.a == 0) &&
          (ed->arch.fast_trap_desc.b == 0) )
         c->fast_trap_idx = 0;
-    else
-        c->fast_trap_idx = 
-            ed->arch.fast_trap_idx;
 #endif
-    c->ldt_base = ed->arch.ldt_base;
-    c->ldt_ents = ed->arch.ldt_ents;
+
     c->gdt_ents = 0;
     if ( GET_GDT_ADDRESS(ed) == GDT_VIRT_START(ed) )
     {
@@ -430,22 +420,8 @@
                 l1e_get_pfn(ed->arch.perdomain_ptes[i]);
         c->gdt_ents = GET_GDT_ENTRIES(ed);
     }
-    c->kernel_ss  = ed->arch.kernel_ss;
-    c->kernel_esp = ed->arch.kernel_sp;
-    c->pt_base   = 
-        pagetable_val(ed->arch.guest_table);
-    memcpy(c->debugreg, 
-           ed->arch.debugreg, 
-           sizeof(ed->arch.debugreg));
-#if defined(__i386__)
-    c->event_callback_cs     = ed->arch.event_selector;
-    c->event_callback_eip    = ed->arch.event_address;
-    c->failsafe_callback_cs  = ed->arch.failsafe_selector;
-    c->failsafe_callback_eip = ed->arch.failsafe_address;
-#elif defined(__x86_64__)
-    c->event_callback_eip    = ed->arch.event_address;
-    c->failsafe_callback_eip = ed->arch.failsafe_address;
-    c->syscall_callback_eip  = ed->arch.syscall_address;
-#endif
+
+    c->pt_base = pagetable_val(ed->arch.guest_table);
+
     c->vm_assist = ed->domain->vm_assist;
 }
diff -Nru a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
--- a/xen/arch/x86/domain.c     2005-04-28 15:04:24 -04:00
+++ b/xen/arch/x86/domain.c     2005-04-28 15:04:24 -04:00
@@ -385,65 +385,42 @@
      * #GP. If DS, ES, FS, GS are DPL 0 then they'll be cleared automatically.
      * If SS RPL or DPL differs from CS RPL then we'll #GP.
      */
-    if (!(c->flags & ECF_VMX_GUEST)) 
+    if ( !(c->flags & VGCF_VMX_GUEST) )
+    {
         if ( ((c->user_regs.cs & 3) == 0) ||
              ((c->user_regs.ss & 3) == 0) )
                 return -EINVAL;
+    }
 
     clear_bit(EDF_DONEFPUINIT, &ed->ed_flags);
-    if ( c->flags & ECF_I387_VALID )
+    if ( c->flags & VGCF_I387_VALID )
         set_bit(EDF_DONEFPUINIT, &ed->ed_flags);
 
     ed->arch.flags &= ~TF_kernel_mode;
-    if ( c->flags & ECF_IN_KERNEL )
+    if ( c->flags & VGCF_IN_KERNEL )
         ed->arch.flags |= TF_kernel_mode;
 
-    memcpy(&ed->arch.user_regs,
-           &c->user_regs,
-           sizeof(ed->arch.user_regs));
-
-    memcpy(&ed->arch.i387,
-           &c->fpu_ctxt,
-           sizeof(ed->arch.i387));
+    memcpy(&ed->arch.guest_context, c, sizeof(*c));
 
     /* IOPL privileges are virtualised. */
-    ed->arch.iopl = (ed->arch.user_regs.eflags >> 12) & 3;
-    ed->arch.user_regs.eflags &= ~EF_IOPL;
+    ed->arch.iopl = (ed->arch.guest_context.user_regs.eflags >> 12) & 3;
+    ed->arch.guest_context.user_regs.eflags &= ~EF_IOPL;
 
     /* Clear IOPL for unprivileged domains. */
-    if (!IS_PRIV(d))
-        ed->arch.user_regs.eflags &= 0xffffcfff;
+    if ( !IS_PRIV(d) )
+        ed->arch.guest_context.user_regs.eflags &= 0xffffcfff;
 
-    if (test_bit(EDF_DONEINIT, &ed->ed_flags))

_______________________________________________
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®.