# HG changeset patch # User tristan.gingold@xxxxxxxx # Node ID b334cae5799f8388203315ac39d52105b2a6987d # Parent 7ed6c203efe9c79446ec21a6ba288c04e2ccee55 Move contents of switch_to macro from xensystem.h to context_switch function. Let fph enabled after context switch. Cleanup (unused function/variables, debug printf...) Signed-off-by: Tristan Gingold diff -r 7ed6c203efe9 -r b334cae5799f xen/arch/ia64/linux-xen/setup.c --- a/xen/arch/ia64/linux-xen/setup.c Wed Apr 19 16:39:15 2006 +++ b/xen/arch/ia64/linux-xen/setup.c Thu Apr 20 10:05:44 2006 @@ -384,7 +384,9 @@ { unw_init(); +#ifndef XEN ia64_patch_vtop((u64) __start___vtop_patchlist, (u64) __end___vtop_patchlist); +#endif *cmdline_p = __va(ia64_boot_param->command_line); #ifndef XEN @@ -931,9 +933,11 @@ #endif } +#ifndef XEN void check_bugs (void) { ia64_patch_mckinley_e9((unsigned long) __start___mckinley_e9_bundles, (unsigned long) __end___mckinley_e9_bundles); } +#endif diff -r 7ed6c203efe9 -r b334cae5799f xen/arch/ia64/xen/domain.c --- a/xen/arch/ia64/xen/domain.c Wed Apr 19 16:39:15 2006 +++ b/xen/arch/ia64/xen/domain.c Thu Apr 20 10:05:44 2006 @@ -70,11 +70,8 @@ #define IS_XEN_ADDRESS(d,a) ((a >= d->xen_vastart) && (a <= d->xen_vaend)) /* FIXME: where these declarations should be there ? */ -extern void domain_pend_keyboard_interrupt(int); extern long platform_is_hp_ski(void); -extern void sync_split_caches(void); extern void serial_input_init(void); - static void init_switch_stack(struct vcpu *v); void build_physmap_table(struct domain *d); @@ -302,7 +299,6 @@ { struct pt_regs *regs = vcpu_regs (v); - printf("arch_getdomaininfo_ctxt\n"); c->regs = *regs; c->vcpu.evtchn_vector = v->vcpu_info->arch.evtchn_vector; @@ -314,7 +310,6 @@ struct pt_regs *regs = vcpu_regs (v); struct domain *d = v->domain; - printf("arch_set_info_guest\n"); if ( test_bit(_VCPUF_initialised, &v->vcpu_flags) ) return 0; if (c->flags & VGCF_VMX_GUEST) { @@ -866,9 +861,8 @@ dom0_start = alloc_boot_pages(dom0_size >> PAGE_SHIFT, dom0_align >> PAGE_SHIFT); dom0_start <<= PAGE_SHIFT; if (!dom0_start) { - printf("alloc_dom0: can't allocate contiguous memory size=%lu\n", + panic("alloc_dom0: can't allocate contiguous memory size=%lu\n", dom0_size); - while(1); } printf("alloc_dom0: dom0_start=0x%lx\n", dom0_start); #else @@ -1133,17 +1127,6 @@ while(1); } - -#if 0 -void switch_to(struct vcpu *prev, struct vcpu *next) -{ - struct vcpu *last; - - __switch_to(prev,next,last); - //set_current(next); -} -#endif - void domain_pend_keyboard_interrupt(int irq) { vcpu_pend_interrupt(dom0->vcpu[0],irq); @@ -1154,10 +1137,6 @@ ia64_save_fpu(v->arch._thread.fph); if (VMX_DOMAIN(v)) vmx_save_state(v); - else { - if (IA64_HAS_EXTRA_STATE(v)) - ia64_save_extra(v); - } // FIXME SMP: Anything else needed here for SMP? } diff -r 7ed6c203efe9 -r b334cae5799f xen/arch/ia64/xen/xenmisc.c --- a/xen/arch/ia64/xen/xenmisc.c Wed Apr 19 16:39:15 2006 +++ b/xen/arch/ia64/xen/xenmisc.c Thu Apr 20 10:05:44 2006 @@ -1,6 +1,6 @@ /* * Xen misc - * + * * Functions/decls that are/may be needed to link with Xen because * of x86 dependencies * @@ -22,10 +22,6 @@ #include #include -efi_memory_desc_t ia64_efi_io_md; -EXPORT_SYMBOL(ia64_efi_io_md); -unsigned long wait_init_idle; -int phys_proc_id[NR_CPUS]; unsigned long loops_per_jiffy = (1<<12); // from linux/init/main.c /* FIXME: where these declarations should be there ? */ @@ -33,8 +29,6 @@ void ia64_mca_init(void) { printf("ia64_mca_init() skipped (Machine check abort handling)\n"); } void ia64_mca_cpu_init(void *x) { } -void ia64_patch_mckinley_e9(unsigned long a, unsigned long b) { } -void ia64_patch_vtop(unsigned long a, unsigned long b) { } void hpsim_setup(char **x) { #ifdef CONFIG_SMP @@ -68,21 +62,8 @@ return running_on_sim; } -/* calls in xen/common code that are unused on ia64 */ - -void sync_lazy_execstate_cpu(unsigned int cpu) {} - -#if 0 -int grant_table_create(struct domain *d) { return 0; } -void grant_table_destroy(struct domain *d) { return; } -#endif struct pt_regs *guest_cpu_user_regs(void) { return vcpu_regs(current); } - -void raise_actimer_softirq(void) -{ - raise_softirq(TIMER_SOFTIRQ); -} unsigned long gmfn_to_mfn_foreign(struct domain *d, unsigned long gpfn) @@ -124,15 +105,12 @@ /////////////////////////////// -void free_page_type(struct page_info *page, u32 type) -{ -// dummy(); - return; -} - -int alloc_page_type(struct page_info *page, u32 type) -{ -// dummy(); +static void free_page_type(struct page_info *page, u32 type) +{ +} + +static int alloc_page_type(struct page_info *page, u32 type) +{ return 1; } @@ -158,7 +136,7 @@ { void *p; p = alloc_xenheap_pages(0); - if (p) + if (p) clear_page(p); return p; } @@ -273,12 +251,16 @@ void *__module_text_address(unsigned long addr) { return NULL; } void *module_text_address(unsigned long addr) { return NULL; } -void cs10foo(void) {} -void cs01foo(void) {} - unsigned long context_switch_count = 0; #include + +extern void ia64_save_extra (struct vcpu *v); +extern void ia64_load_extra (struct vcpu *v); + +extern struct vcpu *vmx_ia64_switch_to (struct vcpu *next_task); +extern struct vcpu *ia64_switch_to (struct vcpu *next_task); + void context_switch(struct vcpu *prev, struct vcpu *next) { @@ -286,14 +268,21 @@ uint64_t pta; local_irq_save(spsr); -// if(VMX_DOMAIN(prev)){ -// vtm_domain_out(prev); -// } - context_switch_count++; - switch_to(prev,next,prev); -// if(VMX_DOMAIN(current)){ -// vtm_domain_in(current); -// } + context_switch_count++; + + ia64_fph_enable (); + __ia64_save_fpu(prev->arch._thread.fph); + __ia64_load_fpu(next->arch._thread.fph); + if (VMX_DOMAIN(prev)) + vmx_save_state(prev); + if (VMX_DOMAIN(next)) + vmx_load_state(next); + /*ia64_psr(ia64_task_regs(next))->dfh = !ia64_is_local_fpu_owner(next);*/ + prev = ia64_switch_to(next); + if (!VMX_DOMAIN(current)){ + vcpu_set_next_timer(current); + } + // leave this debug for now: it acts as a heartbeat when more than // one domain is active @@ -306,28 +295,26 @@ } if (VMX_DOMAIN(current)){ -// vtm_domain_in(current); vmx_load_all_rr(current); }else{ extern char ia64_ivt; ia64_set_iva(&ia64_ivt); if (!is_idle_domain(current->domain)) { ia64_set_pta(VHPT_ADDR | (1 << 8) | (VHPT_SIZE_LOG2 << 2) | - VHPT_ENABLED); + VHPT_ENABLED); load_region_regs(current); vcpu_load_kernel_regs(current); - if (vcpu_timer_expired(current)) - vcpu_pend_timer(current); + if (vcpu_timer_expired(current)) + vcpu_pend_timer(current); }else { - /* When switching to idle domain, only need to disable vhpt - * walker. Then all accesses happen within idle context will - * be handled by TR mapping and identity mapping. - */ - pta = ia64_get_pta(); - ia64_set_pta(pta & ~VHPT_ENABLED); + /* When switching to idle domain, only need to disable vhpt + * walker. Then all accesses happen within idle context will + * be handled by TR mapping and identity mapping. + */ + pta = ia64_get_pta(); + ia64_set_pta(pta & ~VHPT_ENABLED); } } - local_irq_restore(spsr); context_saved(prev); } @@ -346,9 +333,9 @@ va_list args; char buf[128]; struct vcpu *v = current; - + printf("$$$$$ PANIC in domain %d (k6=0x%lx): ", - v->domain->domain_id, + v->domain->domain_id, __get_cpu_var(cpu_kr)._kr[IA64_KR_CURRENT]); va_start(args, fmt); (void)vsnprintf(buf, sizeof(buf), fmt, args); @@ -392,19 +379,19 @@ ASSERT((x & PGT_count_mask) != 0); /* - * The page should always be validated while a reference is held. The - * exception is during domain destruction, when we forcibly invalidate + * The page should always be validated while a reference is held. The + * exception is during domain destruction, when we forcibly invalidate * page-table pages if we detect a referential loop. * See domain.c:relinquish_list(). */ - ASSERT((x & PGT_validated) || + ASSERT((x & PGT_validated) || test_bit(_DOMF_dying, &page_get_owner(page)->domain_flags)); if ( unlikely((nx & PGT_count_mask) == 0) ) { /* Record TLB information for flush later. Races are harmless. */ page->tlbflush_timestamp = tlbflush_current_time(); - + if ( unlikely((nx & PGT_type_mask) <= PGT_l4_page_table) && likely(nx & PGT_validated) ) { @@ -413,7 +400,7 @@ * 'free' is safe because the refcnt is non-zero and validated * bit is clear => other ops will spin or fail. */ - if ( unlikely((y = cmpxchg(&page->u.inuse.type_info, x, + if ( unlikely((y = cmpxchg(&page->u.inuse.type_info, x, x & ~PGT_validated)) != x) ) goto again; /* We cleared the 'valid bit' so we do the clean up. */ @@ -423,7 +410,7 @@ nx &= ~PGT_validated; } } - else if ( unlikely(((nx & (PGT_pinned | PGT_count_mask)) == + else if ( unlikely(((nx & (PGT_pinned | PGT_count_mask)) == (PGT_pinned | 1)) && ((nx & PGT_type_mask) != PGT_writable_page)) ) { diff -r 7ed6c203efe9 -r b334cae5799f xen/include/asm-ia64/linux-xen/asm/system.h --- a/xen/include/asm-ia64/linux-xen/asm/system.h Wed Apr 19 16:39:15 2006 +++ b/xen/include/asm-ia64/linux-xen/asm/system.h Thu Apr 20 10:05:44 2006 @@ -187,7 +187,9 @@ (__ia64_id_flags & IA64_PSR_I) == 0; \ }) -#ifndef XEN +#ifdef XEN +#define local_irq_is_enabled() (!irqs_disabled()) +#else #ifdef __KERNEL__ #ifdef CONFIG_IA32_SUPPORT diff -r 7ed6c203efe9 -r b334cae5799f xen/include/asm-ia64/xensystem.h --- a/xen/include/asm-ia64/xensystem.h Wed Apr 19 16:39:15 2006 +++ b/xen/include/asm-ia64/xensystem.h Thu Apr 20 10:05:44 2006 @@ -37,43 +37,4 @@ #define IS_VMM_ADDRESS(addr) ((((addr) >> 60) ^ ((addr) >> 59)) & 1) -#ifndef __ASSEMBLY__ - -#define IA64_HAS_EXTRA_STATE(t) 0 - -struct vcpu; -extern void ia64_save_extra (struct vcpu *v); -extern void ia64_load_extra (struct vcpu *v); - -extern struct vcpu *vmx_ia64_switch_to (struct vcpu *next_task); -extern struct vcpu *ia64_switch_to (struct vcpu *next_task); - -#define __switch_to(prev,next,last) do { \ - ia64_save_fpu(prev->arch._thread.fph); \ - ia64_load_fpu(next->arch._thread.fph); \ - if (VMX_DOMAIN(prev)) \ - vmx_save_state(prev); \ - else { \ - if (IA64_HAS_EXTRA_STATE(prev)) \ - ia64_save_extra(prev); \ - } \ - if (VMX_DOMAIN(next)) \ - vmx_load_state(next); \ - else { \ - if (IA64_HAS_EXTRA_STATE(next)) \ - ia64_save_extra(next); \ - } \ - /*ia64_psr(ia64_task_regs(next))->dfh = !ia64_is_local_fpu_owner(next);*/ \ - (last) = ia64_switch_to((next)); \ - if (!VMX_DOMAIN(current)){ \ - vcpu_set_next_timer(current); \ - } \ -} while (0) - -// FIXME SMP... see system.h, does this need to be different? -#define switch_to(prev,next,last) __switch_to(prev, next, last) - -#define local_irq_is_enabled() (!irqs_disabled()) - -#endif // __ASSEMBLY__ #endif // _ASM_IA64_XENSYSTEM_H