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

[Xen-devel] [PATCH,RFC 6/17] 32-on-64 shared info handling



Index: 2006-10-04/xen/arch/x86/domain.c
===================================================================
--- 2006-10-04.orig/xen/arch/x86/domain.c       2006-10-04 15:03:07.000000000 
+0200
+++ 2006-10-04/xen/arch/x86/domain.c    2006-10-04 15:11:03.000000000 +0200
@@ -550,10 +550,10 @@ static void load_segments(struct vcpu *n
 
             /* CS longword also contains full evtchn_upcall_mask. */
             cs_and_mask = (unsigned short)regs->cs |
-                ((unsigned int)n->vcpu_info->evtchn_upcall_mask << 16);
+                ((unsigned int)vcpu_info(n, evtchn_upcall_mask) << 16);
             /* Fold upcall mask into RFLAGS.IF. */
             eflags  = regs->_eflags & ~X86_EFLAGS_IF;
-            eflags |= !n->vcpu_info->evtchn_upcall_mask << 9;
+            eflags |= !vcpu_info(n, evtchn_upcall_mask) << 9;
 
             if ( !ring_1(regs) )
             {
@@ -577,7 +577,7 @@ static void load_segments(struct vcpu *n
 
             if ( test_bit(_VGCF_failsafe_disables_events,
                           &n->arch.guest_context.flags) )
-                n->vcpu_info->evtchn_upcall_mask = 1;
+                vcpu_info(n, evtchn_upcall_mask) = 1;
 
             regs->entry_vector  = TRAP_syscall;
             regs->_eflags      &= 0xFFFCBEFFUL;
@@ -595,11 +595,11 @@ static void load_segments(struct vcpu *n
 
         /* CS longword also contains full evtchn_upcall_mask. */
         cs_and_mask = (unsigned long)regs->cs |
-            ((unsigned long)n->vcpu_info->evtchn_upcall_mask << 32);
+            ((unsigned long)vcpu_info(n, evtchn_upcall_mask) << 32);
 
         /* Fold upcall mask into RFLAGS.IF. */
         rflags  = regs->rflags & ~X86_EFLAGS_IF;
-        rflags |= !n->vcpu_info->evtchn_upcall_mask << 9;
+        rflags |= !vcpu_info(n, evtchn_upcall_mask) << 9;
 
         if ( put_user(regs->ss,            rsp- 1) |
              put_user(regs->rsp,           rsp- 2) |
@@ -619,7 +619,7 @@ static void load_segments(struct vcpu *n
 
         if ( test_bit(_VGCF_failsafe_disables_events,
                       &n->arch.guest_context.flags) )
-            n->vcpu_info->evtchn_upcall_mask = 1;
+            vcpu_info(n, evtchn_upcall_mask) = 1;
 
         regs->entry_vector  = TRAP_syscall;
         regs->rflags       &= ~(X86_EFLAGS_AC|X86_EFLAGS_VM|X86_EFLAGS_RF|
Index: 2006-10-04/xen/arch/x86/domain_build.c
===================================================================
--- 2006-10-04.orig/xen/arch/x86/domain_build.c 2006-10-04 15:10:46.000000000 
+0200
+++ 2006-10-04/xen/arch/x86/domain_build.c      2006-10-04 15:11:03.000000000 
+0200
@@ -325,6 +325,7 @@ int construct_dom0(struct domain *d,
         l1_pgentry_t gdt_l1e;
 
         set_bit(_DOMF_compat, &d->domain_flags);
+        v->vcpu_info = (void *)&d->shared_info->compat.vcpu_info[0];
 
         if ( nr_pages != (unsigned int)nr_pages )
             nr_pages = UINT_MAX;
@@ -735,7 +736,7 @@ int construct_dom0(struct domain *d,
 
     /* Mask all upcalls... */
     for ( i = 0; i < MAX_VIRT_CPUS; i++ )
-        d->shared_info->vcpu_info[i].evtchn_upcall_mask = 1;
+        shared_info(d, vcpu_info[i].evtchn_upcall_mask) = 1;
 
     if ( opt_dom0_max_vcpus == 0 )
         opt_dom0_max_vcpus = num_online_cpus();
Index: 2006-10-04/xen/arch/x86/hvm/svm/svm.c
===================================================================
--- 2006-10-04.orig/xen/arch/x86/hvm/svm/svm.c  2006-10-04 08:49:29.000000000 
+0200
+++ 2006-10-04/xen/arch/x86/hvm/svm/svm.c       2006-10-04 15:11:03.000000000 
+0200
@@ -815,8 +815,7 @@ static void svm_final_setup_guest(struct
      * Required to do this once per domain
      * TODO: add a seperate function to do these.
      */
-    memset(&d->shared_info->evtchn_mask[0], 0xff, 
-           sizeof(d->shared_info->evtchn_mask));       
+    memset(shared_info_addr(d, evtchn_mask), 0xff, MAX_EVTCHNS(d) / 8);
 }
 
 
Index: 2006-10-04/xen/arch/x86/hvm/vmx/vmx.c
===================================================================
--- 2006-10-04.orig/xen/arch/x86/hvm/vmx/vmx.c  2006-10-04 08:49:29.000000000 
+0200
+++ 2006-10-04/xen/arch/x86/hvm/vmx/vmx.c       2006-10-04 15:11:03.000000000 
+0200
@@ -119,8 +119,7 @@ static int vmx_initialize_guest_resource
      * Required to do this once per domain XXX todo: add a seperate function 
      * to do these.
      */
-    memset(&d->shared_info->evtchn_mask[0], 0xff,
-           sizeof(d->shared_info->evtchn_mask));
+    memset(shared_info_addr(d, evtchn_mask), 0xff, MAX_EVTCHNS(d) / 8);
 
     return 1;
 }
Index: 2006-10-04/xen/arch/x86/irq.c
===================================================================
--- 2006-10-04.orig/xen/arch/x86/irq.c  2006-10-04 08:49:29.000000000 +0200
+++ 2006-10-04/xen/arch/x86/irq.c       2006-10-04 15:11:03.000000000 +0200
@@ -13,6 +13,7 @@
 #include <xen/perfc.h>
 #include <xen/sched.h>
 #include <xen/keyhandler.h>
+#include <xen/compat.h>
 #include <asm/current.h>
 #include <asm/smpboot.h>
 
@@ -332,7 +333,7 @@ int pirq_guest_unmask(struct domain *d)
           irq < NR_IRQS;
           irq = find_next_bit(d->pirq_mask, NR_IRQS, irq+1) )
     {
-        if ( !test_bit(d->pirq_to_evtchn[irq], s->evtchn_mask) )
+        if ( !test_bit(d->pirq_to_evtchn[irq], __shared_info_addr(d, s, 
evtchn_mask)) )
             __pirq_guest_eoi(d, irq);
     }
 
@@ -619,14 +620,13 @@ static void dump_irqs(unsigned char key)
                 printk("%u(%c%c%c%c)",
                        d->domain_id,
                        (test_bit(d->pirq_to_evtchn[irq],
-                                 d->shared_info->evtchn_pending) ?
+                                 shared_info_addr(d, evtchn_pending)) ?
                         'P' : '-'),
-                       (test_bit(d->pirq_to_evtchn[irq]/BITS_PER_LONG,
-                                 &d->shared_info->vcpu_info[0].
-                                 evtchn_pending_sel) ?
+                       (test_bit(d->pirq_to_evtchn[irq]/BITS_PER_GUEST_LONG(d),
+                                 vcpu_info_addr(d->vcpu[0], 
evtchn_pending_sel)) ?
                         'S' : '-'),
                        (test_bit(d->pirq_to_evtchn[irq],
-                                 d->shared_info->evtchn_mask) ?
+                                 shared_info_addr(d, evtchn_mask)) ?
                         'M' : '-'),
                        (test_bit(irq, d->pirq_mask) ?
                         'M' : '-'));
Index: 2006-10-04/xen/arch/x86/mm/shadow/common.c
===================================================================
--- 2006-10-04.orig/xen/arch/x86/mm/shadow/common.c     2006-10-04 
08:49:30.000000000 +0200
+++ 2006-10-04/xen/arch/x86/mm/shadow/common.c  2006-10-04 15:11:03.000000000 
+0200
@@ -36,6 +36,7 @@
 #include <asm/current.h>
 #include <asm/flushtlb.h>
 #include <asm/shadow.h>
+#include <asm/shared.h>
 #include "private.h"
 
 #if SHADOW_AUDIT
@@ -2712,7 +2713,7 @@ sh_alloc_log_dirty_bitmap(struct domain 
 {
     ASSERT(d->arch.shadow.dirty_bitmap == NULL);
     d->arch.shadow.dirty_bitmap_size =
-        (d->shared_info->arch.max_pfn + (BITS_PER_LONG - 1)) &
+        (arch_get_max_pfn(d) + (BITS_PER_LONG - 1)) &
         ~(BITS_PER_LONG - 1);
     d->arch.shadow.dirty_bitmap =
         xmalloc_array(unsigned long,
Index: 2006-10-04/xen/arch/x86/setup.c
===================================================================
--- 2006-10-04.orig/xen/arch/x86/setup.c        2006-10-04 15:10:46.000000000 
+0200
+++ 2006-10-04/xen/arch/x86/setup.c     2006-10-04 15:11:03.000000000 +0200
@@ -437,14 +437,13 @@ void __init __start_xen(multiboot_info_t
 
     BUILD_BUG_ON(sizeof(start_info_t) > PAGE_SIZE);
     BUILD_BUG_ON(sizeof(shared_info_t) > PAGE_SIZE);
-    BUILD_BUG_ON(sizeof(vcpu_info_t) != 64);
+    BUILD_BUG_ON(sizeof(struct vcpu_info) != 64);
 
 #ifdef CONFIG_COMPAT
     BUILD_BUG_ON(sizeof(((struct compat_platform_op *)0)->u) !=
                  sizeof(((struct compat_platform_op *)0)->u.pad));
     BUILD_BUG_ON(sizeof(start_info_compat_t) > PAGE_SIZE);
-    BUILD_BUG_ON(sizeof(shared_info_compat_t) > PAGE_SIZE);
-    BUILD_BUG_ON(sizeof(vcpu_info_compat_t) != 64);
+    BUILD_BUG_ON(sizeof(struct compat_vcpu_info) != 64);
 #endif
 
     /* Check definitions in public headers match internal defs. */
Index: 2006-10-04/xen/arch/x86/time.c
===================================================================
--- 2006-10-04.orig/xen/arch/x86/time.c 2006-09-11 09:06:11.000000000 +0200
+++ 2006-10-04/xen/arch/x86/time.c      2006-10-04 15:11:03.000000000 +0200
@@ -676,7 +676,7 @@ static inline void __update_vcpu_system_
     struct vcpu_time_info *u;
 
     t = &this_cpu(cpu_time);
-    u = &v->vcpu_info->time;
+    u = &vcpu_info(v, time);
 
     version_update_begin(&u->version);
 
@@ -690,7 +690,7 @@ static inline void __update_vcpu_system_
 
 void update_vcpu_system_time(struct vcpu *v)
 {
-    if ( v->vcpu_info->time.tsc_timestamp !=
+    if ( vcpu_info(v, time.tsc_timestamp) !=
          this_cpu(cpu_time).local_tsc_stamp )
         __update_vcpu_system_time(v);
 }
@@ -698,10 +698,10 @@ void update_vcpu_system_time(struct vcpu
 void update_domain_wallclock_time(struct domain *d)
 {
     spin_lock(&wc_lock);
-    version_update_begin(&d->shared_info->wc_version);
-    d->shared_info->wc_sec  = wc_sec + d->time_offset_seconds;
-    d->shared_info->wc_nsec = wc_nsec;
-    version_update_end(&d->shared_info->wc_version);
+    version_update_begin(&shared_info(d, wc_version));
+    shared_info(d, wc_sec)  = wc_sec + d->time_offset_seconds;
+    shared_info(d, wc_nsec) = wc_nsec;
+    version_update_end(&shared_info(d, wc_version));
     spin_unlock(&wc_lock);
 }
 
Index: 2006-10-04/xen/arch/x86/traps.c
===================================================================
--- 2006-10-04.orig/xen/arch/x86/traps.c        2006-10-04 15:06:22.000000000 
+0200
+++ 2006-10-04/xen/arch/x86/traps.c     2006-10-04 15:11:03.000000000 +0200
@@ -57,6 +57,7 @@
 #include <asm/i387.h>
 #include <asm/debugger.h>
 #include <asm/msr.h>
+#include <asm/shared.h>
 #include <asm/x86_emulate.h>
 
 /*
@@ -688,7 +689,7 @@ void propagate_page_fault(unsigned long 
     struct trap_bounce *tb = &v->arch.trap_bounce;
 
     v->arch.guest_context.ctrlreg[2] = addr;
-    v->vcpu_info->arch.cr2           = addr;
+    arch_set_cr2(v, addr);
 
     /* Re-set error_code.user flag appropriately for the guest. */
     error_code &= ~PFEC_user_mode;
@@ -1393,7 +1394,7 @@ static int emulate_privileged_op(struct 
 
         case 2: /* Write CR2 */
             v->arch.guest_context.ctrlreg[2] = *reg;
-            v->vcpu_info->arch.cr2           = *reg;
+            arch_set_cr2(v, *reg);
             break;
 
         case 3: /* Write CR3 */
@@ -1611,7 +1612,7 @@ static void nmi_dom0_report(unsigned int
     if ( ((d = dom0) == NULL) || ((v = d->vcpu[0]) == NULL) )
         return;
 
-    set_bit(reason_idx, &d->shared_info->arch.nmi_reason);
+    set_bit(reason_idx, nmi_reason(d));
 
     if ( test_and_set_bit(_VCPUF_nmi_pending, &v->vcpu_flags) )
         raise_softirq(NMI_SOFTIRQ); /* not safe to wake up a vcpu here */
Index: 2006-10-04/xen/arch/x86/x86_64/asm-offsets.c
===================================================================
--- 2006-10-04.orig/xen/arch/x86/x86_64/asm-offsets.c   2006-10-04 
15:06:22.000000000 +0200
+++ 2006-10-04/xen/arch/x86/x86_64/asm-offsets.c        2006-10-04 
15:11:03.000000000 +0200
@@ -7,6 +7,9 @@
 #include <xen/config.h>
 #include <xen/perfc.h>
 #include <xen/sched.h>
+#ifdef CONFIG_COMPAT
+#include <compat/xen.h>
+#endif
 #include <asm/fixmap.h>
 #include <asm/hardirq.h>
 
@@ -95,9 +98,15 @@ void __dummy__(void)
     OFFSET(VMCB_tsc_offset, struct vmcb_struct, tsc_offset);
     BLANK();
 
-    OFFSET(VCPUINFO_upcall_pending, vcpu_info_t, evtchn_upcall_pending);
-    OFFSET(VCPUINFO_upcall_mask, vcpu_info_t, evtchn_upcall_mask);
+    OFFSET(VCPUINFO_upcall_pending, struct vcpu_info, evtchn_upcall_pending);
+    OFFSET(VCPUINFO_upcall_mask, struct vcpu_info, evtchn_upcall_mask);
+    BLANK();
+
+#ifdef CONFIG_COMPAT
+    OFFSET(COMPAT_VCPUINFO_upcall_pending, struct compat_vcpu_info, 
evtchn_upcall_pending);
+    OFFSET(COMPAT_VCPUINFO_upcall_mask, struct compat_vcpu_info, 
evtchn_upcall_mask);
     BLANK();
+#endif
 
     OFFSET(CPUINFO_current_vcpu, struct cpu_info, current_vcpu);
     DEFINE(CPUINFO_sizeof, sizeof(struct cpu_info));
Index: 2006-10-04/xen/arch/x86/x86_64/compat/entry.S
===================================================================
--- 2006-10-04.orig/xen/arch/x86/x86_64/compat/entry.S  2006-10-04 
15:09:52.000000000 +0200
+++ 2006-10-04/xen/arch/x86/x86_64/compat/entry.S       2006-10-04 
15:11:03.000000000 +0200
@@ -71,9 +71,9 @@ compat_test_all_events:
         jc    compat_process_nmi
 compat_test_guest_events:
         movq  VCPU_vcpu_info(%rbx),%rax
-        testb $0xFF,VCPUINFO_upcall_mask(%rax)
+        testb $0xFF,COMPAT_VCPUINFO_upcall_mask(%rax)
         jnz   compat_restore_all_guest
-        testb $0xFF,VCPUINFO_upcall_pending(%rax)
+        testb $0xFF,COMPAT_VCPUINFO_upcall_pending(%rax)
         jz    compat_restore_all_guest
 /*compat_process_guest_events:*/
         sti
@@ -191,10 +191,10 @@ CFLT4:  mov   UREGS_ss+8(%rsp),%fs
         movb  TRAPBOUNCE_flags(%rdx),%cl
         subl  $3*4,%esi
         movq  VCPU_vcpu_info(%rbx),%rax
-        pushq VCPUINFO_upcall_mask(%rax)
+        pushq COMPAT_VCPUINFO_upcall_mask(%rax)
         testb $TBF_INTERRUPT,%cl
         setnz %ch                       # TBF_INTERRUPT -> set upcall mask
-        orb   %ch,VCPUINFO_upcall_mask(%rax)
+        orb   %ch,COMPAT_VCPUINFO_upcall_mask(%rax)
         popq  %rax
         shll  $16,%eax                  # Bits 16-23: saved_upcall_mask
         movw  UREGS_cs+8(%rsp),%ax      # Bits  0-15: CS
Index: 2006-10-04/xen/arch/x86/x86_64/compat/traps.c
===================================================================
--- 2006-10-04.orig/xen/arch/x86/x86_64/compat/traps.c  2006-10-04 
15:09:52.000000000 +0200
+++ 2006-10-04/xen/arch/x86/x86_64/compat/traps.c       2006-10-04 
15:11:03.000000000 +0200
@@ -75,7 +75,7 @@ unsigned long compat_iret(void)
     clear_bit(_VCPUF_nmi_masked, &current->vcpu_flags);
 
     /* Restore upcall mask from supplied EFLAGS.IF. */
-    current->vcpu_info->evtchn_upcall_mask = !(eflags & X86_EFLAGS_IF);
+    vcpu_info(current, evtchn_upcall_mask) = !(eflags & X86_EFLAGS_IF);
 
     /*
      * The hypercall exit path will overwrite EAX with this return
Index: 2006-10-04/xen/arch/x86/x86_64/traps.c
===================================================================
--- 2006-10-04.orig/xen/arch/x86/x86_64/traps.c 2006-10-04 15:06:22.000000000 
+0200
+++ 2006-10-04/xen/arch/x86/x86_64/traps.c      2006-10-04 15:11:03.000000000 
+0200
@@ -18,6 +18,7 @@
 #include <asm/msr.h>
 #include <asm/page.h>
 #include <asm/shadow.h>
+#include <asm/shared.h>
 #include <asm/hvm/hvm.h>
 #include <asm/hvm/support.h>
 
@@ -53,7 +54,7 @@ void show_registers(struct cpu_user_regs
         if ( guest_mode(regs) )
         {
             context = "guest";
-            fault_crs[2] = current->vcpu_info->arch.cr2;
+            fault_crs[2] = arch_get_cr2(current);
         }
         else
         {
@@ -241,7 +242,7 @@ unsigned long do_iret(void)
     clear_bit(_VCPUF_nmi_masked, &current->vcpu_flags);
 
     /* Restore upcall mask from supplied EFLAGS.IF. */
-    current->vcpu_info->evtchn_upcall_mask = !(iret_saved.rflags & EF_IE);
+    vcpu_info(current, evtchn_upcall_mask) = !(iret_saved.rflags & EF_IE);
 
     /* Saved %rax gets written back to regs->rax in entry.S. */
     return iret_saved.rax;
Index: 2006-10-04/xen/common/compat/xlat.c
===================================================================
--- 2006-10-04.orig/xen/common/compat/xlat.c    2006-10-04 15:10:46.000000000 
+0200
+++ 2006-10-04/xen/common/compat/xlat.c 2006-10-04 15:11:03.000000000 +0200
@@ -21,6 +21,10 @@ void xlat_start_info(struct start_info *
 CHECK_dom0_vga_console_info
 #undef dom0_vga_console_info
 
+#define xen_vcpu_time_info vcpu_time_info
+CHECK_vcpu_time_info
+#undef xen_vcpu_time_info
+
 /*
  * Local variables:
  * mode: C
Index: 2006-10-04/xen/common/domain.c
===================================================================
--- 2006-10-04.orig/xen/common/domain.c 2006-10-04 08:49:30.000000000 +0200
+++ 2006-10-04/xen/common/domain.c      2006-10-04 15:14:26.000000000 +0200
@@ -82,7 +82,7 @@ struct vcpu *alloc_vcpu(
 
     v->domain = d;
     v->vcpu_id = vcpu_id;
-    v->vcpu_info = &d->shared_info->vcpu_info[vcpu_id];
+    v->vcpu_info = shared_info_addr(d, vcpu_info[vcpu_id]);
     spin_lock_init(&v->pause_lock);
 
     v->runstate.state = is_idle_vcpu(v) ? RUNSTATE_running : RUNSTATE_offline;
Index: 2006-10-04/xen/common/event_channel.c
===================================================================
--- 2006-10-04.orig/xen/common/event_channel.c  2006-08-07 09:07:03.000000000 
+0200
+++ 2006-10-04/xen/common/event_channel.c       2006-10-04 15:11:03.000000000 
+0200
@@ -23,6 +23,7 @@
 #include <xen/event.h>
 #include <xen/irq.h>
 #include <xen/iocap.h>
+#include <xen/compat.h>
 #include <xen/guest_access.h>
 #include <asm/current.h>
 
@@ -33,7 +34,7 @@
 #define bucket_from_port(d,p) \
     ((d)->evtchn[(p)/EVTCHNS_PER_BUCKET])
 #define port_is_valid(d,p)    \
-    (((p) >= 0) && ((p) < MAX_EVTCHNS) && \
+    (((p) >= 0) && ((p) < MAX_EVTCHNS(d)) && \
      (bucket_from_port(d,p) != NULL))
 #define evtchn_from_port(d,p) \
     (&(bucket_from_port(d,p))[(p)&(EVTCHNS_PER_BUCKET-1)])
@@ -81,7 +82,7 @@ static int get_free_port(struct domain *
         if ( evtchn_from_port(d, port)->state == ECS_FREE )
             return port;
 
-    if ( port == MAX_EVTCHNS )
+    if ( port == MAX_EVTCHNS(d) )
         return -ENOSPC;
 
     chn = xmalloc_array(struct evtchn, EVTCHNS_PER_BUCKET);
@@ -516,12 +517,12 @@ void evtchn_set_pending(struct vcpu *v, 
      * others may require explicit memory barriers.
      */
 
-    if ( test_and_set_bit(port, s->evtchn_pending) )
+    if ( test_and_set_bit(port, __shared_info_addr(d, s, evtchn_pending)) )
         return;
 
-    if ( !test_bit        (port, s->evtchn_mask) &&
-         !test_and_set_bit(port / BITS_PER_LONG,
-                           &v->vcpu_info->evtchn_pending_sel) )
+    if ( !test_bit        (port, __shared_info_addr(d, s, evtchn_mask)) &&
+         !test_and_set_bit(port / BITS_PER_GUEST_LONG(d),
+                           vcpu_info_addr(v, evtchn_pending_sel)) )
     {
         vcpu_mark_events_pending(v);
     }
@@ -719,10 +720,10 @@ static long evtchn_unmask(evtchn_unmask_
      * These operations must happen in strict order. Based on
      * include/xen/event.h:evtchn_set_pending(). 
      */
-    if ( test_and_clear_bit(port, s->evtchn_mask) &&
-         test_bit          (port, s->evtchn_pending) &&
-         !test_and_set_bit (port / BITS_PER_LONG,
-                            &v->vcpu_info->evtchn_pending_sel) )
+    if ( test_and_clear_bit(port, __shared_info_addr(d, s, evtchn_mask)) &&
+         test_bit          (port, __shared_info_addr(d, s, evtchn_pending)) &&
+         !test_and_set_bit (port / BITS_PER_GUEST_LONG(d),
+                            vcpu_info_addr(v, evtchn_pending_sel)) )
     {
         vcpu_mark_events_pending(v);
     }
Index: 2006-10-04/xen/common/kernel.c
===================================================================
--- 2006-10-04.orig/xen/common/kernel.c 2006-10-04 15:09:52.000000000 +0200
+++ 2006-10-04/xen/common/kernel.c      2006-10-04 15:11:03.000000000 +0200
@@ -16,6 +16,9 @@
 #include <asm/current.h>
 #include <public/nmi.h>
 #include <public/version.h>
+#ifdef CONFIG_X86
+#include <asm/shared.h>
+#endif
 
 #ifndef COMPAT
 
@@ -257,7 +260,7 @@ long register_guest_nmi_callback(unsigne
      * If no handler was registered we can 'lose the NMI edge'. Re-assert it
      * now.
      */
-    if ( d->shared_info->arch.nmi_reason != 0 )
+    if ( arch_get_nmi_reason(d) != 0 )
         set_bit(_VCPUF_nmi_pending, &v->vcpu_flags);
 #endif
 
Index: 2006-10-04/xen/common/keyhandler.c
===================================================================
--- 2006-10-04.orig/xen/common/keyhandler.c     2006-08-21 18:02:24.000000000 
+0200
+++ 2006-10-04/xen/common/keyhandler.c  2006-10-04 15:11:03.000000000 +0200
@@ -12,6 +12,7 @@
 #include <xen/softirq.h>
 #include <xen/domain.h>
 #include <xen/rangeset.h>
+#include <xen/compat.h>
 #include <asm/debugger.h>
 #include <asm/shadow.h>
 #include <asm/div64.h>
@@ -167,8 +168,8 @@ static void dump_domains(unsigned char k
                    v->vcpu_id, v->processor,
                    test_bit(_VCPUF_running, &v->vcpu_flags) ? 'T':'F',
                    v->vcpu_flags,
-                   v->vcpu_info->evtchn_upcall_pending, 
-                   v->vcpu_info->evtchn_upcall_mask);
+                   vcpu_info(v, evtchn_upcall_pending),
+                   vcpu_info(v, evtchn_upcall_mask));
             cpuset_print(cpuset, sizeof(cpuset), v->vcpu_dirty_cpumask);
             printk("dirty_cpus=%s ", cpuset);
             cpuset_print(cpuset, sizeof(cpuset), v->cpu_affinity);
@@ -176,11 +177,11 @@ static void dump_domains(unsigned char k
             printk("    Notifying guest (virq %d, port %d, stat %d/%d/%d)\n",
                    VIRQ_DEBUG, v->virq_to_evtchn[VIRQ_DEBUG],
                    test_bit(v->virq_to_evtchn[VIRQ_DEBUG], 
-                            d->shared_info->evtchn_pending),
+                            shared_info_addr(d, evtchn_pending)),
                    test_bit(v->virq_to_evtchn[VIRQ_DEBUG], 
-                            d->shared_info->evtchn_mask),
-                   test_bit(v->virq_to_evtchn[VIRQ_DEBUG]/BITS_PER_LONG, 
-                            &v->vcpu_info->evtchn_pending_sel));
+                            shared_info_addr(d, evtchn_mask)),
+                   
test_bit(v->virq_to_evtchn[VIRQ_DEBUG]/BITS_PER_GUEST_LONG(d),
+                            vcpu_info_addr(v, evtchn_pending_sel)));
             send_guest_vcpu_virq(v, VIRQ_DEBUG);
         }
     }
Index: 2006-10-04/xen/common/schedule.c
===================================================================
--- 2006-10-04.orig/xen/common/schedule.c       2006-10-04 08:49:30.000000000 
+0200
+++ 2006-10-04/xen/common/schedule.c    2006-10-04 15:11:03.000000000 +0200
@@ -277,10 +277,11 @@ static long do_block(void)
 
 static long do_poll(struct sched_poll *sched_poll)
 {
-    struct vcpu  *v = current;
-    evtchn_port_t port;
-    long          rc = 0;
-    unsigned int  i;
+    struct vcpu   *v = current;
+    struct domain *d = v->domain;
+    evtchn_port_t  port;
+    long           rc = 0;
+    unsigned int   i;
 
     /* Fairly arbitrary limit. */
     if ( sched_poll->nr_ports > 128 )
@@ -292,7 +293,7 @@ static long do_poll(struct sched_poll *s
     /* These operations must occur in order. */
     set_bit(_VCPUF_blocked, &v->vcpu_flags);
     set_bit(_VCPUF_polling, &v->vcpu_flags);
-    set_bit(_DOMF_polling, &v->domain->domain_flags);
+    set_bit(_DOMF_polling, &d->domain_flags);
 
     /* Check for events /after/ setting flags: avoids wakeup waiting race. */
     for ( i = 0; i < sched_poll->nr_ports; i++ )
@@ -302,18 +303,18 @@ static long do_poll(struct sched_poll *s
             goto out;
 
         rc = -EINVAL;
-        if ( port >= MAX_EVTCHNS )
+        if ( port >= MAX_EVTCHNS(d) )
             goto out;
 
         rc = 0;
-        if ( test_bit(port, v->domain->shared_info->evtchn_pending) )
+        if ( test_bit(port, shared_info_addr(d, evtchn_pending)) )
             goto out;
     }
 
     if ( sched_poll->timeout != 0 )
         set_timer(&v->poll_timer, sched_poll->timeout);
 
-    TRACE_2D(TRC_SCHED_BLOCK, v->domain->domain_id, v->vcpu_id);
+    TRACE_2D(TRC_SCHED_BLOCK, d->domain_id, v->vcpu_id);
     __enter_scheduler();
 
     stop_timer(&v->poll_timer);
Index: 2006-10-04/xen/include/Makefile
===================================================================
--- 2006-10-04.orig/xen/include/Makefile        2006-10-04 15:10:46.000000000 
+0200
+++ 2006-10-04/xen/include/Makefile     2006-10-04 15:11:03.000000000 +0200
@@ -29,6 +29,7 @@ compat/%.h: compat/%.i Makefile
        sed -e 's,__InClUdE__,#include,' \
            -e 's,"xen-compat.h",<public/xen-compat.h>,' \
            -e 
's,\(struct\|union\|enum\)[[:space:]]\+\(xen_\?\)\?\([[:alpha:]_]\),\1 
compat_\3,g' \
+           -e 's,@KeeP@,,g' \
            -e 's,_t\([^[:alnum:]_]\|$$\),_compat_t\1,g' \
            -e 's,\(8\|16\|32\|64\)_compat_t\([^[:alnum:]_]\|$$\),\1_t\2,g' \
            -e 
's,\(^\|[^[:alnum:]_]\)xen_\?\([[:alnum:]_]*\)_compat_t\([^[:alnum:]_]\|$$\),\1compat_\2_t\3,g'
 \
@@ -43,13 +44,15 @@ compat/%.h: compat/%.i Makefile
 compat/%.i: compat/%.c Makefile
        $(CPP) $(CFLAGS) $(cppflags-y) -o $@ $<
 
-compat/%.c: public/%.h Makefile
+compat/%.c: public/%.h xlat.lst Makefile
        mkdir -p $(@D)
        grep -v 'DEFINE_XEN_GUEST_HANDLE(long)' $< | \
        sed -e 's,^[[:space:]]*#[[:space:]]*include[[:space:]]\+,__InClUdE__ ,' 
\
            -e 
's,^[[:space:]]*#[[:space:]]*define[[:space:]]\+\([[:upper:]_]*_GUEST_HANDLE\),#define
 HIDE_\1,' \
            -e 
's,^[[:space:]]*#[[:space:]]*define[[:space:]]\+\([[:lower:]_]*_guest_handle\),#define
 hide_\1,' \
            -e 's,XEN_GUEST_HANDLE,COMPAT_HANDLE,g' \
+           $(foreach n,$(shell sed -n 
's,^[[:space:]]*?[[:space:]]\+\([[:alnum:]_]*\)[[:space:]].*,\1,p' xlat.lst), \
+                       -e 
's,\(struct\|union\)[[:space:]]\+\(xen_\?\)\?$n[[:space:]]\+\([[:alpha:]_]\),\1 
@KeeP@\2$n
\3,g') \
            >$@.new
        mv -f $@.new $@
 
Index: 2006-10-04/xen/include/asm-ia64/shared.h
===================================================================
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
+++ 2006-10-04/xen/include/asm-ia64/shared.h    2006-10-04 15:11:03.000000000 
+0200
@@ -0,0 +1,4 @@
+#ifndef __XEN_ASM_SHARED_H__
+#define __XEN_ASM_SHARED_H__
+
+#endif /* __XEN_ASM_SHARED_H__ */
Index: 2006-10-04/xen/include/asm-powerpc/shared.h
===================================================================
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
+++ 2006-10-04/xen/include/asm-powerpc/shared.h 2006-10-04 15:11:03.000000000 
+0200
@@ -0,0 +1,4 @@
+#ifndef __XEN_ASM_SHARED_H__
+#define __XEN_ASM_SHARED_H__
+
+#endif /* __XEN_ASM_SHARED_H__ */
Index: 2006-10-04/xen/include/asm-x86/shared.h
===================================================================
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
+++ 2006-10-04/xen/include/asm-x86/shared.h     2006-10-04 15:11:03.000000000 
+0200
@@ -0,0 +1,78 @@
+#ifndef __XEN_X86_SHARED_H__
+#define __XEN_X86_SHARED_H__
+
+#ifdef CONFIG_COMPAT
+
+#define nmi_reason(d) (!IS_COMPAT(d) ? \
+                       (void *)&(d)->shared_info->native.arch.nmi_reason : \
+                       (void *)&(d)->shared_info->compat.arch.nmi_reason)
+
+#define GET_SET_SHARED(type, field) \
+static inline type arch_get_##field(const struct domain *d) \
+{ \
+    return !IS_COMPAT(d) ? \
+           d->shared_info->native.arch.field : \
+           d->shared_info->compat.arch.field; \
+} \
+static inline void arch_set_##field(struct domain *d, \
+                                    type val) \
+{ \
+    if ( !IS_COMPAT(d) ) \
+        d->shared_info->native.arch.field = val; \
+    else \
+        d->shared_info->compat.arch.field = val; \
+}
+
+#define GET_SET_VCPU(type, field) \
+static inline type arch_get_##field(const struct vcpu *v) \
+{ \
+    return !IS_COMPAT(v->domain) ? \
+           v->vcpu_info->native.arch.field : \
+           v->vcpu_info->compat.arch.field; \
+} \
+static inline void arch_set_##field(struct vcpu *v, \
+                                    type val) \
+{ \
+    if ( !IS_COMPAT(v->domain) ) \
+        v->vcpu_info->native.arch.field = val; \
+    else \
+        v->vcpu_info->compat.arch.field = val; \
+}
+
+#else
+
+#define nmi_reason(d) ((void *)&(d)->shared_info->arch.nmi_reason)
+
+#define GET_SET_SHARED(type, field) \
+static inline type arch_get_##field(const struct domain *d) \
+{ \
+    return d->shared_info->arch.field; \
+} \
+static inline void arch_set_##field(struct domain *d, \
+                                    type val) \
+{ \
+    d->shared_info->arch.field = val; \
+}
+
+#define GET_SET_VCPU(type, field) \
+static inline type arch_get_##field(const struct vcpu *v) \
+{ \
+    return v->vcpu_info->arch.field; \
+} \
+static inline void arch_set_##field(struct vcpu *v, \
+                                    type val) \
+{ \
+    v->vcpu_info->arch.field = val; \
+}
+#endif
+
+GET_SET_SHARED(unsigned long, max_pfn)
+GET_SET_SHARED(xen_pfn_t, pfn_to_mfn_frame_list_list)
+GET_SET_SHARED(unsigned long, nmi_reason)
+
+GET_SET_VCPU(unsigned long, cr2)
+
+#undef GET_SET_VCPU
+#undef GET_SET_SHARED
+
+#endif /* __XEN_X86_SHARED_H__ */
Index: 2006-10-04/xen/include/asm-x86/compat.h
===================================================================
--- 2006-10-04.orig/xen/include/asm-x86/compat.h        2006-10-04 
15:09:52.000000000 +0200
+++ 2006-10-04/xen/include/asm-x86/compat.h     2006-10-04 15:11:03.000000000 
+0200
@@ -2,5 +2,7 @@
  * compat.h
  */
 
+#define COMPAT_BITS_PER_LONG 32
+
 typedef uint32_t compat_ptr_t;
 typedef unsigned long full_ptr_t;
Index: 2006-10-04/xen/include/asm-x86/event.h
===================================================================
--- 2006-10-04.orig/xen/include/asm-x86/event.h 2006-06-14 18:10:51.000000000 
+0200
+++ 2006-10-04/xen/include/asm-x86/event.h      2006-10-04 15:11:04.000000000 
+0200
@@ -9,6 +9,8 @@
 #ifndef __ASM_EVENT_H__
 #define __ASM_EVENT_H__
 
+#include <xen/shared.h>
+
 static inline void vcpu_kick(struct vcpu *v)
 {
     /*
@@ -28,7 +30,7 @@ static inline void vcpu_kick(struct vcpu
 
 static inline void vcpu_mark_events_pending(struct vcpu *v)
 {
-    if ( !test_and_set_bit(0, &v->vcpu_info->evtchn_upcall_pending) )
+    if ( !test_and_set_bit(0, &vcpu_info(v, evtchn_upcall_pending)) )
         vcpu_kick(v);
 }
 
@@ -36,23 +38,23 @@ static inline int local_events_need_deli
 {
     struct vcpu *v = current;
     /* Note: Bitwise operations result in fast code with no branches. */
-    return (!!v->vcpu_info->evtchn_upcall_pending &
-             !v->vcpu_info->evtchn_upcall_mask);
+    return (!!vcpu_info(v, evtchn_upcall_pending) &
+             !vcpu_info(v, evtchn_upcall_mask));
 }
 
 static inline int local_event_delivery_is_enabled(void)
 {
-    return !current->vcpu_info->evtchn_upcall_mask;
+    return !vcpu_info(current, evtchn_upcall_mask);
 }
 
 static inline void local_event_delivery_disable(void)
 {
-    current->vcpu_info->evtchn_upcall_mask = 1;
+    vcpu_info(current, evtchn_upcall_mask) = 1;
 }
 
 static inline void local_event_delivery_enable(void)
 {
-    current->vcpu_info->evtchn_upcall_mask = 0;
+    vcpu_info(current, evtchn_upcall_mask) = 0;
 }
 
 /* No arch specific virq definition now. Default to global. */
Index: 2006-10-04/xen/include/public/xen.h
===================================================================
--- 2006-10-04.orig/xen/include/public/xen.h    2006-09-21 11:09:00.000000000 
+0200
+++ 2006-10-04/xen/include/public/xen.h 2006-10-04 15:11:04.000000000 +0200
@@ -396,7 +396,9 @@ struct vcpu_info {
     struct arch_vcpu_info arch;
     struct vcpu_time_info time;
 }; /* 64 bytes (x86) */
+#ifndef __XEN__
 typedef struct vcpu_info vcpu_info_t;
+#endif
 
 /*
  * Xen/kernel shared data -- pointer provided in start_info.
@@ -454,7 +456,9 @@ struct shared_info {
     struct arch_shared_info arch;
 
 };
+#ifndef __XEN__
 typedef struct shared_info shared_info_t;
+#endif
 
 /*
  * Start-of-day memory layout for the initial domain (DOM0):
Index: 2006-10-04/xen/include/xen/compat.h
===================================================================
--- 2006-10-04.orig/xen/include/xen/compat.h    2006-10-04 15:09:52.000000000 
+0200
+++ 2006-10-04/xen/include/xen/compat.h 2006-10-04 15:11:04.000000000 +0200
@@ -147,6 +147,12 @@
 struct start_info;
 void xlat_start_info(struct start_info *, enum XLAT_start_info_console);
 
+#define BITS_PER_GUEST_LONG(d) (!IS_COMPAT(d) ? BITS_PER_LONG : 
COMPAT_BITS_PER_LONG)
+
+#else
+
+#define BITS_PER_GUEST_LONG(d) BITS_PER_LONG
+
 #endif
 
 #endif /* __XEN_COMPAT_H__ */
Index: 2006-10-04/xen/include/xen/sched.h
===================================================================
--- 2006-10-04.orig/xen/include/xen/sched.h     2006-10-04 15:03:07.000000000 
+0200
+++ 2006-10-04/xen/include/xen/sched.h  2006-10-04 15:11:04.000000000 +0200
@@ -6,6 +6,7 @@
 #include <xen/types.h>
 #include <xen/spinlock.h>
 #include <xen/smp.h>
+#include <xen/shared.h>
 #include <public/xen.h>
 #include <public/domctl.h>
 #include <public/vcpu.h>
@@ -23,9 +24,15 @@ extern rwlock_t domlist_lock;
 /* A global pointer to the initial domain (DOM0). */
 extern struct domain *dom0;
 
-#define MAX_EVTCHNS        NR_EVENT_CHANNELS
+#ifndef CONFIG_COMPAT
+#define MAX_EVTCHNS(d)     NR_EVENT_CHANNELS
+#else
+#define MAX_EVTCHNS(d)     (!IS_COMPAT(d) ? \
+                            NR_EVENT_CHANNELS : \
+                            sizeof(unsigned int) * sizeof(unsigned int) * 64)
+#endif
 #define EVTCHNS_PER_BUCKET 128
-#define NR_EVTCHN_BUCKETS  (MAX_EVTCHNS / EVTCHNS_PER_BUCKET)
+#define NR_EVTCHN_BUCKETS  (NR_EVENT_CHANNELS / EVTCHNS_PER_BUCKET)
 
 struct evtchn
 {
Index: 2006-10-04/xen/include/xen/shared.h
===================================================================
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
+++ 2006-10-04/xen/include/xen/shared.h 2006-10-04 15:11:04.000000000 +0200
@@ -0,0 +1,54 @@
+#ifndef __XEN_SHARED_H__
+#define __XEN_SHARED_H__
+
+#include <xen/config.h>
+
+#ifdef CONFIG_COMPAT
+
+#include <compat/xen.h>
+
+typedef union {
+    struct shared_info native;
+    struct compat_shared_info compat;
+} shared_info_t;
+
+#define __shared_info(d, s, field)      (*(!IS_COMPAT(d) ? \
+                                           &(s)->native.field : \
+                                           &(s)->compat.field))
+#define __shared_info_addr(d, s, field) (!IS_COMPAT(d) ? \
+                                         (void *)&(s)->native.field : \
+                                         (void *)&(s)->compat.field)
+
+#define shared_info(d, field)      __shared_info(d, (d)->shared_info, field)
+#define shared_info_addr(d, field) __shared_info_addr(d, (d)->shared_info, 
field)
+
+typedef union {
+    struct vcpu_info native;
+    struct compat_vcpu_info compat;
+} vcpu_info_t;
+
+#define vcpu_info(v, field)      (*(!IS_COMPAT((v)->domain) ? \
+                                    &(v)->vcpu_info->native.field : \
+                                    &(v)->vcpu_info->compat.field))
+#define vcpu_info_addr(v, field) (!IS_COMPAT((v)->domain) ? \
+                                  (void *)&(v)->vcpu_info->native.field : \
+                                  (void *)&(v)->vcpu_info->compat.field)
+
+#else
+
+typedef struct shared_info shared_info_t;
+
+#define __shared_info(d, s, field)      ((s)->field)
+#define __shared_info_addr(d, s, field) ((void *)&(s)->field)
+
+#define shared_info(d, field)           ((d)->shared_info->field)
+#define shared_info_addr(d, field)      ((void *)&(d)->shared_info->field)
+
+typedef struct vcpu_info vcpu_info_t;
+
+#define vcpu_info(v, field)             ((v)->vcpu_info->field)
+#define vcpu_info_addr(v, field)        ((void *)&(v)->vcpu_info->field)
+
+#endif
+
+#endif /* __XEN_SHARED_H__ */
Index: 2006-10-04/xen/include/xlat.lst
===================================================================
--- 2006-10-04.orig/xen/include/xlat.lst        2006-10-04 15:10:46.000000000 
+0200
+++ 2006-10-04/xen/include/xlat.lst     2006-10-04 15:11:04.000000000 +0200
@@ -3,3 +3,4 @@
 # ? - needs checking
 ?      dom0_vga_console_info           xen.h
 !      start_info                      xen.h
+?      vcpu_time_info                  xen.h


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


 


Rackspace

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