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

[Xen-changelog] Xen fixes and cleanups for x86/64 guests.



ChangeSet 1.1440, 2005/04/03 11:11:45+01:00, kaf24@viper.(none)

        Xen fixes and cleanups for x86/64 guests.
        Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>



 freebsd-5.3-xen-sparse/i386-xen/include/hypervisor.h           |    2 
 linux-2.6.11-xen-sparse/arch/xen/x86_64/mm/hypervisor.c        |   14 ------
 linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/hypercall.h |    5 --
 linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/system.h    |    2 
 linux-2.6.11-xen-sparse/include/asm-xen/hypervisor.h           |    2 
 netbsd-2.0-xen-sparse/sys/arch/xen/include/hypervisor.h        |    2 
 xen/arch/x86/domain.c                                          |    8 ++-
 xen/arch/x86/mm.c                                              |    6 --
 xen/arch/x86/x86_64/entry.S                                    |    7 +--
 xen/arch/x86/x86_64/mm.c                                       |   21 +++++++++
 xen/common/schedule.c                                          |   16 ++-----
 xen/include/public/arch-x86_64.h                               |    1 
 xen/include/public/xen.h                                       |   22 
+++++-----
 13 files changed, 53 insertions(+), 55 deletions(-)


diff -Nru a/freebsd-5.3-xen-sparse/i386-xen/include/hypervisor.h 
b/freebsd-5.3-xen-sparse/i386-xen/include/hypervisor.h
--- a/freebsd-5.3-xen-sparse/i386-xen/include/hypervisor.h      2005-04-03 
07:03:05 -04:00
+++ b/freebsd-5.3-xen-sparse/i386-xen/include/hypervisor.h      2005-04-03 
07:03:05 -04:00
@@ -176,7 +176,7 @@
     __asm__ __volatile__ (
         TRAP_INSTR
         : "=a" (ret) : "0" (__HYPERVISOR_set_timer_op),
-        "b" (timeout_hi), "c" (timeout_lo) : "memory" );
+        "b" (timeout_lo), "c" (timeout_hi) : "memory" );
 
     return ret;
 }
diff -Nru a/linux-2.6.11-xen-sparse/arch/xen/x86_64/mm/hypervisor.c 
b/linux-2.6.11-xen-sparse/arch/xen/x86_64/mm/hypervisor.c
--- a/linux-2.6.11-xen-sparse/arch/xen/x86_64/mm/hypervisor.c   2005-04-03 
07:03:04 -04:00
+++ b/linux-2.6.11-xen-sparse/arch/xen/x86_64/mm/hypervisor.c   2005-04-03 
07:03:05 -04:00
@@ -430,20 +430,6 @@
     spin_unlock_irqrestore(&update_lock, flags);
 }
 
-void xen_load_gs(unsigned long ptr)
-{
-    int cpu = smp_processor_id();
-    int idx;
-    unsigned long flags;
-    spin_lock_irqsave(&update_lock, flags);
-    idx = per_cpu(mmu_update_queue_idx, cpu);
-    per_cpu(update_queue[idx], cpu).ptr  = phys_to_machine(ptr);
-    per_cpu(update_queue[idx], cpu).ptr |= MMU_EXTENDED_COMMAND;
-    per_cpu(update_queue[idx], cpu).val  = MMUEXT_LOAD_GS;
-    increment_index_and_flush();
-    spin_unlock_irqrestore(&update_lock, flags);
-}
-
 void xen_invlpg(unsigned long ptr)
 {
     int cpu = smp_processor_id();
diff -Nru a/linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/hypercall.h 
b/linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/hypercall.h
--- a/linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/hypercall.h    
2005-04-03 07:03:05 -04:00
+++ b/linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/hypercall.h    
2005-04-03 07:03:05 -04:00
@@ -218,15 +218,12 @@
 HYPERVISOR_set_timer_op(
     u64 timeout)
 {
-    unsigned long timeout_hi = timeout >> 32;
-    unsigned long timeout_lo = timeout & 0xffffffff;    
     int ret;
 
     __asm__ __volatile__ (
         TRAP_INSTR
         : "=a" (ret)
-       : "0" ((unsigned long)__HYPERVISOR_set_timer_op), 
-          "D" (timeout_hi), "S" (timeout_lo)
+       : "0" ((unsigned long)__HYPERVISOR_set_timer_op), "D" (timeout)
        : __syscall_clobber );
 
     return ret;
diff -Nru a/linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/system.h 
b/linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/system.h
--- a/linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/system.h       
2005-04-03 07:03:05 -04:00
+++ b/linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/system.h       
2005-04-03 07:03:05 -04:00
@@ -55,7 +55,7 @@
 extern void load_gs_index(unsigned);
 
 #define __load_gs_index(index) \
-        xen_load_gs((index))
+       HYPERVISOR_set_segment_base(SEGBASE_GS_USER_SEL, index)
 
 /*
  * Load a segment. Fall back on loading the zero
diff -Nru a/linux-2.6.11-xen-sparse/include/asm-xen/hypervisor.h 
b/linux-2.6.11-xen-sparse/include/asm-xen/hypervisor.h
--- a/linux-2.6.11-xen-sparse/include/asm-xen/hypervisor.h      2005-04-03 
07:03:05 -04:00
+++ b/linux-2.6.11-xen-sparse/include/asm-xen/hypervisor.h      2005-04-03 
07:03:05 -04:00
@@ -342,7 +342,7 @@
     __asm__ __volatile__ (
         TRAP_INSTR
         : "=a" (ret), "=b" (ign1), "=c" (ign2)
-       : "0" (__HYPERVISOR_set_timer_op), "b" (timeout_hi), "c" (timeout_lo)
+       : "0" (__HYPERVISOR_set_timer_op), "b" (timeout_lo), "c" (timeout_hi)
        : "memory");
 
     return ret;
diff -Nru a/netbsd-2.0-xen-sparse/sys/arch/xen/include/hypervisor.h 
b/netbsd-2.0-xen-sparse/sys/arch/xen/include/hypervisor.h
--- a/netbsd-2.0-xen-sparse/sys/arch/xen/include/hypervisor.h   2005-04-03 
07:03:05 -04:00
+++ b/netbsd-2.0-xen-sparse/sys/arch/xen/include/hypervisor.h   2005-04-03 
07:03:05 -04:00
@@ -284,7 +284,7 @@
     __asm__ __volatile__ (
         TRAP_INSTR
         : "=a" (ret), "=b" (ign1), "=c" (ign2)
-       : "0" (__HYPERVISOR_set_timer_op), "b" (timeout_hi), "c" (timeout_lo)
+       : "0" (__HYPERVISOR_set_timer_op), "b" (timeout_lo), "c" (timeout_hi)
        : "memory");
 
     return ret;
diff -Nru a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
--- a/xen/arch/x86/domain.c     2005-04-03 07:03:05 -04:00
+++ b/xen/arch/x86/domain.c     2005-04-03 07:03:05 -04:00
@@ -573,7 +573,7 @@
 void toggle_guest_mode(struct exec_domain *ed)
 {
     ed->arch.flags ^= TF_kernel_mode;
-    __asm__ __volatile__ ( "swapgs" );
+    __asm__ __volatile__ ( "mfence; swapgs" ); /* AMD erratum #88 */
     update_pagetables(ed);
     write_ptbase(ed);
 }
@@ -657,7 +657,7 @@
 
     /* If in kernel mode then switch the GS bases around. */
     if ( n->arch.flags & TF_kernel_mode )
-        __asm__ __volatile__ ( "swapgs" );
+        __asm__ __volatile__ ( "mfence; swapgs" ); /* AMD erratum #88 */
 
     if ( unlikely(!all_segs_okay) )
     {
@@ -711,7 +711,9 @@
         "movl %0,%%ds; "
         "movl %0,%%es; "
         "movl %0,%%fs; "
-        "movl %0,%%gs; swapgs; movl %0,%%gs"
+        "movl %0,%%gs; "
+        "mfence; swapgs; " /* AMD erratum #88 */
+        "movl %0,%%gs"
         : : "r" (0) );
 }
 
diff -Nru a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
--- a/xen/arch/x86/mm.c 2005-04-03 07:03:05 -04:00
+++ b/xen/arch/x86/mm.c 2005-04-03 07:03:05 -04:00
@@ -2218,8 +2218,7 @@
 }
 
 
-long do_update_descriptor(
-    unsigned long pa, unsigned long word1, unsigned long word2)
+long do_update_descriptor(unsigned long pa, u64 desc)
 {
     unsigned long pfn = pa >> PAGE_SHIFT;
     struct desc_struct *gdt_pent, d;
@@ -2227,8 +2226,7 @@
     struct exec_domain *ed;
     long ret = -EINVAL;
 
-    d.a = (u32)word1;
-    d.b = (u32)word2;
+    *(u64 *)&d = desc;
 
     LOCK_BIGLOCK(current->domain);
 
diff -Nru a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S
--- a/xen/arch/x86/x86_64/entry.S       2005-04-03 07:03:05 -04:00
+++ b/xen/arch/x86/x86_64/entry.S       2005-04-03 07:03:05 -04:00
@@ -30,6 +30,7 @@
         popq  %r11                    # CS
         cmpw  $__GUEST_CS32,%r11
         popq  %r11                    # RFLAGS
+        cli                           # No interrupts after stack switch
         popq  %rsp                    # RSP
         je    1f
         sysretq
@@ -112,8 +113,8 @@
         movq  EDOMAIN_syscall_addr(%rbx),%rax
         movq  %rax,TRAPBOUNCE_eip(%rdx)
         movw  $0,TRAPBOUNCE_flags(%rdx)
-        pushq restore_all_guest(%rip)
-        jmp   create_bounce_frame
+        call  create_bounce_frame
+        jmp   restore_all_guest
 
 /* %rbx: struct exec_domain */
 hypercall:
@@ -215,7 +216,7 @@
 FLT12:  movq  %rax,(%rsi)               # DS
 2:      subq  $16,%rsi
         movq  XREGS_r11+8(%rsp),%rax
-FLT13:  movq  %rax,(%rsi)               # R11
+FLT13:  movq  %rax,8(%rsi)              # R11
         movq  XREGS_rcx+8(%rsp),%rax
 FLT14:  movq  %rax,(%rsi)               # RCX
         /* Rewrite our stack frame and return to guest-OS mode. */
diff -Nru a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c
--- a/xen/arch/x86/x86_64/mm.c  2005-04-03 07:03:05 -04:00
+++ b/xen/arch/x86/x86_64/mm.c  2005-04-03 07:03:05 -04:00
@@ -249,6 +249,9 @@
 {
     struct exec_domain *ed = current;
 
+    /* Canonicalise the base address. */
+    base &= VADDR_MASK;
+
     switch ( which )
     {
     case SEGBASE_FS:
@@ -266,6 +269,22 @@
         wrmsr(MSR_GS_BASE, base, base>>32);
         break;
 
+    case SEGBASE_GS_USER_SEL:
+        __asm__ __volatile__ (
+            "     swapgs              \n"
+            "1:   movl %k0,%%gs       \n"
+            "     mfence; swapgs      \n" /* AMD erratum #88 */
+            ".section .fixup,\"ax\"   \n"
+            "2:   xorl %k0,%k0        \n"
+            "     jmp  1b             \n"
+            ".previous                \n"
+            ".section __ex_table,\"a\"\n"
+            "    .align 8             \n"
+            "    .quad 1b,2b          \n"
+            ".previous                  "
+            : : "r" (base&0xffff) );
+        break;
+
     default:
         return -EINVAL;
     }
@@ -284,7 +303,7 @@
         goto good;
 
     /* The guest can only safely be executed in ring 3. */
-    if ( (b & _SEGMENT_DPL) != 3 )
+    if ( (b & _SEGMENT_DPL) != _SEGMENT_DPL )
         goto bad;
 
     /* All code and data segments are okay. No base/limit checking. */
diff -Nru a/xen/common/schedule.c b/xen/common/schedule.c
--- a/xen/common/schedule.c     2005-04-03 07:03:05 -04:00
+++ b/xen/common/schedule.c     2005-04-03 07:03:05 -04:00
@@ -294,20 +294,14 @@
 }
 
 /* Per-domain one-shot-timer hypercall. */
-long do_set_timer_op(unsigned long timeout_hi, unsigned long timeout_lo)
+long do_set_timer_op(s_time_t timeout)
 {
-    struct exec_domain *p = current;
+    struct exec_domain *ed = current;
 
-    rem_ac_timer(&p->timer);
+    rem_ac_timer(&ed->timer);
     
-    if ( (timeout_hi != 0) || (timeout_lo != 0) )
-    {
-        p->timer.expires = ((s_time_t)timeout_hi<<32) | ((s_time_t)timeout_lo);
-        add_ac_timer(&p->timer);
-    }
-
-    TRACE_5D(TRC_SCHED_SET_TIMER, p->domain->id, p->eid, p, timeout_hi,
-             timeout_lo);
+    if ( (ed->timer.expires = timeout) != 0 )
+        add_ac_timer(&ed->timer);
 

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