[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] Handle shared info (having different layout for native and compatibility
# HG changeset patch # User Emmanuel Ackaouy <ack@xxxxxxxxxxxxx> # Date 1168018469 0 # Node ID 4c8f157a3a471f694ccbdefa6f541ea88438b2ab # Parent 4a164bf1edfcd8bcff422db5b31710babd43162e Handle shared info (having different layout for native and compatibility mode guests) accesses. Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx> --- xen/arch/x86/crash.c | 3 - xen/arch/x86/domain.c | 12 ++--- xen/arch/x86/domain_build.c | 5 +- xen/arch/x86/irq.c | 12 ++--- xen/arch/x86/mm/shadow/common.c | 3 - xen/arch/x86/setup.c | 5 -- xen/arch/x86/time.c | 12 ++--- xen/arch/x86/traps.c | 7 +-- xen/arch/x86/x86_64/asm-offsets.c | 13 +++++- xen/arch/x86/x86_64/compat/entry.S | 8 +-- xen/arch/x86/x86_64/compat/traps.c | 2 xen/arch/x86/x86_64/traps.c | 5 +- xen/common/compat/xlat.c | 4 + xen/common/domain.c | 2 xen/common/event_channel.c | 21 +++++---- xen/common/kernel.c | 5 +- xen/common/keyhandler.c | 13 +++--- xen/common/schedule.c | 17 ++++---- xen/include/Makefile | 5 +- xen/include/asm-ia64/shared.h | 4 + xen/include/asm-powerpc/shared.h | 4 + xen/include/asm-x86/compat.h | 2 xen/include/asm-x86/event.h | 14 +++--- xen/include/asm-x86/shared.h | 78 +++++++++++++++++++++++++++++++++++++ xen/include/public/xen.h | 4 + xen/include/xen/compat.h | 6 ++ xen/include/xen/sched.h | 11 ++++- xen/include/xen/shared.h | 54 +++++++++++++++++++++++++ xen/include/xlat.lst | 1 29 files changed, 261 insertions(+), 71 deletions(-) diff -r 4a164bf1edfc -r 4c8f157a3a47 xen/arch/x86/crash.c --- a/xen/arch/x86/crash.c Fri Jan 05 17:34:28 2007 +0000 +++ b/xen/arch/x86/crash.c Fri Jan 05 17:34:29 2007 +0000 @@ -25,6 +25,7 @@ #include <xen/kexec.h> #include <xen/sched.h> #include <public/xen.h> +#include <asm/shared.h> #include <asm/hvm/hvm.h> static atomic_t waiting_for_crash_ipi; @@ -103,7 +104,7 @@ void machine_crash_shutdown(void) info = kexec_crash_save_info(); info->dom0_pfn_to_mfn_frame_list_list = - dom0->shared_info->arch.pfn_to_mfn_frame_list_list; + arch_get_pfn_to_mfn_frame_list_list(dom0); } /* diff -r 4a164bf1edfc -r 4c8f157a3a47 xen/arch/x86/domain.c --- a/xen/arch/x86/domain.c Fri Jan 05 17:34:28 2007 +0000 +++ b/xen/arch/x86/domain.c Fri Jan 05 17:34:29 2007 +0000 @@ -534,10 +534,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) ) { @@ -562,7 +562,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; @@ -580,11 +580,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) | @@ -605,7 +605,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| diff -r 4a164bf1edfc -r 4c8f157a3a47 xen/arch/x86/domain_build.c --- a/xen/arch/x86/domain_build.c Fri Jan 05 17:34:28 2007 +0000 +++ b/xen/arch/x86/domain_build.c Fri Jan 05 17:34:29 2007 +0000 @@ -328,6 +328,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; @@ -730,7 +731,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(); @@ -738,6 +739,8 @@ int construct_dom0(struct domain *d, opt_dom0_max_vcpus = num_online_cpus(); if ( opt_dom0_max_vcpus > MAX_VIRT_CPUS ) opt_dom0_max_vcpus = MAX_VIRT_CPUS; + if ( opt_dom0_max_vcpus > BITS_PER_GUEST_LONG(d) ) + opt_dom0_max_vcpus = BITS_PER_GUEST_LONG(d); printk("Dom0 has maximum %u VCPUs\n", opt_dom0_max_vcpus); for ( i = 1; i < opt_dom0_max_vcpus; i++ ) diff -r 4a164bf1edfc -r 4c8f157a3a47 xen/arch/x86/irq.c --- a/xen/arch/x86/irq.c Fri Jan 05 17:34:28 2007 +0000 +++ b/xen/arch/x86/irq.c Fri Jan 05 17:34:29 2007 +0000 @@ -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); } @@ -624,14 +625,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' : '-')); diff -r 4a164bf1edfc -r 4c8f157a3a47 xen/arch/x86/mm/shadow/common.c --- a/xen/arch/x86/mm/shadow/common.c Fri Jan 05 17:34:28 2007 +0000 +++ b/xen/arch/x86/mm/shadow/common.c Fri Jan 05 17:34:29 2007 +0000 @@ -36,6 +36,7 @@ #include <asm/current.h> #include <asm/flushtlb.h> #include <asm/shadow.h> +#include <asm/shared.h> #include "private.h" @@ -2917,7 +2918,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, diff -r 4a164bf1edfc -r 4c8f157a3a47 xen/arch/x86/setup.c --- a/xen/arch/x86/setup.c Fri Jan 05 17:34:28 2007 +0000 +++ b/xen/arch/x86/setup.c Fri Jan 05 17:34:29 2007 +0000 @@ -548,14 +548,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. */ diff -r 4a164bf1edfc -r 4c8f157a3a47 xen/arch/x86/time.c --- a/xen/arch/x86/time.c Fri Jan 05 17:34:28 2007 +0000 +++ b/xen/arch/x86/time.c Fri Jan 05 17:34:29 2007 +0000 @@ -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_domain_wallclock_time(struct 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); } diff -r 4a164bf1edfc -r 4c8f157a3a47 xen/arch/x86/traps.c --- a/xen/arch/x86/traps.c Fri Jan 05 17:34:28 2007 +0000 +++ b/xen/arch/x86/traps.c Fri Jan 05 17:34:29 2007 +0000 @@ -58,6 +58,7 @@ #include <asm/i387.h> #include <asm/debugger.h> #include <asm/msr.h> +#include <asm/shared.h> #include <asm/x86_emulate.h> #include <asm/hvm/vpt.h> @@ -665,7 +666,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; @@ -1390,7 +1391,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 */ @@ -1601,7 +1602,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 */ diff -r 4a164bf1edfc -r 4c8f157a3a47 xen/arch/x86/x86_64/asm-offsets.c --- a/xen/arch/x86/x86_64/asm-offsets.c Fri Jan 05 17:34:28 2007 +0000 +++ b/xen/arch/x86/x86_64/asm-offsets.c Fri Jan 05 17:34:29 2007 +0000 @@ -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> @@ -96,9 +99,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)); diff -r 4a164bf1edfc -r 4c8f157a3a47 xen/arch/x86/x86_64/compat/entry.S --- a/xen/arch/x86/x86_64/compat/entry.S Fri Jan 05 17:34:28 2007 +0000 +++ b/xen/arch/x86/x86_64/compat/entry.S Fri Jan 05 17:34:29 2007 +0000 @@ -69,9 +69,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 @@ -189,10 +189,10 @@ 2: 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 diff -r 4a164bf1edfc -r 4c8f157a3a47 xen/arch/x86/x86_64/compat/traps.c --- a/xen/arch/x86/x86_64/compat/traps.c Fri Jan 05 17:34:28 2007 +0000 +++ b/xen/arch/x86/x86_64/compat/traps.c Fri Jan 05 17:34:29 2007 +0000 @@ -118,7 +118,7 @@ unsigned int compat_iret(void) clear_bit(_VCPUF_nmi_masked, ¤t->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 diff -r 4a164bf1edfc -r 4c8f157a3a47 xen/arch/x86/x86_64/traps.c --- a/xen/arch/x86/x86_64/traps.c Fri Jan 05 17:34:28 2007 +0000 +++ b/xen/arch/x86/x86_64/traps.c Fri Jan 05 17:34:29 2007 +0000 @@ -17,6 +17,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> @@ -52,7 +53,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 { @@ -234,7 +235,7 @@ unsigned long do_iret(void) clear_bit(_VCPUF_nmi_masked, ¤t->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; diff -r 4a164bf1edfc -r 4c8f157a3a47 xen/common/compat/xlat.c --- a/xen/common/compat/xlat.c Fri Jan 05 17:34:28 2007 +0000 +++ b/xen/common/compat/xlat.c Fri Jan 05 17:34:29 2007 +0000 @@ -21,6 +21,10 @@ CHECK_dom0_vga_console_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 diff -r 4a164bf1edfc -r 4c8f157a3a47 xen/common/domain.c --- a/xen/common/domain.c Fri Jan 05 17:34:28 2007 +0000 +++ b/xen/common/domain.c Fri Jan 05 17:34:29 2007 +0000 @@ -90,7 +90,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; diff -r 4a164bf1edfc -r 4c8f157a3a47 xen/common/event_channel.c --- a/xen/common/event_channel.c Fri Jan 05 17:34:28 2007 +0000 +++ b/xen/common/event_channel.c Fri Jan 05 17:34:29 2007 +0000 @@ -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)]) @@ -82,7 +83,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); @@ -517,12 +518,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); } @@ -720,10 +721,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); } diff -r 4a164bf1edfc -r 4c8f157a3a47 xen/common/kernel.c --- a/xen/common/kernel.c Fri Jan 05 17:34:28 2007 +0000 +++ b/xen/common/kernel.c Fri Jan 05 17:34:29 2007 +0000 @@ -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 @@ -253,7 +256,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 diff -r 4a164bf1edfc -r 4c8f157a3a47 xen/common/keyhandler.c --- a/xen/common/keyhandler.c Fri Jan 05 17:34:28 2007 +0000 +++ b/xen/common/keyhandler.c Fri Jan 05 17:34:29 2007 +0000 @@ -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> @@ -171,8 +172,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); @@ -181,11 +182,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); } } diff -r 4a164bf1edfc -r 4c8f157a3a47 xen/common/schedule.c --- a/xen/common/schedule.c Fri Jan 05 17:34:28 2007 +0000 +++ b/xen/common/schedule.c Fri Jan 05 17:34:29 2007 +0000 @@ -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); raise_softirq(SCHEDULE_SOFTIRQ); return 0; diff -r 4a164bf1edfc -r 4c8f157a3a47 xen/include/Makefile --- a/xen/include/Makefile Fri Jan 05 17:34:28 2007 +0000 +++ b/xen/include/Makefile Fri Jan 05 17:34:29 2007 +0000 @@ -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/%.i: compat/%.c 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\(_[[:xdigit:]]\+\)\?,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 $@ diff -r 4a164bf1edfc -r 4c8f157a3a47 xen/include/asm-ia64/shared.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/xen/include/asm-ia64/shared.h Fri Jan 05 17:34:29 2007 +0000 @@ -0,0 +1,4 @@ +#ifndef __XEN_ASM_SHARED_H__ +#define __XEN_ASM_SHARED_H__ + +#endif /* __XEN_ASM_SHARED_H__ */ diff -r 4a164bf1edfc -r 4c8f157a3a47 xen/include/asm-powerpc/shared.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/xen/include/asm-powerpc/shared.h Fri Jan 05 17:34:29 2007 +0000 @@ -0,0 +1,4 @@ +#ifndef __XEN_ASM_SHARED_H__ +#define __XEN_ASM_SHARED_H__ + +#endif /* __XEN_ASM_SHARED_H__ */ diff -r 4a164bf1edfc -r 4c8f157a3a47 xen/include/asm-x86/compat.h --- a/xen/include/asm-x86/compat.h Fri Jan 05 17:34:28 2007 +0000 +++ b/xen/include/asm-x86/compat.h Fri Jan 05 17:34:29 2007 +0000 @@ -2,5 +2,7 @@ * compat.h */ +#define COMPAT_BITS_PER_LONG 32 + typedef uint32_t compat_ptr_t; typedef unsigned long full_ptr_t; diff -r 4a164bf1edfc -r 4c8f157a3a47 xen/include/asm-x86/event.h --- a/xen/include/asm-x86/event.h Fri Jan 05 17:34:28 2007 +0000 +++ b/xen/include/asm-x86/event.h Fri Jan 05 17:34:29 2007 +0000 @@ -8,6 +8,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. */ diff -r 4a164bf1edfc -r 4c8f157a3a47 xen/include/asm-x86/shared.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/xen/include/asm-x86/shared.h Fri Jan 05 17:34:29 2007 +0000 @@ -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__ */ diff -r 4a164bf1edfc -r 4c8f157a3a47 xen/include/public/xen.h --- a/xen/include/public/xen.h Fri Jan 05 17:34:28 2007 +0000 +++ b/xen/include/public/xen.h Fri Jan 05 17:34:29 2007 +0000 @@ -408,7 +408,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. @@ -466,7 +468,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): diff -r 4a164bf1edfc -r 4c8f157a3a47 xen/include/xen/compat.h --- a/xen/include/xen/compat.h Fri Jan 05 17:34:28 2007 +0000 +++ b/xen/include/xen/compat.h Fri Jan 05 17:34:29 2007 +0000 @@ -162,6 +162,12 @@ struct start_info; 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__ */ diff -r 4a164bf1edfc -r 4c8f157a3a47 xen/include/xen/sched.h --- a/xen/include/xen/sched.h Fri Jan 05 17:34:28 2007 +0000 +++ b/xen/include/xen/sched.h Fri Jan 05 17:34:29 2007 +0000 @@ -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 { diff -r 4a164bf1edfc -r 4c8f157a3a47 xen/include/xen/shared.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/xen/include/xen/shared.h Fri Jan 05 17:34:29 2007 +0000 @@ -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__ */ diff -r 4a164bf1edfc -r 4c8f157a3a47 xen/include/xlat.lst --- a/xen/include/xlat.lst Fri Jan 05 17:34:28 2007 +0000 +++ b/xen/include/xlat.lst Fri Jan 05 17:34:29 2007 +0000 @@ -3,3 +3,4 @@ # ? - needs checking ? dom0_vga_console_info xen.h ! start_info xen.h +? vcpu_time_info xen.h _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |