ia64/xen-unstable

changeset 13292:4c8f157a3a47

Handle shared info (having different layout for native and compatibility
mode guests) accesses.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Emmanuel Ackaouy <ack@xensource.com>
date Fri Jan 05 17:34:29 2007 +0000 (2007-01-05)
parents 4a164bf1edfc
children f632c0c36976
files xen/arch/x86/crash.c xen/arch/x86/domain.c xen/arch/x86/domain_build.c xen/arch/x86/irq.c xen/arch/x86/mm/shadow/common.c xen/arch/x86/setup.c xen/arch/x86/time.c xen/arch/x86/traps.c xen/arch/x86/x86_64/asm-offsets.c xen/arch/x86/x86_64/compat/entry.S xen/arch/x86/x86_64/compat/traps.c xen/arch/x86/x86_64/traps.c xen/common/compat/xlat.c xen/common/domain.c xen/common/event_channel.c xen/common/kernel.c xen/common/keyhandler.c xen/common/schedule.c xen/include/Makefile xen/include/asm-ia64/shared.h xen/include/asm-powerpc/shared.h xen/include/asm-x86/compat.h xen/include/asm-x86/event.h xen/include/asm-x86/shared.h xen/include/public/xen.h xen/include/xen/compat.h xen/include/xen/sched.h xen/include/xen/shared.h xen/include/xlat.lst
line diff
     1.1 --- a/xen/arch/x86/crash.c	Fri Jan 05 17:34:28 2007 +0000
     1.2 +++ b/xen/arch/x86/crash.c	Fri Jan 05 17:34:29 2007 +0000
     1.3 @@ -25,6 +25,7 @@
     1.4  #include <xen/kexec.h>
     1.5  #include <xen/sched.h>
     1.6  #include <public/xen.h>
     1.7 +#include <asm/shared.h>
     1.8  #include <asm/hvm/hvm.h>
     1.9  
    1.10  static atomic_t waiting_for_crash_ipi;
    1.11 @@ -103,7 +104,7 @@ void machine_crash_shutdown(void)
    1.12  
    1.13      info = kexec_crash_save_info();
    1.14      info->dom0_pfn_to_mfn_frame_list_list =
    1.15 -        dom0->shared_info->arch.pfn_to_mfn_frame_list_list;
    1.16 +        arch_get_pfn_to_mfn_frame_list_list(dom0);
    1.17  }
    1.18  
    1.19  /*
     2.1 --- a/xen/arch/x86/domain.c	Fri Jan 05 17:34:28 2007 +0000
     2.2 +++ b/xen/arch/x86/domain.c	Fri Jan 05 17:34:29 2007 +0000
     2.3 @@ -534,10 +534,10 @@ static void load_segments(struct vcpu *n
     2.4  
     2.5              /* CS longword also contains full evtchn_upcall_mask. */
     2.6              cs_and_mask = (unsigned short)regs->cs |
     2.7 -                ((unsigned int)n->vcpu_info->evtchn_upcall_mask << 16);
     2.8 +                ((unsigned int)vcpu_info(n, evtchn_upcall_mask) << 16);
     2.9              /* Fold upcall mask into RFLAGS.IF. */
    2.10              eflags  = regs->_eflags & ~X86_EFLAGS_IF;
    2.11 -            eflags |= !n->vcpu_info->evtchn_upcall_mask << 9;
    2.12 +            eflags |= !vcpu_info(n, evtchn_upcall_mask) << 9;
    2.13  
    2.14              if ( !ring_1(regs) )
    2.15              {
    2.16 @@ -562,7 +562,7 @@ static void load_segments(struct vcpu *n
    2.17  
    2.18              if ( test_bit(_VGCF_failsafe_disables_events,
    2.19                            &n->arch.guest_context.flags) )
    2.20 -                n->vcpu_info->evtchn_upcall_mask = 1;
    2.21 +                vcpu_info(n, evtchn_upcall_mask) = 1;
    2.22  
    2.23              regs->entry_vector  = TRAP_syscall;
    2.24              regs->_eflags      &= 0xFFFCBEFFUL;
    2.25 @@ -580,11 +580,11 @@ static void load_segments(struct vcpu *n
    2.26  
    2.27          /* CS longword also contains full evtchn_upcall_mask. */
    2.28          cs_and_mask = (unsigned long)regs->cs |
    2.29 -            ((unsigned long)n->vcpu_info->evtchn_upcall_mask << 32);
    2.30 +            ((unsigned long)vcpu_info(n, evtchn_upcall_mask) << 32);
    2.31  
    2.32          /* Fold upcall mask into RFLAGS.IF. */
    2.33          rflags  = regs->rflags & ~X86_EFLAGS_IF;
    2.34 -        rflags |= !n->vcpu_info->evtchn_upcall_mask << 9;
    2.35 +        rflags |= !vcpu_info(n, evtchn_upcall_mask) << 9;
    2.36  
    2.37          if ( put_user(regs->ss,            rsp- 1) |
    2.38               put_user(regs->rsp,           rsp- 2) |
    2.39 @@ -605,7 +605,7 @@ static void load_segments(struct vcpu *n
    2.40  
    2.41          if ( test_bit(_VGCF_failsafe_disables_events,
    2.42                        &n->arch.guest_context.flags) )
    2.43 -            n->vcpu_info->evtchn_upcall_mask = 1;
    2.44 +            vcpu_info(n, evtchn_upcall_mask) = 1;
    2.45  
    2.46          regs->entry_vector  = TRAP_syscall;
    2.47          regs->rflags       &= ~(X86_EFLAGS_AC|X86_EFLAGS_VM|X86_EFLAGS_RF|
     3.1 --- a/xen/arch/x86/domain_build.c	Fri Jan 05 17:34:28 2007 +0000
     3.2 +++ b/xen/arch/x86/domain_build.c	Fri Jan 05 17:34:29 2007 +0000
     3.3 @@ -328,6 +328,7 @@ int construct_dom0(struct domain *d,
     3.4          l1_pgentry_t gdt_l1e;
     3.5  
     3.6          set_bit(_DOMF_compat, &d->domain_flags);
     3.7 +        v->vcpu_info = (void *)&d->shared_info->compat.vcpu_info[0];
     3.8  
     3.9          if ( nr_pages != (unsigned int)nr_pages )
    3.10              nr_pages = UINT_MAX;
    3.11 @@ -730,7 +731,7 @@ int construct_dom0(struct domain *d,
    3.12  
    3.13      /* Mask all upcalls... */
    3.14      for ( i = 0; i < MAX_VIRT_CPUS; i++ )
    3.15 -        d->shared_info->vcpu_info[i].evtchn_upcall_mask = 1;
    3.16 +        shared_info(d, vcpu_info[i].evtchn_upcall_mask) = 1;
    3.17  
    3.18      if ( opt_dom0_max_vcpus == 0 )
    3.19          opt_dom0_max_vcpus = num_online_cpus();
    3.20 @@ -738,6 +739,8 @@ int construct_dom0(struct domain *d,
    3.21          opt_dom0_max_vcpus = num_online_cpus();
    3.22      if ( opt_dom0_max_vcpus > MAX_VIRT_CPUS )
    3.23          opt_dom0_max_vcpus = MAX_VIRT_CPUS;
    3.24 +    if ( opt_dom0_max_vcpus > BITS_PER_GUEST_LONG(d) )
    3.25 +        opt_dom0_max_vcpus = BITS_PER_GUEST_LONG(d);
    3.26      printk("Dom0 has maximum %u VCPUs\n", opt_dom0_max_vcpus);
    3.27  
    3.28      for ( i = 1; i < opt_dom0_max_vcpus; i++ )
     4.1 --- a/xen/arch/x86/irq.c	Fri Jan 05 17:34:28 2007 +0000
     4.2 +++ b/xen/arch/x86/irq.c	Fri Jan 05 17:34:29 2007 +0000
     4.3 @@ -13,6 +13,7 @@
     4.4  #include <xen/perfc.h>
     4.5  #include <xen/sched.h>
     4.6  #include <xen/keyhandler.h>
     4.7 +#include <xen/compat.h>
     4.8  #include <asm/current.h>
     4.9  #include <asm/smpboot.h>
    4.10  
    4.11 @@ -332,7 +333,7 @@ int pirq_guest_unmask(struct domain *d)
    4.12            irq < NR_IRQS;
    4.13            irq = find_next_bit(d->pirq_mask, NR_IRQS, irq+1) )
    4.14      {
    4.15 -        if ( !test_bit(d->pirq_to_evtchn[irq], s->evtchn_mask) )
    4.16 +        if ( !test_bit(d->pirq_to_evtchn[irq], __shared_info_addr(d, s, evtchn_mask)) )
    4.17              __pirq_guest_eoi(d, irq);
    4.18      }
    4.19  
    4.20 @@ -624,14 +625,13 @@ static void dump_irqs(unsigned char key)
    4.21                  printk("%u(%c%c%c%c)",
    4.22                         d->domain_id,
    4.23                         (test_bit(d->pirq_to_evtchn[irq],
    4.24 -                                 d->shared_info->evtchn_pending) ?
    4.25 +                                 shared_info_addr(d, evtchn_pending)) ?
    4.26                          'P' : '-'),
    4.27 -                       (test_bit(d->pirq_to_evtchn[irq]/BITS_PER_LONG,
    4.28 -                                 &d->shared_info->vcpu_info[0].
    4.29 -                                 evtchn_pending_sel) ?
    4.30 +                       (test_bit(d->pirq_to_evtchn[irq]/BITS_PER_GUEST_LONG(d),
    4.31 +                                 vcpu_info_addr(d->vcpu[0], evtchn_pending_sel)) ?
    4.32                          'S' : '-'),
    4.33                         (test_bit(d->pirq_to_evtchn[irq],
    4.34 -                                 d->shared_info->evtchn_mask) ?
    4.35 +                                 shared_info_addr(d, evtchn_mask)) ?
    4.36                          'M' : '-'),
    4.37                         (test_bit(irq, d->pirq_mask) ?
    4.38                          'M' : '-'));
     5.1 --- a/xen/arch/x86/mm/shadow/common.c	Fri Jan 05 17:34:28 2007 +0000
     5.2 +++ b/xen/arch/x86/mm/shadow/common.c	Fri Jan 05 17:34:29 2007 +0000
     5.3 @@ -36,6 +36,7 @@
     5.4  #include <asm/current.h>
     5.5  #include <asm/flushtlb.h>
     5.6  #include <asm/shadow.h>
     5.7 +#include <asm/shared.h>
     5.8  #include "private.h"
     5.9  
    5.10  
    5.11 @@ -2917,7 +2918,7 @@ sh_alloc_log_dirty_bitmap(struct domain 
    5.12  {
    5.13      ASSERT(d->arch.shadow.dirty_bitmap == NULL);
    5.14      d->arch.shadow.dirty_bitmap_size =
    5.15 -        (d->shared_info->arch.max_pfn + (BITS_PER_LONG - 1)) &
    5.16 +        (arch_get_max_pfn(d) + (BITS_PER_LONG - 1)) &
    5.17          ~(BITS_PER_LONG - 1);
    5.18      d->arch.shadow.dirty_bitmap =
    5.19          xmalloc_array(unsigned long,
     6.1 --- a/xen/arch/x86/setup.c	Fri Jan 05 17:34:28 2007 +0000
     6.2 +++ b/xen/arch/x86/setup.c	Fri Jan 05 17:34:29 2007 +0000
     6.3 @@ -548,14 +548,13 @@ void __init __start_xen(multiboot_info_t
     6.4  
     6.5      BUILD_BUG_ON(sizeof(start_info_t) > PAGE_SIZE);
     6.6      BUILD_BUG_ON(sizeof(shared_info_t) > PAGE_SIZE);
     6.7 -    BUILD_BUG_ON(sizeof(vcpu_info_t) != 64);
     6.8 +    BUILD_BUG_ON(sizeof(struct vcpu_info) != 64);
     6.9  
    6.10  #ifdef CONFIG_COMPAT
    6.11      BUILD_BUG_ON(sizeof(((struct compat_platform_op *)0)->u) !=
    6.12                   sizeof(((struct compat_platform_op *)0)->u.pad));
    6.13      BUILD_BUG_ON(sizeof(start_info_compat_t) > PAGE_SIZE);
    6.14 -    BUILD_BUG_ON(sizeof(shared_info_compat_t) > PAGE_SIZE);
    6.15 -    BUILD_BUG_ON(sizeof(vcpu_info_compat_t) != 64);
    6.16 +    BUILD_BUG_ON(sizeof(struct compat_vcpu_info) != 64);
    6.17  #endif
    6.18  
    6.19      /* Check definitions in public headers match internal defs. */
     7.1 --- a/xen/arch/x86/time.c	Fri Jan 05 17:34:28 2007 +0000
     7.2 +++ b/xen/arch/x86/time.c	Fri Jan 05 17:34:29 2007 +0000
     7.3 @@ -676,7 +676,7 @@ static inline void __update_vcpu_system_
     7.4      struct vcpu_time_info *u;
     7.5  
     7.6      t = &this_cpu(cpu_time);
     7.7 -    u = &v->vcpu_info->time;
     7.8 +    u = &vcpu_info(v, time);
     7.9  
    7.10      version_update_begin(&u->version);
    7.11  
    7.12 @@ -690,7 +690,7 @@ static inline void __update_vcpu_system_
    7.13  
    7.14  void update_vcpu_system_time(struct vcpu *v)
    7.15  {
    7.16 -    if ( v->vcpu_info->time.tsc_timestamp !=
    7.17 +    if ( vcpu_info(v, time.tsc_timestamp) !=
    7.18           this_cpu(cpu_time).local_tsc_stamp )
    7.19          __update_vcpu_system_time(v);
    7.20  }
    7.21 @@ -698,10 +698,10 @@ void update_vcpu_system_time(struct vcpu
    7.22  void update_domain_wallclock_time(struct domain *d)
    7.23  {
    7.24      spin_lock(&wc_lock);
    7.25 -    version_update_begin(&d->shared_info->wc_version);
    7.26 -    d->shared_info->wc_sec  = wc_sec + d->time_offset_seconds;
    7.27 -    d->shared_info->wc_nsec = wc_nsec;
    7.28 -    version_update_end(&d->shared_info->wc_version);
    7.29 +    version_update_begin(&shared_info(d, wc_version));
    7.30 +    shared_info(d, wc_sec)  = wc_sec + d->time_offset_seconds;
    7.31 +    shared_info(d, wc_nsec) = wc_nsec;
    7.32 +    version_update_end(&shared_info(d, wc_version));
    7.33      spin_unlock(&wc_lock);
    7.34  }
    7.35  
     8.1 --- a/xen/arch/x86/traps.c	Fri Jan 05 17:34:28 2007 +0000
     8.2 +++ b/xen/arch/x86/traps.c	Fri Jan 05 17:34:29 2007 +0000
     8.3 @@ -58,6 +58,7 @@
     8.4  #include <asm/i387.h>
     8.5  #include <asm/debugger.h>
     8.6  #include <asm/msr.h>
     8.7 +#include <asm/shared.h>
     8.8  #include <asm/x86_emulate.h>
     8.9  #include <asm/hvm/vpt.h>
    8.10  
    8.11 @@ -665,7 +666,7 @@ void propagate_page_fault(unsigned long 
    8.12      struct trap_bounce *tb = &v->arch.trap_bounce;
    8.13  
    8.14      v->arch.guest_context.ctrlreg[2] = addr;
    8.15 -    v->vcpu_info->arch.cr2           = addr;
    8.16 +    arch_set_cr2(v, addr);
    8.17  
    8.18      /* Re-set error_code.user flag appropriately for the guest. */
    8.19      error_code &= ~PFEC_user_mode;
    8.20 @@ -1390,7 +1391,7 @@ static int emulate_privileged_op(struct 
    8.21  
    8.22          case 2: /* Write CR2 */
    8.23              v->arch.guest_context.ctrlreg[2] = *reg;
    8.24 -            v->vcpu_info->arch.cr2           = *reg;
    8.25 +            arch_set_cr2(v, *reg);
    8.26              break;
    8.27  
    8.28          case 3: /* Write CR3 */
    8.29 @@ -1601,7 +1602,7 @@ static void nmi_dom0_report(unsigned int
    8.30      if ( ((d = dom0) == NULL) || ((v = d->vcpu[0]) == NULL) )
    8.31          return;
    8.32  
    8.33 -    set_bit(reason_idx, &d->shared_info->arch.nmi_reason);
    8.34 +    set_bit(reason_idx, nmi_reason(d));
    8.35  
    8.36      if ( test_and_set_bit(_VCPUF_nmi_pending, &v->vcpu_flags) )
    8.37          raise_softirq(NMI_SOFTIRQ); /* not safe to wake up a vcpu here */
     9.1 --- a/xen/arch/x86/x86_64/asm-offsets.c	Fri Jan 05 17:34:28 2007 +0000
     9.2 +++ b/xen/arch/x86/x86_64/asm-offsets.c	Fri Jan 05 17:34:29 2007 +0000
     9.3 @@ -7,6 +7,9 @@
     9.4  #include <xen/config.h>
     9.5  #include <xen/perfc.h>
     9.6  #include <xen/sched.h>
     9.7 +#ifdef CONFIG_COMPAT
     9.8 +#include <compat/xen.h>
     9.9 +#endif
    9.10  #include <asm/fixmap.h>
    9.11  #include <asm/hardirq.h>
    9.12  
    9.13 @@ -96,10 +99,16 @@ void __dummy__(void)
    9.14      OFFSET(VMCB_tsc_offset, struct vmcb_struct, tsc_offset);
    9.15      BLANK();
    9.16  
    9.17 -    OFFSET(VCPUINFO_upcall_pending, vcpu_info_t, evtchn_upcall_pending);
    9.18 -    OFFSET(VCPUINFO_upcall_mask, vcpu_info_t, evtchn_upcall_mask);
    9.19 +    OFFSET(VCPUINFO_upcall_pending, struct vcpu_info, evtchn_upcall_pending);
    9.20 +    OFFSET(VCPUINFO_upcall_mask, struct vcpu_info, evtchn_upcall_mask);
    9.21      BLANK();
    9.22  
    9.23 +#ifdef CONFIG_COMPAT
    9.24 +    OFFSET(COMPAT_VCPUINFO_upcall_pending, struct compat_vcpu_info, evtchn_upcall_pending);
    9.25 +    OFFSET(COMPAT_VCPUINFO_upcall_mask, struct compat_vcpu_info, evtchn_upcall_mask);
    9.26 +    BLANK();
    9.27 +#endif
    9.28 +
    9.29      OFFSET(CPUINFO_current_vcpu, struct cpu_info, current_vcpu);
    9.30      DEFINE(CPUINFO_sizeof, sizeof(struct cpu_info));
    9.31      BLANK();
    10.1 --- a/xen/arch/x86/x86_64/compat/entry.S	Fri Jan 05 17:34:28 2007 +0000
    10.2 +++ b/xen/arch/x86/x86_64/compat/entry.S	Fri Jan 05 17:34:29 2007 +0000
    10.3 @@ -69,9 +69,9 @@ compat_test_all_events:
    10.4          jc    compat_process_nmi
    10.5  compat_test_guest_events:
    10.6          movq  VCPU_vcpu_info(%rbx),%rax
    10.7 -        testb $0xFF,VCPUINFO_upcall_mask(%rax)
    10.8 +        testb $0xFF,COMPAT_VCPUINFO_upcall_mask(%rax)
    10.9          jnz   compat_restore_all_guest
   10.10 -        testb $0xFF,VCPUINFO_upcall_pending(%rax)
   10.11 +        testb $0xFF,COMPAT_VCPUINFO_upcall_pending(%rax)
   10.12          jz    compat_restore_all_guest
   10.13  /*compat_process_guest_events:*/
   10.14          sti
   10.15 @@ -189,10 +189,10 @@ 2:
   10.16          movb  TRAPBOUNCE_flags(%rdx),%cl
   10.17          subl  $3*4,%esi
   10.18          movq  VCPU_vcpu_info(%rbx),%rax
   10.19 -        pushq VCPUINFO_upcall_mask(%rax)
   10.20 +        pushq COMPAT_VCPUINFO_upcall_mask(%rax)
   10.21          testb $TBF_INTERRUPT,%cl
   10.22          setnz %ch                       # TBF_INTERRUPT -> set upcall mask
   10.23 -        orb   %ch,VCPUINFO_upcall_mask(%rax)
   10.24 +        orb   %ch,COMPAT_VCPUINFO_upcall_mask(%rax)
   10.25          popq  %rax
   10.26          shll  $16,%eax                  # Bits 16-23: saved_upcall_mask
   10.27          movw  UREGS_cs+8(%rsp),%ax      # Bits  0-15: CS
    11.1 --- a/xen/arch/x86/x86_64/compat/traps.c	Fri Jan 05 17:34:28 2007 +0000
    11.2 +++ b/xen/arch/x86/x86_64/compat/traps.c	Fri Jan 05 17:34:29 2007 +0000
    11.3 @@ -118,7 +118,7 @@ unsigned int compat_iret(void)
    11.4      clear_bit(_VCPUF_nmi_masked, &current->vcpu_flags);
    11.5  
    11.6      /* Restore upcall mask from supplied EFLAGS.IF. */
    11.7 -    current->vcpu_info->evtchn_upcall_mask = !(eflags & X86_EFLAGS_IF);
    11.8 +    vcpu_info(current, evtchn_upcall_mask) = !(eflags & X86_EFLAGS_IF);
    11.9  
   11.10      /*
   11.11       * The hypercall exit path will overwrite EAX with this return
    12.1 --- a/xen/arch/x86/x86_64/traps.c	Fri Jan 05 17:34:28 2007 +0000
    12.2 +++ b/xen/arch/x86/x86_64/traps.c	Fri Jan 05 17:34:29 2007 +0000
    12.3 @@ -17,6 +17,7 @@
    12.4  #include <asm/msr.h>
    12.5  #include <asm/page.h>
    12.6  #include <asm/shadow.h>
    12.7 +#include <asm/shared.h>
    12.8  #include <asm/hvm/hvm.h>
    12.9  #include <asm/hvm/support.h>
   12.10  
   12.11 @@ -52,7 +53,7 @@ void show_registers(struct cpu_user_regs
   12.12          if ( guest_mode(regs) )
   12.13          {
   12.14              context = "guest";
   12.15 -            fault_crs[2] = current->vcpu_info->arch.cr2;
   12.16 +            fault_crs[2] = arch_get_cr2(current);
   12.17          }
   12.18          else
   12.19          {
   12.20 @@ -234,7 +235,7 @@ unsigned long do_iret(void)
   12.21      clear_bit(_VCPUF_nmi_masked, &current->vcpu_flags);
   12.22  
   12.23      /* Restore upcall mask from supplied EFLAGS.IF. */
   12.24 -    current->vcpu_info->evtchn_upcall_mask = !(iret_saved.rflags & EF_IE);
   12.25 +    vcpu_info(current, evtchn_upcall_mask) = !(iret_saved.rflags & EF_IE);
   12.26  
   12.27      /* Saved %rax gets written back to regs->rax in entry.S. */
   12.28      return iret_saved.rax;
    13.1 --- a/xen/common/compat/xlat.c	Fri Jan 05 17:34:28 2007 +0000
    13.2 +++ b/xen/common/compat/xlat.c	Fri Jan 05 17:34:29 2007 +0000
    13.3 @@ -21,6 +21,10 @@ void xlat_start_info(struct start_info *
    13.4  CHECK_dom0_vga_console_info;
    13.5  #undef dom0_vga_console_info
    13.6  
    13.7 +#define xen_vcpu_time_info vcpu_time_info
    13.8 +CHECK_vcpu_time_info;
    13.9 +#undef xen_vcpu_time_info
   13.10 +
   13.11  /*
   13.12   * Local variables:
   13.13   * mode: C
    14.1 --- a/xen/common/domain.c	Fri Jan 05 17:34:28 2007 +0000
    14.2 +++ b/xen/common/domain.c	Fri Jan 05 17:34:29 2007 +0000
    14.3 @@ -90,7 +90,7 @@ struct vcpu *alloc_vcpu(
    14.4  
    14.5      v->domain = d;
    14.6      v->vcpu_id = vcpu_id;
    14.7 -    v->vcpu_info = &d->shared_info->vcpu_info[vcpu_id];
    14.8 +    v->vcpu_info = shared_info_addr(d, vcpu_info[vcpu_id]);
    14.9      spin_lock_init(&v->pause_lock);
   14.10  
   14.11      v->runstate.state = is_idle_vcpu(v) ? RUNSTATE_running : RUNSTATE_offline;
    15.1 --- a/xen/common/event_channel.c	Fri Jan 05 17:34:28 2007 +0000
    15.2 +++ b/xen/common/event_channel.c	Fri Jan 05 17:34:29 2007 +0000
    15.3 @@ -23,6 +23,7 @@
    15.4  #include <xen/event.h>
    15.5  #include <xen/irq.h>
    15.6  #include <xen/iocap.h>
    15.7 +#include <xen/compat.h>
    15.8  #include <xen/guest_access.h>
    15.9  #include <asm/current.h>
   15.10  
   15.11 @@ -33,7 +34,7 @@
   15.12  #define bucket_from_port(d,p) \
   15.13      ((d)->evtchn[(p)/EVTCHNS_PER_BUCKET])
   15.14  #define port_is_valid(d,p)    \
   15.15 -    (((p) >= 0) && ((p) < MAX_EVTCHNS) && \
   15.16 +    (((p) >= 0) && ((p) < MAX_EVTCHNS(d)) && \
   15.17       (bucket_from_port(d,p) != NULL))
   15.18  #define evtchn_from_port(d,p) \
   15.19      (&(bucket_from_port(d,p))[(p)&(EVTCHNS_PER_BUCKET-1)])
   15.20 @@ -82,7 +83,7 @@ static int get_free_port(struct domain *
   15.21          if ( evtchn_from_port(d, port)->state == ECS_FREE )
   15.22              return port;
   15.23  
   15.24 -    if ( port == MAX_EVTCHNS )
   15.25 +    if ( port == MAX_EVTCHNS(d) )
   15.26          return -ENOSPC;
   15.27  
   15.28      chn = xmalloc_array(struct evtchn, EVTCHNS_PER_BUCKET);
   15.29 @@ -517,12 +518,12 @@ void evtchn_set_pending(struct vcpu *v, 
   15.30       * others may require explicit memory barriers.
   15.31       */
   15.32  
   15.33 -    if ( test_and_set_bit(port, s->evtchn_pending) )
   15.34 +    if ( test_and_set_bit(port, __shared_info_addr(d, s, evtchn_pending)) )
   15.35          return;
   15.36  
   15.37 -    if ( !test_bit        (port, s->evtchn_mask) &&
   15.38 -         !test_and_set_bit(port / BITS_PER_LONG,
   15.39 -                           &v->vcpu_info->evtchn_pending_sel) )
   15.40 +    if ( !test_bit        (port, __shared_info_addr(d, s, evtchn_mask)) &&
   15.41 +         !test_and_set_bit(port / BITS_PER_GUEST_LONG(d),
   15.42 +                           vcpu_info_addr(v, evtchn_pending_sel)) )
   15.43      {
   15.44          vcpu_mark_events_pending(v);
   15.45      }
   15.46 @@ -720,10 +721,10 @@ static long evtchn_unmask(evtchn_unmask_
   15.47       * These operations must happen in strict order. Based on
   15.48       * include/xen/event.h:evtchn_set_pending(). 
   15.49       */
   15.50 -    if ( test_and_clear_bit(port, s->evtchn_mask) &&
   15.51 -         test_bit          (port, s->evtchn_pending) &&
   15.52 -         !test_and_set_bit (port / BITS_PER_LONG,
   15.53 -                            &v->vcpu_info->evtchn_pending_sel) )
   15.54 +    if ( test_and_clear_bit(port, __shared_info_addr(d, s, evtchn_mask)) &&
   15.55 +         test_bit          (port, __shared_info_addr(d, s, evtchn_pending)) &&
   15.56 +         !test_and_set_bit (port / BITS_PER_GUEST_LONG(d),
   15.57 +                            vcpu_info_addr(v, evtchn_pending_sel)) )
   15.58      {
   15.59          vcpu_mark_events_pending(v);
   15.60      }
    16.1 --- a/xen/common/kernel.c	Fri Jan 05 17:34:28 2007 +0000
    16.2 +++ b/xen/common/kernel.c	Fri Jan 05 17:34:29 2007 +0000
    16.3 @@ -16,6 +16,9 @@
    16.4  #include <asm/current.h>
    16.5  #include <public/nmi.h>
    16.6  #include <public/version.h>
    16.7 +#ifdef CONFIG_X86
    16.8 +#include <asm/shared.h>
    16.9 +#endif
   16.10  
   16.11  #ifndef COMPAT
   16.12  
   16.13 @@ -253,7 +256,7 @@ long register_guest_nmi_callback(unsigne
   16.14       * If no handler was registered we can 'lose the NMI edge'. Re-assert it
   16.15       * now.
   16.16       */
   16.17 -    if ( d->shared_info->arch.nmi_reason != 0 )
   16.18 +    if ( arch_get_nmi_reason(d) != 0 )
   16.19          set_bit(_VCPUF_nmi_pending, &v->vcpu_flags);
   16.20  #endif
   16.21  
    17.1 --- a/xen/common/keyhandler.c	Fri Jan 05 17:34:28 2007 +0000
    17.2 +++ b/xen/common/keyhandler.c	Fri Jan 05 17:34:29 2007 +0000
    17.3 @@ -12,6 +12,7 @@
    17.4  #include <xen/softirq.h>
    17.5  #include <xen/domain.h>
    17.6  #include <xen/rangeset.h>
    17.7 +#include <xen/compat.h>
    17.8  #include <asm/debugger.h>
    17.9  #include <asm/shadow.h>
   17.10  #include <asm/div64.h>
   17.11 @@ -171,8 +172,8 @@ static void dump_domains(unsigned char k
   17.12                     v->vcpu_id, v->processor,
   17.13                     test_bit(_VCPUF_running, &v->vcpu_flags) ? 'T':'F',
   17.14                     v->vcpu_flags,
   17.15 -                   v->vcpu_info->evtchn_upcall_pending, 
   17.16 -                   v->vcpu_info->evtchn_upcall_mask);
   17.17 +                   vcpu_info(v, evtchn_upcall_pending),
   17.18 +                   vcpu_info(v, evtchn_upcall_mask));
   17.19              cpuset_print(cpuset, sizeof(cpuset), v->vcpu_dirty_cpumask);
   17.20              printk("dirty_cpus=%s ", cpuset);
   17.21              cpuset_print(cpuset, sizeof(cpuset), v->cpu_affinity);
   17.22 @@ -181,11 +182,11 @@ static void dump_domains(unsigned char k
   17.23              printk("    Notifying guest (virq %d, port %d, stat %d/%d/%d)\n",
   17.24                     VIRQ_DEBUG, v->virq_to_evtchn[VIRQ_DEBUG],
   17.25                     test_bit(v->virq_to_evtchn[VIRQ_DEBUG], 
   17.26 -                            d->shared_info->evtchn_pending),
   17.27 +                            shared_info_addr(d, evtchn_pending)),
   17.28                     test_bit(v->virq_to_evtchn[VIRQ_DEBUG], 
   17.29 -                            d->shared_info->evtchn_mask),
   17.30 -                   test_bit(v->virq_to_evtchn[VIRQ_DEBUG]/BITS_PER_LONG, 
   17.31 -                            &v->vcpu_info->evtchn_pending_sel));
   17.32 +                            shared_info_addr(d, evtchn_mask)),
   17.33 +                   test_bit(v->virq_to_evtchn[VIRQ_DEBUG]/BITS_PER_GUEST_LONG(d),
   17.34 +                            vcpu_info_addr(v, evtchn_pending_sel)));
   17.35              send_guest_vcpu_virq(v, VIRQ_DEBUG);
   17.36          }
   17.37      }
    18.1 --- a/xen/common/schedule.c	Fri Jan 05 17:34:28 2007 +0000
    18.2 +++ b/xen/common/schedule.c	Fri Jan 05 17:34:29 2007 +0000
    18.3 @@ -277,10 +277,11 @@ static long do_block(void)
    18.4  
    18.5  static long do_poll(struct sched_poll *sched_poll)
    18.6  {
    18.7 -    struct vcpu  *v = current;
    18.8 -    evtchn_port_t port;
    18.9 -    long          rc = 0;
   18.10 -    unsigned int  i;
   18.11 +    struct vcpu   *v = current;
   18.12 +    struct domain *d = v->domain;
   18.13 +    evtchn_port_t  port;
   18.14 +    long           rc = 0;
   18.15 +    unsigned int   i;
   18.16  
   18.17      /* Fairly arbitrary limit. */
   18.18      if ( sched_poll->nr_ports > 128 )
   18.19 @@ -292,7 +293,7 @@ static long do_poll(struct sched_poll *s
   18.20      /* These operations must occur in order. */
   18.21      set_bit(_VCPUF_blocked, &v->vcpu_flags);
   18.22      set_bit(_VCPUF_polling, &v->vcpu_flags);
   18.23 -    set_bit(_DOMF_polling, &v->domain->domain_flags);
   18.24 +    set_bit(_DOMF_polling, &d->domain_flags);
   18.25  
   18.26      /* Check for events /after/ setting flags: avoids wakeup waiting race. */
   18.27      for ( i = 0; i < sched_poll->nr_ports; i++ )
   18.28 @@ -302,18 +303,18 @@ static long do_poll(struct sched_poll *s
   18.29              goto out;
   18.30  
   18.31          rc = -EINVAL;
   18.32 -        if ( port >= MAX_EVTCHNS )
   18.33 +        if ( port >= MAX_EVTCHNS(d) )
   18.34              goto out;
   18.35  
   18.36          rc = 0;
   18.37 -        if ( test_bit(port, v->domain->shared_info->evtchn_pending) )
   18.38 +        if ( test_bit(port, shared_info_addr(d, evtchn_pending)) )
   18.39              goto out;
   18.40      }
   18.41  
   18.42      if ( sched_poll->timeout != 0 )
   18.43          set_timer(&v->poll_timer, sched_poll->timeout);
   18.44  
   18.45 -    TRACE_2D(TRC_SCHED_BLOCK, v->domain->domain_id, v->vcpu_id);
   18.46 +    TRACE_2D(TRC_SCHED_BLOCK, d->domain_id, v->vcpu_id);
   18.47      raise_softirq(SCHEDULE_SOFTIRQ);
   18.48  
   18.49      return 0;
    19.1 --- a/xen/include/Makefile	Fri Jan 05 17:34:28 2007 +0000
    19.2 +++ b/xen/include/Makefile	Fri Jan 05 17:34:29 2007 +0000
    19.3 @@ -29,6 +29,7 @@ compat/%.h: compat/%.i Makefile
    19.4  	sed -e 's,__InClUdE__,#include,' \
    19.5  	    -e 's,"xen-compat.h",<public/xen-compat.h>,' \
    19.6  	    -e 's,\(struct\|union\|enum\)[[:space:]]\+\(xen_\?\)\?\([[:alpha:]_]\),\1 compat_\3,g' \
    19.7 +	    -e 's,@KeeP@,,g' \
    19.8  	    -e 's,_t\([^[:alnum:]_]\|$$\),_compat_t\1,g' \
    19.9  	    -e 's,\(8\|16\|32\|64\)_compat_t\([^[:alnum:]_]\|$$\),\1_t\2,g' \
   19.10  	    -e 's,\(^\|[^[:alnum:]_]\)xen_\?\([[:alnum:]_]*\)_compat_t\([^[:alnum:]_]\|$$\),\1compat_\2_t\3,g' \
   19.11 @@ -43,13 +44,15 @@ compat/%.h: compat/%.i Makefile
   19.12  compat/%.i: compat/%.c Makefile
   19.13  	$(CPP) $(CFLAGS) $(cppflags-y) -o $@ $<
   19.14  
   19.15 -compat/%.c: public/%.h Makefile
   19.16 +compat/%.c: public/%.h xlat.lst Makefile
   19.17  	mkdir -p $(@D)
   19.18  	grep -v 'DEFINE_XEN_GUEST_HANDLE(long)' $< | \
   19.19  	sed -e 's,^[[:space:]]*#[[:space:]]*include[[:space:]]\+,__InClUdE__ ,' \
   19.20  	    -e 's,^[[:space:]]*#[[:space:]]*define[[:space:]]\+\([[:upper:]_]*_GUEST_HANDLE\),#define HIDE_\1,' \
   19.21  	    -e 's,^[[:space:]]*#[[:space:]]*define[[:space:]]\+\([[:lower:]_]*_guest_handle\),#define hide_\1,' \
   19.22  	    -e 's,XEN_GUEST_HANDLE\(_[[:xdigit:]]\+\)\?,COMPAT_HANDLE,g' \
   19.23 +	    $(foreach n,$(shell sed -n 's,^[[:space:]]*?[[:space:]]\+\([[:alnum:]_]*\)[[:space:]].*,\1,p' xlat.lst), \
   19.24 +	                -e 's,\(struct\|union\)[[:space:]]\+\(xen_\?\)\?$n[[:space:]]\+\([[:alpha:]_]\),\1 @KeeP@\2$n \3,g') \
   19.25  	    >$@.new
   19.26  	mv -f $@.new $@
   19.27  
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/xen/include/asm-ia64/shared.h	Fri Jan 05 17:34:29 2007 +0000
    20.3 @@ -0,0 +1,4 @@
    20.4 +#ifndef __XEN_ASM_SHARED_H__
    20.5 +#define __XEN_ASM_SHARED_H__
    20.6 +
    20.7 +#endif /* __XEN_ASM_SHARED_H__ */
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/xen/include/asm-powerpc/shared.h	Fri Jan 05 17:34:29 2007 +0000
    21.3 @@ -0,0 +1,4 @@
    21.4 +#ifndef __XEN_ASM_SHARED_H__
    21.5 +#define __XEN_ASM_SHARED_H__
    21.6 +
    21.7 +#endif /* __XEN_ASM_SHARED_H__ */
    22.1 --- a/xen/include/asm-x86/compat.h	Fri Jan 05 17:34:28 2007 +0000
    22.2 +++ b/xen/include/asm-x86/compat.h	Fri Jan 05 17:34:29 2007 +0000
    22.3 @@ -2,5 +2,7 @@
    22.4   * compat.h
    22.5   */
    22.6  
    22.7 +#define COMPAT_BITS_PER_LONG 32
    22.8 +
    22.9  typedef uint32_t compat_ptr_t;
   22.10  typedef unsigned long full_ptr_t;
    23.1 --- a/xen/include/asm-x86/event.h	Fri Jan 05 17:34:28 2007 +0000
    23.2 +++ b/xen/include/asm-x86/event.h	Fri Jan 05 17:34:29 2007 +0000
    23.3 @@ -9,6 +9,8 @@
    23.4  #ifndef __ASM_EVENT_H__
    23.5  #define __ASM_EVENT_H__
    23.6  
    23.7 +#include <xen/shared.h>
    23.8 +
    23.9  static inline void vcpu_kick(struct vcpu *v)
   23.10  {
   23.11      /*
   23.12 @@ -28,7 +30,7 @@ static inline void vcpu_kick(struct vcpu
   23.13  
   23.14  static inline void vcpu_mark_events_pending(struct vcpu *v)
   23.15  {
   23.16 -    if ( !test_and_set_bit(0, &v->vcpu_info->evtchn_upcall_pending) )
   23.17 +    if ( !test_and_set_bit(0, &vcpu_info(v, evtchn_upcall_pending)) )
   23.18          vcpu_kick(v);
   23.19  }
   23.20  
   23.21 @@ -36,23 +38,23 @@ static inline int local_events_need_deli
   23.22  {
   23.23      struct vcpu *v = current;
   23.24      /* Note: Bitwise operations result in fast code with no branches. */
   23.25 -    return (!!v->vcpu_info->evtchn_upcall_pending &
   23.26 -             !v->vcpu_info->evtchn_upcall_mask);
   23.27 +    return (!!vcpu_info(v, evtchn_upcall_pending) &
   23.28 +             !vcpu_info(v, evtchn_upcall_mask));
   23.29  }
   23.30  
   23.31  static inline int local_event_delivery_is_enabled(void)
   23.32  {
   23.33 -    return !current->vcpu_info->evtchn_upcall_mask;
   23.34 +    return !vcpu_info(current, evtchn_upcall_mask);
   23.35  }
   23.36  
   23.37  static inline void local_event_delivery_disable(void)
   23.38  {
   23.39 -    current->vcpu_info->evtchn_upcall_mask = 1;
   23.40 +    vcpu_info(current, evtchn_upcall_mask) = 1;
   23.41  }
   23.42  
   23.43  static inline void local_event_delivery_enable(void)
   23.44  {
   23.45 -    current->vcpu_info->evtchn_upcall_mask = 0;
   23.46 +    vcpu_info(current, evtchn_upcall_mask) = 0;
   23.47  }
   23.48  
   23.49  /* No arch specific virq definition now. Default to global. */
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/xen/include/asm-x86/shared.h	Fri Jan 05 17:34:29 2007 +0000
    24.3 @@ -0,0 +1,78 @@
    24.4 +#ifndef __XEN_X86_SHARED_H__
    24.5 +#define __XEN_X86_SHARED_H__
    24.6 +
    24.7 +#ifdef CONFIG_COMPAT
    24.8 +
    24.9 +#define nmi_reason(d) (!IS_COMPAT(d) ? \
   24.10 +                       (void *)&(d)->shared_info->native.arch.nmi_reason : \
   24.11 +                       (void *)&(d)->shared_info->compat.arch.nmi_reason)
   24.12 +
   24.13 +#define GET_SET_SHARED(type, field) \
   24.14 +static inline type arch_get_##field(const struct domain *d) \
   24.15 +{ \
   24.16 +    return !IS_COMPAT(d) ? \
   24.17 +           d->shared_info->native.arch.field : \
   24.18 +           d->shared_info->compat.arch.field; \
   24.19 +} \
   24.20 +static inline void arch_set_##field(struct domain *d, \
   24.21 +                                    type val) \
   24.22 +{ \
   24.23 +    if ( !IS_COMPAT(d) ) \
   24.24 +        d->shared_info->native.arch.field = val; \
   24.25 +    else \
   24.26 +        d->shared_info->compat.arch.field = val; \
   24.27 +}
   24.28 +
   24.29 +#define GET_SET_VCPU(type, field) \
   24.30 +static inline type arch_get_##field(const struct vcpu *v) \
   24.31 +{ \
   24.32 +    return !IS_COMPAT(v->domain) ? \
   24.33 +           v->vcpu_info->native.arch.field : \
   24.34 +           v->vcpu_info->compat.arch.field; \
   24.35 +} \
   24.36 +static inline void arch_set_##field(struct vcpu *v, \
   24.37 +                                    type val) \
   24.38 +{ \
   24.39 +    if ( !IS_COMPAT(v->domain) ) \
   24.40 +        v->vcpu_info->native.arch.field = val; \
   24.41 +    else \
   24.42 +        v->vcpu_info->compat.arch.field = val; \
   24.43 +}
   24.44 +
   24.45 +#else
   24.46 +
   24.47 +#define nmi_reason(d) ((void *)&(d)->shared_info->arch.nmi_reason)
   24.48 +
   24.49 +#define GET_SET_SHARED(type, field) \
   24.50 +static inline type arch_get_##field(const struct domain *d) \
   24.51 +{ \
   24.52 +    return d->shared_info->arch.field; \
   24.53 +} \
   24.54 +static inline void arch_set_##field(struct domain *d, \
   24.55 +                                    type val) \
   24.56 +{ \
   24.57 +    d->shared_info->arch.field = val; \
   24.58 +}
   24.59 +
   24.60 +#define GET_SET_VCPU(type, field) \
   24.61 +static inline type arch_get_##field(const struct vcpu *v) \
   24.62 +{ \
   24.63 +    return v->vcpu_info->arch.field; \
   24.64 +} \
   24.65 +static inline void arch_set_##field(struct vcpu *v, \
   24.66 +                                    type val) \
   24.67 +{ \
   24.68 +    v->vcpu_info->arch.field = val; \
   24.69 +}
   24.70 +#endif
   24.71 +
   24.72 +GET_SET_SHARED(unsigned long, max_pfn)
   24.73 +GET_SET_SHARED(xen_pfn_t, pfn_to_mfn_frame_list_list)
   24.74 +GET_SET_SHARED(unsigned long, nmi_reason)
   24.75 +
   24.76 +GET_SET_VCPU(unsigned long, cr2)
   24.77 +
   24.78 +#undef GET_SET_VCPU
   24.79 +#undef GET_SET_SHARED
   24.80 +
   24.81 +#endif /* __XEN_X86_SHARED_H__ */
    25.1 --- a/xen/include/public/xen.h	Fri Jan 05 17:34:28 2007 +0000
    25.2 +++ b/xen/include/public/xen.h	Fri Jan 05 17:34:29 2007 +0000
    25.3 @@ -408,7 +408,9 @@ struct vcpu_info {
    25.4      struct arch_vcpu_info arch;
    25.5      struct vcpu_time_info time;
    25.6  }; /* 64 bytes (x86) */
    25.7 +#ifndef __XEN__
    25.8  typedef struct vcpu_info vcpu_info_t;
    25.9 +#endif
   25.10  
   25.11  /*
   25.12   * Xen/kernel shared data -- pointer provided in start_info.
   25.13 @@ -466,7 +468,9 @@ struct shared_info {
   25.14      struct arch_shared_info arch;
   25.15  
   25.16  };
   25.17 +#ifndef __XEN__
   25.18  typedef struct shared_info shared_info_t;
   25.19 +#endif
   25.20  
   25.21  /*
   25.22   * Start-of-day memory layout for the initial domain (DOM0):
    26.1 --- a/xen/include/xen/compat.h	Fri Jan 05 17:34:28 2007 +0000
    26.2 +++ b/xen/include/xen/compat.h	Fri Jan 05 17:34:29 2007 +0000
    26.3 @@ -162,6 +162,12 @@ extern int compat_disabled;
    26.4  struct start_info;
    26.5  void xlat_start_info(struct start_info *, enum XLAT_start_info_console);
    26.6  
    26.7 +#define BITS_PER_GUEST_LONG(d) (!IS_COMPAT(d) ? BITS_PER_LONG : COMPAT_BITS_PER_LONG)
    26.8 +
    26.9 +#else
   26.10 +
   26.11 +#define BITS_PER_GUEST_LONG(d) BITS_PER_LONG
   26.12 +
   26.13  #endif
   26.14  
   26.15  #endif /* __XEN_COMPAT_H__ */
    27.1 --- a/xen/include/xen/sched.h	Fri Jan 05 17:34:28 2007 +0000
    27.2 +++ b/xen/include/xen/sched.h	Fri Jan 05 17:34:29 2007 +0000
    27.3 @@ -6,6 +6,7 @@
    27.4  #include <xen/types.h>
    27.5  #include <xen/spinlock.h>
    27.6  #include <xen/smp.h>
    27.7 +#include <xen/shared.h>
    27.8  #include <public/xen.h>
    27.9  #include <public/domctl.h>
   27.10  #include <public/vcpu.h>
   27.11 @@ -23,9 +24,15 @@ extern rwlock_t domlist_lock;
   27.12  /* A global pointer to the initial domain (DOM0). */
   27.13  extern struct domain *dom0;
   27.14  
   27.15 -#define MAX_EVTCHNS        NR_EVENT_CHANNELS
   27.16 +#ifndef CONFIG_COMPAT
   27.17 +#define MAX_EVTCHNS(d)     NR_EVENT_CHANNELS
   27.18 +#else
   27.19 +#define MAX_EVTCHNS(d)     (!IS_COMPAT(d) ? \
   27.20 +                            NR_EVENT_CHANNELS : \
   27.21 +                            sizeof(unsigned int) * sizeof(unsigned int) * 64)
   27.22 +#endif
   27.23  #define EVTCHNS_PER_BUCKET 128
   27.24 -#define NR_EVTCHN_BUCKETS  (MAX_EVTCHNS / EVTCHNS_PER_BUCKET)
   27.25 +#define NR_EVTCHN_BUCKETS  (NR_EVENT_CHANNELS / EVTCHNS_PER_BUCKET)
   27.26  
   27.27  struct evtchn
   27.28  {
    28.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.2 +++ b/xen/include/xen/shared.h	Fri Jan 05 17:34:29 2007 +0000
    28.3 @@ -0,0 +1,54 @@
    28.4 +#ifndef __XEN_SHARED_H__
    28.5 +#define __XEN_SHARED_H__
    28.6 +
    28.7 +#include <xen/config.h>
    28.8 +
    28.9 +#ifdef CONFIG_COMPAT
   28.10 +
   28.11 +#include <compat/xen.h>
   28.12 +
   28.13 +typedef union {
   28.14 +    struct shared_info native;
   28.15 +    struct compat_shared_info compat;
   28.16 +} shared_info_t;
   28.17 +
   28.18 +#define __shared_info(d, s, field)      (*(!IS_COMPAT(d) ? \
   28.19 +                                           &(s)->native.field : \
   28.20 +                                           &(s)->compat.field))
   28.21 +#define __shared_info_addr(d, s, field) (!IS_COMPAT(d) ? \
   28.22 +                                         (void *)&(s)->native.field : \
   28.23 +                                         (void *)&(s)->compat.field)
   28.24 +
   28.25 +#define shared_info(d, field)      __shared_info(d, (d)->shared_info, field)
   28.26 +#define shared_info_addr(d, field) __shared_info_addr(d, (d)->shared_info, field)
   28.27 +
   28.28 +typedef union {
   28.29 +    struct vcpu_info native;
   28.30 +    struct compat_vcpu_info compat;
   28.31 +} vcpu_info_t;
   28.32 +
   28.33 +#define vcpu_info(v, field)      (*(!IS_COMPAT((v)->domain) ? \
   28.34 +                                    &(v)->vcpu_info->native.field : \
   28.35 +                                    &(v)->vcpu_info->compat.field))
   28.36 +#define vcpu_info_addr(v, field) (!IS_COMPAT((v)->domain) ? \
   28.37 +                                  (void *)&(v)->vcpu_info->native.field : \
   28.38 +                                  (void *)&(v)->vcpu_info->compat.field)
   28.39 +
   28.40 +#else
   28.41 +
   28.42 +typedef struct shared_info shared_info_t;
   28.43 +
   28.44 +#define __shared_info(d, s, field)      ((s)->field)
   28.45 +#define __shared_info_addr(d, s, field) ((void *)&(s)->field)
   28.46 +
   28.47 +#define shared_info(d, field)           ((d)->shared_info->field)
   28.48 +#define shared_info_addr(d, field)      ((void *)&(d)->shared_info->field)
   28.49 +
   28.50 +typedef struct vcpu_info vcpu_info_t;
   28.51 +
   28.52 +#define vcpu_info(v, field)             ((v)->vcpu_info->field)
   28.53 +#define vcpu_info_addr(v, field)        ((void *)&(v)->vcpu_info->field)
   28.54 +
   28.55 +#endif
   28.56 +
   28.57 +#endif /* __XEN_SHARED_H__ */
    29.1 --- a/xen/include/xlat.lst	Fri Jan 05 17:34:28 2007 +0000
    29.2 +++ b/xen/include/xlat.lst	Fri Jan 05 17:34:29 2007 +0000
    29.3 @@ -3,3 +3,4 @@
    29.4  # ? - needs checking
    29.5  ?	dom0_vga_console_info		xen.h
    29.6  !	start_info			xen.h
    29.7 +?	vcpu_time_info			xen.h