int machine_kexec_prepare(struct kimage *image)
{ int i; unsignedlong begin, end; /* limits of segment */ unsignedlong low, high; /* limits of blocked memory range */ struct device_node *node; constunsignedlong *basep; constunsignedint *sizep;
/* *Sinceweusethekernelfaulthandlersandpagingcodeto *handlethevirtualmode,wemustmakesurenodestination *overlapskernelstaticdataorbss.
*/ for (i = 0; i < image->nr_segments; i++) if (image->segment[i].mem < __pa(_end)) return -ETXTBSY;
/* We also should not overwrite the tce tables */
for_each_node_by_type(node, "pci") {
basep = of_get_property(node, "linux,tce-base", NULL);
sizep = of_get_property(node, "linux,tce-size", NULL); if (basep == NULL || sizep == NULL) continue;
low = *basep;
high = low + (*sizep);
for (i = 0; i < image->nr_segments; i++) {
begin = image->segment[i].mem;
end = begin + image->segment[i].memsz;
switch (entry & IND_FLAGS) { case IND_DESTINATION:
dest = addr; break; case IND_INDIRECTION:
ptr = addr; break; case IND_SOURCE:
copy_page(dest, addr);
dest += PAGE_SIZE;
}
}
}
/* Called during kexec sequence with MMU off */
notrace void kexec_copy_flush(struct kimage *image)
{ long i, nr_segments = image->nr_segments; struct kexec_segment ranges[KEXEC_SEGMENT_MAX];
/* save the ranges on the stack to efficiently flush the icache */
memcpy(ranges, image->segment, sizeof(ranges));
mb(); /* make sure our irqs are disabled before we say they are */
get_paca()->kexec_state = KEXEC_STATE_IRQS_OFF; while(kexec_all_irq_disabled == 0)
cpu_relax();
mb(); /* make sure all irqs are disabled before this */
hw_breakpoint_disable(); /* *NoweveryCPUhasIRQsoff,wecanclearoutanypending *IPIsandbesurethatnomorewillcomeinafterthis.
*/ if (ppc_md.kexec_cpu_down)
ppc_md.kexec_cpu_down(0, 1);
reset_sprs();
kexec_smp_wait(); /* NOTREACHED */
}
staticvoid kexec_prepare_cpus_wait(int wait_state)
{ int my_cpu, i, notified=-1;
hw_breakpoint_disable();
my_cpu = get_cpu(); /* Make sure each CPU has at least made it to the state we need. * *FIXME:Thereisa(slim)chanceofaproblemifnotalloftheCPUs *arecorrectlyonlined.IfsomehowwestartaCPUonbootwithRTAS *start-cpu,butsomehowthatCPUdoesn'twritecallin_cpu_map[]in *time,thebootCPUwilltimeout.Ifitdoeseventuallyexecute *stuff,thesecondarywillstartup(paca_ptrs[]->cpu_startwas *written)andgetintoapeculiarstate. *Iftheplatformsupportssmp_ops->take_timebase(),thesecondaryCPU *willprobablybespinninginthere.Ifnot(i.e.pseries),the *secondarywillcontinueonandtrytoonlineitself/idle/etc.Ifit *survivesthat,weneedtofindthese *possible-but-not-online-but-should-beCPUsandchaperonetheminto *kexec_smp_wait().
*/
for_each_online_cpu(i) { if (i == my_cpu) continue;
while (paca_ptrs[i]->kexec_state < wait_state) {
barrier(); if (i != notified) {
printk(KERN_INFO "kexec: waiting for cpu %d " "(physical %d) to enter %i state\n",
i, paca_ptrs[i]->hw_cpu_id, wait_state);
notified = i;
}
}
}
mb();
}
/* *WeneedtomakesureeachpresentCPUisonline.Thenextkernelwillscan *thedevicetreeandassumeprimarythreadsareonlineandquerysecondary *threadsviaRTAStoonlinethemifrequired.Ifwedon'tonlineprimary *threads,theywillbestuck.However,wealsoonlinesecondarythreadsaswe *maybeusing'cedeoffline'.InthiscaseRTASdoesn'tseethesecondary *threadsasoffline--andagain,theseCPUswillbestuck. * *So,weonlineallCPUsthatshouldberunning,includingsecondarythreads.
*/ staticvoid wake_offline_cpus(void)
{ int cpu = 0;
for_each_present_cpu(cpu) { if (!cpu_online(cpu)) {
printk(KERN_INFO "kexec: Waking offline cpu %d.\n",
cpu);
WARN_ON(add_cpu(cpu));
}
}
}
/* switch to a staticly allocated stack. Based on irq stack code. *Wesetuppreempt_counttoavoidusingVMXinmemcpy. *XXX:thetaskstructwilllikelybeinvalidoncewedothecopy!
*/
current_thread_info()->flags = 0;
current_thread_info()->preempt_count = HARDIRQ_OFFSET;
/* We need a static PACA, too; copy this CPU's PACA over and switch to *it.Alsopoisonper_cpu_offsetandNULLlppacatocatchanyoneusing *non-staticdata.
*/
memcpy(&kexec_paca, get_paca(), sizeof(struct paca_struct));
kexec_paca.data_offset = 0xedeaddeadeeeeeeeUL; #ifdef CONFIG_PPC_PSERIES
kexec_paca.lppaca_ptr = NULL; #endif
if (is_secure_guest() && !(image->preserve_context ||
image->type == KEXEC_TYPE_CRASH)) {
uv_unshare_all_pages();
printk("kexec: Unshared all shared pages.\n");
}
/* Some things are best done in assembly. Finding globals with *atociseasierinC,sopassinwhatwecan.
*/
kexec_sequence(&kexec_stack, image->start, image,
page_address(image->control_code_page),
mmu_cleanup_all, copy_with_mmu_off); /* NOTREACHED */
}
#ifdef CONFIG_PPC_64S_HASH_MMU /* Values we need to export to the second kernel via the device tree. */ static __be64 htab_base; static __be64 htab_size;
/* On machines with no htab htab_address is NULL */ if (!htab_address) return -ENODEV;
node = of_find_node_by_path("/chosen"); if (!node) return -ENODEV;
/* remove any stale properties so ours can be found */
of_remove_property(node, of_find_property(node, htab_base_prop.name, NULL));
of_remove_property(node, of_find_property(node, htab_size_prop.name, NULL));
prev_node_offset = cpus_offset; /* Delete sub-nodes of /cpus node with device_type == "cpu" */ for (cpus_subnode_offset = fdt_first_subnode(fdt, cpus_offset); cpus_subnode_offset >= 0;) { /* Ignore nodes that do not have a device_type property or device_type != "cpu" */
prop = fdt_get_property(fdt, cpus_subnode_offset, "device_type", NULL); if (!prop || strcmp(prop->data, "cpu")) {
prev_node_offset = cpus_subnode_offset; goto next_node;
}
ret = fdt_del_node(fdt, cpus_subnode_offset); if (ret < 0) {
pr_err("Failed to delete a cpus sub-node: %s\n", fdt_strerror(ret)); return ret;
}
next_node: if (prev_node_offset == cpus_offset)
cpus_subnode_offset = fdt_first_subnode(fdt, cpus_offset); else
cpus_subnode_offset = fdt_next_subnode(fdt, prev_node_offset);
}
cpus_node = of_find_node_by_path("/cpus"); /* Fail here to avoid kexec/kdump kernel boot hung */ if (!cpus_node) {
pr_err("No /cpus node found\n"); return -EINVAL;
}
/* Add all /cpus sub-nodes of device_type == "cpu" to FDT */
for_each_child_of_node(cpus_node, dn) { /* Ignore device nodes that do not have a device_type property *ordevice_type!="cpu".
*/
device_type = of_get_property(dn, "device_type", NULL); if (!device_type || strcmp(device_type, "cpu")) continue;
cpus_subnode_offset = fdt_add_subnode(fdt, cpus_offset, dn->full_name); if (cpus_subnode_offset < 0) {
pr_err("Unable to add %s subnode: %s\n", dn->full_name,
fdt_strerror(cpus_subnode_offset));
ret = cpus_subnode_offset; goto out;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.