Lines Matching refs:cpu
91 void initialize_cpu_data(unsigned int cpu) in initialize_cpu_data() argument
93 cpu_data[cpu] = boot_cpu_data; in initialize_cpu_data()
177 unsigned int cpu = smp_processor_id(); in smp_callin() local
198 if ( !smp_store_cpu_info(cpu) ) in smp_callin()
201 cpu); in smp_callin()
208 printk("CPU%d: Failed to initialise hypervisor functions. Not coming online.\n", cpu); in smp_callin()
215 printk("CPU%d: Failed to initialise HVM. Not coming online.\n", cpu); in smp_callin()
226 synchronize_tsc_slave(cpu); in smp_callin()
246 static void set_cpu_sibling_map(unsigned int cpu) in set_cpu_sibling_map() argument
251 cpumask_set_cpu(cpu, &cpu_sibling_setup_map); in set_cpu_sibling_map()
253 cpumask_set_cpu(cpu, socket_cpumask[cpu_to_socket(cpu)]); in set_cpu_sibling_map()
254 cpumask_set_cpu(cpu, per_cpu(cpu_core_mask, cpu)); in set_cpu_sibling_map()
255 cpumask_set_cpu(cpu, per_cpu(cpu_sibling_mask, cpu)); in set_cpu_sibling_map()
257 if ( c[cpu].x86_num_siblings > 1 ) in set_cpu_sibling_map()
261 if ( cpu == i || c[cpu].phys_proc_id != c[i].phys_proc_id ) in set_cpu_sibling_map()
263 if ( c[cpu].compute_unit_id != INVALID_CUID && in set_cpu_sibling_map()
266 if ( c[cpu].compute_unit_id == c[i].compute_unit_id ) in set_cpu_sibling_map()
267 link_thread_siblings(cpu, i); in set_cpu_sibling_map()
269 else if ( c[cpu].cpu_core_id != XEN_INVALID_CORE_ID && in set_cpu_sibling_map()
272 if ( c[cpu].cpu_core_id == c[i].cpu_core_id ) in set_cpu_sibling_map()
273 link_thread_siblings(cpu, i); in set_cpu_sibling_map()
278 cpu, i); in set_cpu_sibling_map()
282 if ( c[cpu].x86_max_cores == 1 ) in set_cpu_sibling_map()
284 cpumask_copy(per_cpu(cpu_core_mask, cpu), in set_cpu_sibling_map()
285 per_cpu(cpu_sibling_mask, cpu)); in set_cpu_sibling_map()
286 c[cpu].booted_cores = 1; in set_cpu_sibling_map()
292 if ( c[cpu].phys_proc_id == c[i].phys_proc_id ) in set_cpu_sibling_map()
294 cpumask_set_cpu(i, per_cpu(cpu_core_mask, cpu)); in set_cpu_sibling_map()
295 cpumask_set_cpu(cpu, per_cpu(cpu_core_mask, i)); in set_cpu_sibling_map()
299 if ( cpumask_weight(per_cpu(cpu_sibling_mask, cpu)) == 1 ) in set_cpu_sibling_map()
306 c[cpu].booted_cores++; in set_cpu_sibling_map()
311 if ( i != cpu ) in set_cpu_sibling_map()
314 else if ( (i != cpu) && !c[cpu].booted_cores ) in set_cpu_sibling_map()
316 c[cpu].booted_cores = c[i].booted_cores; in set_cpu_sibling_map()
328 unsigned int cpu = booting_cpu; in start_secondary() local
332 set_current(idle_vcpu[cpu]); in start_secondary()
333 this_cpu(curr_vcpu) = idle_vcpu[cpu]; in start_secondary()
370 initialize_cpu_data(cpu); in start_secondary()
388 set_cpu_sibling_map(cpu); in start_secondary()
402 notify_cpu_starting(cpu); in start_secondary()
410 setup_vector_irq(cpu); in start_secondary()
411 cpumask_set_cpu(cpu, &cpu_online_map); in start_secondary()
535 int cpu; in alloc_cpu_id() local
538 cpu = cpumask_first(&tmp_map); in alloc_cpu_id()
539 return (cpu < nr_cpu_ids) ? cpu : -ENODEV; in alloc_cpu_id()
542 static int do_boot_cpu(int apicid, int cpu) in do_boot_cpu() argument
553 booting_cpu = cpu; in do_boot_cpu()
564 cpu, apicid, start_eip); in do_boot_cpu()
566 stack_start = stack_base[cpu] + STACK_SIZE - sizeof(struct cpu_info); in do_boot_cpu()
580 Dprintk("After Callout %d.\n", cpu); in do_boot_cpu()
594 print_cpu_info(cpu); in do_boot_cpu()
595 synchronize_tsc_master(cpu); in do_boot_cpu()
618 cpu_exit_clear(cpu); in do_boot_cpu()
629 #define STUB_BUF_CPU_OFFS(cpu) (((cpu) & (STUBS_PER_PAGE - 1)) * STUB_BUF_SIZE) argument
631 unsigned long alloc_stub_page(unsigned int cpu, unsigned long *mfn) in alloc_stub_page() argument
642 nodeid_t node = cpu_to_node(cpu); in alloc_stub_page()
652 stub_va = XEN_VIRT_END - FIXADDR_X_SIZE - (cpu + 1) * PAGE_SIZE; in alloc_stub_page()
666 void cpu_exit_clear(unsigned int cpu) in cpu_exit_clear() argument
668 cpu_uninit(cpu); in cpu_exit_clear()
788 static int setup_cpu_root_pgt(unsigned int cpu) in setup_cpu_root_pgt() argument
802 per_cpu(root_pgt, cpu) = rpt; in setup_cpu_root_pgt()
828 rc = clone_mapping(__va(__pa(stack_base[cpu])) + off, rpt); in setup_cpu_root_pgt()
831 rc = clone_mapping(idt_tables[cpu], rpt); in setup_cpu_root_pgt()
834 struct tss_page *ptr = &per_cpu(tss_page, cpu); in setup_cpu_root_pgt()
841 rc = clone_mapping((void *)per_cpu(stubs.addr, cpu), rpt); in setup_cpu_root_pgt()
846 static void cleanup_cpu_root_pgt(unsigned int cpu) in cleanup_cpu_root_pgt() argument
848 root_pgentry_t *rpt = per_cpu(root_pgt, cpu); in cleanup_cpu_root_pgt()
850 unsigned long stub_linear = per_cpu(stubs.addr, cpu); in cleanup_cpu_root_pgt()
855 per_cpu(root_pgt, cpu) = NULL; in cleanup_cpu_root_pgt()
923 static void cpu_smpboot_free(unsigned int cpu, bool remove) in cpu_smpboot_free() argument
925 unsigned int socket = cpu_to_socket(cpu); in cpu_smpboot_free()
934 cpumask_clear_cpu(cpu, &cpu_sibling_setup_map); in cpu_smpboot_free()
938 c[cpu].phys_proc_id = XEN_INVALID_SOCKET_ID; in cpu_smpboot_free()
939 c[cpu].cpu_core_id = XEN_INVALID_CORE_ID; in cpu_smpboot_free()
940 c[cpu].compute_unit_id = INVALID_CUID; in cpu_smpboot_free()
942 FREE_CPUMASK_VAR(per_cpu(cpu_sibling_mask, cpu)); in cpu_smpboot_free()
943 FREE_CPUMASK_VAR(per_cpu(cpu_core_mask, cpu)); in cpu_smpboot_free()
944 if ( per_cpu(scratch_cpumask, cpu) != &scratch_cpu0mask ) in cpu_smpboot_free()
945 FREE_CPUMASK_VAR(per_cpu(scratch_cpumask, cpu)); in cpu_smpboot_free()
946 if ( per_cpu(send_ipi_cpumask, cpu) != &send_ipi_cpu0mask ) in cpu_smpboot_free()
947 FREE_CPUMASK_VAR(per_cpu(send_ipi_cpumask, cpu)); in cpu_smpboot_free()
950 cleanup_cpu_root_pgt(cpu); in cpu_smpboot_free()
952 if ( per_cpu(stubs.addr, cpu) ) in cpu_smpboot_free()
954 mfn_t mfn = _mfn(per_cpu(stubs.mfn, cpu)); in cpu_smpboot_free()
958 memset(stub_page + STUB_BUF_CPU_OFFS(cpu), 0xcc, STUB_BUF_SIZE); in cpu_smpboot_free()
963 destroy_xen_mappings(per_cpu(stubs.addr, cpu) & PAGE_MASK, in cpu_smpboot_free()
964 (per_cpu(stubs.addr, cpu) | ~PAGE_MASK) + 1); in cpu_smpboot_free()
965 per_cpu(stubs.addr, cpu) = 0; in cpu_smpboot_free()
966 per_cpu(stubs.mfn, cpu) = 0; in cpu_smpboot_free()
972 FREE_XENHEAP_PAGE(per_cpu(compat_gdt, cpu)); in cpu_smpboot_free()
976 FREE_XENHEAP_PAGE(per_cpu(gdt, cpu)); in cpu_smpboot_free()
977 FREE_XENHEAP_PAGE(idt_tables[cpu]); in cpu_smpboot_free()
979 if ( stack_base[cpu] ) in cpu_smpboot_free()
981 memguard_unguard_stack(stack_base[cpu]); in cpu_smpboot_free()
982 FREE_XENHEAP_PAGES(stack_base[cpu], STACK_ORDER); in cpu_smpboot_free()
987 static int cpu_smpboot_alloc(unsigned int cpu) in cpu_smpboot_alloc() argument
991 nodeid_t node = cpu_to_node(cpu); in cpu_smpboot_alloc()
999 if ( stack_base[cpu] == NULL ) in cpu_smpboot_alloc()
1001 stack_base[cpu] = alloc_xenheap_pages(STACK_ORDER, memflags); in cpu_smpboot_alloc()
1002 if ( !stack_base[cpu] ) in cpu_smpboot_alloc()
1005 memguard_guard_stack(stack_base[cpu]); in cpu_smpboot_alloc()
1008 info = get_cpu_info_from_stack((unsigned long)stack_base[cpu]); in cpu_smpboot_alloc()
1009 info->processor_id = cpu; in cpu_smpboot_alloc()
1010 info->per_cpu_offset = __per_cpu_offset[cpu]; in cpu_smpboot_alloc()
1012 gdt = per_cpu(gdt, cpu) ?: alloc_xenheap_pages(0, memflags); in cpu_smpboot_alloc()
1015 per_cpu(gdt, cpu) = gdt; in cpu_smpboot_alloc()
1016 per_cpu(gdt_l1e, cpu) = in cpu_smpboot_alloc()
1020 gdt[PER_CPU_GDT_ENTRY - FIRST_RESERVED_GDT_ENTRY].a = cpu; in cpu_smpboot_alloc()
1023 per_cpu(compat_gdt, cpu) = gdt = alloc_xenheap_pages(0, memflags); in cpu_smpboot_alloc()
1026 per_cpu(compat_gdt_l1e, cpu) = in cpu_smpboot_alloc()
1029 gdt[PER_CPU_GDT_ENTRY - FIRST_RESERVED_GDT_ENTRY].a = cpu; in cpu_smpboot_alloc()
1032 if ( idt_tables[cpu] == NULL ) in cpu_smpboot_alloc()
1033 idt_tables[cpu] = alloc_xenheap_pages(0, memflags); in cpu_smpboot_alloc()
1034 if ( idt_tables[cpu] == NULL ) in cpu_smpboot_alloc()
1036 memcpy(idt_tables[cpu], idt_table, IDT_ENTRIES * sizeof(idt_entry_t)); in cpu_smpboot_alloc()
1037 disable_each_ist(idt_tables[cpu]); in cpu_smpboot_alloc()
1039 for ( stub_page = 0, i = cpu & ~(STUBS_PER_PAGE - 1); in cpu_smpboot_alloc()
1040 i < nr_cpu_ids && i <= (cpu | (STUBS_PER_PAGE - 1)); ++i ) in cpu_smpboot_alloc()
1043 per_cpu(stubs.mfn, cpu) = per_cpu(stubs.mfn, i); in cpu_smpboot_alloc()
1046 BUG_ON(i == cpu); in cpu_smpboot_alloc()
1047 stub_page = alloc_stub_page(cpu, &per_cpu(stubs.mfn, cpu)); in cpu_smpboot_alloc()
1050 per_cpu(stubs.addr, cpu) = stub_page + STUB_BUF_CPU_OFFS(cpu); in cpu_smpboot_alloc()
1052 rc = setup_cpu_root_pgt(cpu); in cpu_smpboot_alloc()
1061 if ( !(cond_zalloc_cpumask_var(&per_cpu(cpu_sibling_mask, cpu)) && in cpu_smpboot_alloc()
1062 cond_zalloc_cpumask_var(&per_cpu(cpu_core_mask, cpu)) && in cpu_smpboot_alloc()
1063 cond_alloc_cpumask_var(&per_cpu(scratch_cpumask, cpu)) && in cpu_smpboot_alloc()
1064 cond_alloc_cpumask_var(&per_cpu(send_ipi_cpumask, cpu))) ) in cpu_smpboot_alloc()
1071 cpu_smpboot_free(cpu, true); in cpu_smpboot_alloc()
1079 unsigned int cpu = (unsigned long)hcpu; in cpu_smpboot_callback() local
1085 rc = cpu_smpboot_alloc(cpu); in cpu_smpboot_callback()
1089 cpu_smpboot_free(cpu, !park_offline_cpus); in cpu_smpboot_callback()
1092 cpu_smpboot_free(cpu, true); in cpu_smpboot_callback()
1199 unsigned int cpu = smp_processor_id(); in smp_prepare_boot_cpu() local
1201 cpumask_set_cpu(cpu, &cpu_online_map); in smp_prepare_boot_cpu()
1202 cpumask_set_cpu(cpu, &cpu_present_map); in smp_prepare_boot_cpu()
1204 per_cpu(scratch_cpumask, cpu) = &scratch_cpu0mask; in smp_prepare_boot_cpu()
1205 per_cpu(send_ipi_cpumask, cpu) = &send_ipi_cpu0mask; in smp_prepare_boot_cpu()
1214 remove_siblinginfo(int cpu) in remove_siblinginfo() argument
1218 cpumask_clear_cpu(cpu, socket_cpumask[cpu_to_socket(cpu)]); in remove_siblinginfo()
1220 for_each_cpu ( sibling, per_cpu(cpu_core_mask, cpu) ) in remove_siblinginfo()
1222 cpumask_clear_cpu(cpu, per_cpu(cpu_core_mask, sibling)); in remove_siblinginfo()
1224 if ( cpumask_weight(per_cpu(cpu_sibling_mask, cpu)) == 1 ) in remove_siblinginfo()
1228 for_each_cpu(sibling, per_cpu(cpu_sibling_mask, cpu)) in remove_siblinginfo()
1229 cpumask_clear_cpu(cpu, per_cpu(cpu_sibling_mask, sibling)); in remove_siblinginfo()
1230 cpumask_clear(per_cpu(cpu_sibling_mask, cpu)); in remove_siblinginfo()
1231 cpumask_clear(per_cpu(cpu_core_mask, cpu)); in remove_siblinginfo()
1236 int cpu = smp_processor_id(); in __cpu_disable() local
1249 remove_siblinginfo(cpu); in __cpu_disable()
1252 cpumask_clear_cpu(cpu, &cpu_online_map); in __cpu_disable()
1257 void __cpu_die(unsigned int cpu) in __cpu_die() argument
1270 printk(KERN_ERR "CPU %u still not dead...\n", cpu); in __cpu_die()
1276 int cpu = -1; in cpu_add() local
1291 cpu = (x86_acpiid_to_apicid[acpi_id] != apic_id) in cpu_add()
1298 cpu = -EEXIST; in cpu_add()
1302 if ( (cpu = mp_register_lapic(apic_id, 1, 1)) < 0 ) in cpu_add()
1316 mp_unregister_lapic(apic_id, cpu); in cpu_add()
1317 cpu = -ENOSPC; in cpu_add()
1331 cpu); in cpu_add()
1332 cpumask_set_cpu(cpu, &tsc_sync_cpu_mask); in cpu_add()
1335 srat_detect_node(cpu); in cpu_add()
1336 numa_add_cpu(cpu); in cpu_add()
1337 dprintk(XENLOG_INFO, "Add CPU %x with index %x\n", apic_id, cpu); in cpu_add()
1340 return cpu; in cpu_add()
1344 int __cpu_up(unsigned int cpu) in __cpu_up() argument
1348 if ( (apicid = x86_cpu_to_apicid[cpu]) == BAD_APICID ) in __cpu_up()
1359 if ( (ret = do_boot_cpu(apicid, cpu)) != 0 ) in __cpu_up()
1365 while ( !cpu_online(cpu) ) in __cpu_up()
1391 int irq, vector, seridx, cpu = smp_processor_id(); in smp_intr_init() local
1408 per_cpu(vector_irq, cpu)[vector] = irq; in smp_intr_init()