[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] [XEN] Clean up some x86 bootstrap code. Replace some CPU iterators
# HG changeset patch # User kfraser@xxxxxxxxxxxxxxxxxxxxx # Node ID 80c5350a68f1f9499b08f76345882b2bcf059c2a # Parent f681ffc9b01a5ba97ccb81dbeb50343904e8498b [XEN] Clean up some x86 bootstrap code. Replace some CPU iterators with for_each_cpu() -- we want to ensure that per_cpu areas are accessed only for cpus in cpu_possible_map. Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx> --- xen/arch/x86/domain.c | 11 +++++++++-- xen/arch/x86/setup.c | 31 ++++++++++++++++++++----------- xen/arch/x86/smpboot.c | 2 -- xen/arch/x86/x86_32/mm.c | 10 ++++++---- xen/arch/x86/x86_64/mm.c | 7 ++++--- xen/common/sched_sedf.c | 13 +++---------- xen/common/schedule.c | 2 +- xen/common/timer.c | 2 +- xen/include/asm-x86/page.h | 3 ++- 9 files changed, 46 insertions(+), 35 deletions(-) diff -r f681ffc9b01a -r 80c5350a68f1 xen/arch/x86/domain.c --- a/xen/arch/x86/domain.c Mon Aug 21 12:05:11 2006 -0400 +++ b/xen/arch/x86/domain.c Tue Aug 22 11:19:48 2006 +0100 @@ -125,8 +125,15 @@ struct vcpu *alloc_vcpu_struct(struct do v->arch.flags = TF_kernel_mode; - v->arch.schedule_tail = is_idle_domain(d) ? - continue_idle_domain : continue_nonidle_domain; + if ( is_idle_domain(d) ) + { + v->arch.schedule_tail = continue_idle_domain; + v->arch.cr3 = __pa(idle_pg_table); + } + else + { + v->arch.schedule_tail = continue_nonidle_domain; + } v->arch.ctxt_switch_from = paravirt_ctxt_switch_from; v->arch.ctxt_switch_to = paravirt_ctxt_switch_to; diff -r f681ffc9b01a -r 80c5350a68f1 xen/arch/x86/setup.c --- a/xen/arch/x86/setup.c Mon Aug 21 12:05:11 2006 -0400 +++ b/xen/arch/x86/setup.c Tue Aug 22 11:19:48 2006 +0100 @@ -190,10 +190,26 @@ static void percpu_free_unused_areas(voi __pa(__per_cpu_end)); } +static void init_idle_domain(void) +{ + struct domain *idle_domain; + + /* Domain creation requires that scheduler structures are initialised. */ + scheduler_init(); + + idle_domain = domain_create(IDLE_DOMAIN_ID); + if ( (idle_domain == NULL) || (alloc_vcpu(idle_domain, 0, 0) == NULL) ) + BUG(); + + set_current(idle_domain->vcpu[0]); + idle_vcpu[0] = this_cpu(curr_vcpu) = current; + + setup_idle_pagetable(); +} + void __init __start_xen(multiboot_info_t *mbi) { char __cmdline[] = "", *cmdline = __cmdline; - struct domain *idle_domain; unsigned long _initrd_start = 0, _initrd_len = 0; unsigned int initrdidx = 1; module_t *mod = (module_t *)__va(mbi->mods_addr); @@ -212,6 +228,7 @@ void __init __start_xen(multiboot_info_t cmdline_parse(cmdline); set_current((struct vcpu *)0xfffff000); /* debug sanity */ + idle_vcpu[0] = current; set_processor_id(0); /* needed early, for smp_processor_id() */ smp_prepare_boot_cpu(); @@ -437,16 +454,6 @@ void __init __start_xen(multiboot_info_t early_cpu_init(); - scheduler_init(); - - idle_domain = domain_create(IDLE_DOMAIN_ID); - if ( (idle_domain == NULL) || (alloc_vcpu(idle_domain, 0, 0) == NULL) ) - BUG(); - - set_current(idle_domain->vcpu[0]); - this_cpu(curr_vcpu) = idle_domain->vcpu[0]; - idle_vcpu[0] = current; - paging_init(); /* Unmap the first page of CPU0's stack. */ @@ -476,6 +483,8 @@ void __init __start_xen(multiboot_info_t init_apic_mappings(); init_IRQ(); + + init_idle_domain(); trap_init(); diff -r f681ffc9b01a -r 80c5350a68f1 xen/arch/x86/smpboot.c --- a/xen/arch/x86/smpboot.c Mon Aug 21 12:05:11 2006 -0400 +++ b/xen/arch/x86/smpboot.c Tue Aug 22 11:19:48 2006 +0100 @@ -896,8 +896,6 @@ static int __devinit do_boot_cpu(int api v = alloc_idle_vcpu(cpu); BUG_ON(v == NULL); - v->arch.cr3 = __pa(idle_pg_table); - /* start_eip had better be page-aligned! */ start_eip = setup_trampoline(); diff -r f681ffc9b01a -r 80c5350a68f1 xen/arch/x86/x86_32/mm.c --- a/xen/arch/x86/x86_32/mm.c Mon Aug 21 12:05:11 2006 -0400 +++ b/xen/arch/x86/x86_32/mm.c Tue Aug 22 11:19:48 2006 +0100 @@ -75,8 +75,6 @@ void __init paging_init(void) printk("PAE disabled.\n"); #endif - idle_vcpu[0]->arch.cr3 = __pa(idle_pg_table); - if ( cpu_has_pge ) { /* Suitable Xen mapping can be GLOBAL. */ @@ -120,8 +118,12 @@ void __init paging_init(void) idle_pg_table_l2[l2_linear_offset(IOREMAP_VIRT_START) + i] = l2e_from_page(virt_to_page(ioremap_pt), __PAGE_HYPERVISOR); } - - /* Install per-domain mappings for idle domain. */ +} + +void __init setup_idle_pagetable(void) +{ + int i; + for ( i = 0; i < PDPT_L2_ENTRIES; i++ ) idle_pg_table_l2[l2_linear_offset(PERDOMAIN_VIRT_START) + i] = l2e_from_page(virt_to_page(idle_vcpu[0]->domain-> diff -r f681ffc9b01a -r 80c5350a68f1 xen/arch/x86/x86_64/mm.c --- a/xen/arch/x86/x86_64/mm.c Mon Aug 21 12:05:11 2006 -0400 +++ b/xen/arch/x86/x86_64/mm.c Tue Aug 22 11:19:48 2006 +0100 @@ -81,8 +81,6 @@ void __init paging_init(void) l2_pgentry_t *l2_ro_mpt; struct page_info *pg; - idle_vcpu[0]->arch.cr3 = __pa(idle_pg_table); - /* Create user-accessible L2 directory to map the MPT for guests. */ l3_ro_mpt = alloc_xenheap_page(); clear_page(l3_ro_mpt); @@ -121,7 +119,10 @@ void __init paging_init(void) /* Set up linear page table mapping. */ idle_pg_table[l4_table_offset(LINEAR_PT_VIRT_START)] = l4e_from_paddr(__pa(idle_pg_table), __PAGE_HYPERVISOR); - +} + +void __init setup_idle_pagetable(void) +{ /* Install per-domain mappings for idle domain. */ idle_pg_table[l4_table_offset(PERDOMAIN_VIRT_START)] = l4e_from_page( diff -r f681ffc9b01a -r 80c5350a68f1 xen/common/sched_sedf.c --- a/xen/common/sched_sedf.c Mon Aug 21 12:05:11 2006 -0400 +++ b/xen/common/sched_sedf.c Tue Aug 22 11:19:48 2006 +0100 @@ -1301,16 +1301,9 @@ static int sedf_adjust_weights(struct sc { struct vcpu *p; struct domain *d; - int sumw[NR_CPUS]; - s_time_t sumt[NR_CPUS]; - int cpu; - - for ( cpu = 0; cpu < NR_CPUS; cpu++ ) - { - sumw[cpu] = 0; - sumt[cpu] = 0; - } - + int sumw[NR_CPUS] = { 0 }; + s_time_t sumt[NR_CPUS] = { 0 }; + /* Sum across all weights. */ for_each_domain( d ) { diff -r f681ffc9b01a -r 80c5350a68f1 xen/common/schedule.c --- a/xen/common/schedule.c Mon Aug 21 12:05:11 2006 -0400 +++ b/xen/common/schedule.c Tue Aug 22 11:19:48 2006 +0100 @@ -633,7 +633,7 @@ void __init scheduler_init(void) open_softirq(SCHEDULE_SOFTIRQ, __enter_scheduler); - for ( i = 0; i < NR_CPUS; i++ ) + for_each_cpu ( i ) { spin_lock_init(&per_cpu(schedule_data, i).schedule_lock); init_timer(&per_cpu(schedule_data, i).s_timer, s_timer_fn, NULL, i); diff -r f681ffc9b01a -r 80c5350a68f1 xen/common/timer.c --- a/xen/common/timer.c Mon Aug 21 12:05:11 2006 -0400 +++ b/xen/common/timer.c Tue Aug 22 11:19:48 2006 +0100 @@ -382,7 +382,7 @@ void __init timer_init(void) SET_HEAP_SIZE(&dummy_heap, 0); SET_HEAP_LIMIT(&dummy_heap, 0); - for ( i = 0; i < NR_CPUS; i++ ) + for_each_cpu ( i ) { spin_lock_init(&per_cpu(timers, i).lock); per_cpu(timers, i).heap = &dummy_heap; diff -r f681ffc9b01a -r 80c5350a68f1 xen/include/asm-x86/page.h --- a/xen/include/asm-x86/page.h Mon Aug 21 12:05:11 2006 -0400 +++ b/xen/include/asm-x86/page.h Tue Aug 22 11:19:48 2006 +0100 @@ -255,7 +255,8 @@ extern root_pgentry_t idle_pg_table[ROOT extern root_pgentry_t idle_pg_table[ROOT_PAGETABLE_ENTRIES]; extern l2_pgentry_t idle_pg_table_l2[ROOT_PAGETABLE_ENTRIES]; #endif -extern void paging_init(void); +void paging_init(void); +void setup_idle_pagetable(void); #endif #define __pge_off() \ _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |