kexec on ia64
PATCH 1/1 kexec on ia64
Add kexec support on ia64.
---
arch/ia64/hp/common/sba_iommu.c +22 -0
@@ -1624,6 +1624,28 @@ ioc_iova_init(struct ioc *ioc)READ_REG (ioc->ioc_hpa +IOC_IBASE ); } +#ifdef CONFIG_KEXEC +void +ioc_iova_disable (void ) +{ +struct ioc *ioc; + + ioc = ioc_list; + +while (ioc !=NULL ) { +/* Disable IOVA translation */ +WRITE_REG (ioc->ibase &0xfffffffffffffffe , ioc->ioc_hpa +IOC_IBASE ); +READ_REG (ioc->ioc_hpa +IOC_IBASE ); + +/* Clear I/O TLB of any possible entries */ +WRITE_REG (ioc->ibase | (get_iovp_order (ioc->iov_size) + iovp_shift), ioc->ioc_hpa +IOC_PCOM ); +READ_REG (ioc->ioc_hpa +IOC_PCOM ); + + ioc = ioc->next; + } +} +#endif +static void __init ioc_resource_init (struct ioc *ioc) {
arch/ia64/Kconfig +17 -0
@@ -376,6 +376,23 @@ config IA64_PALINFO config SGI_SN def_bool y if (IA64_SGI_SN2 || IA64_GENERIC) +config KEXEC + bool "kexec system call (EXPERIMENTAL)" + depends on EXPERIMENTAL + help + kexec is a system call that implements the ability to shutdown your + current kernel, and to start another kernel. It is like a reboot + but it is indepedent of the system firmware. And like a reboot + you can start any kernel with it, not just Linux. + + The name comes from the similiarity to the exec system call. + + It is an ongoing process to be certain the hardware in a machine + is properly shutdown, so do not be surprised if this code does not + initially work for you. It may help to enable device hotplugging + support. As of this writing the exact hardware interface is + strongly in flux, so no good recommendation can be made. + source "drivers/firmware/Kconfig" source "fs/Kconfig.binfmt"
arch/ia64/kernel/crash.c +43 -0
43 lines not on this page · raw message
arch/ia64/kernel/entry.S +1 -1
@@ -1590,7 +1590,7 @@ sys_call_table: data8 sys_mq_timedreceive // 1265 data8 sys_mq_notify data8 sys_mq_getsetattr - data8 sys_ni_syscall // reserved for kexec_load + data8 sys_kexec_load data8 sys_ni_syscall // reserved for vserver data8 sys_waitid // 1270 data8 sys_add_key
arch/ia64/kernel/machine_kexec.c +149 -0
149 lines not on this page · raw message
arch/ia64/kernel/Makefile +1 -0
@@ -28,6 +28,7 @@ obj-$(CONFIG_IA64_CYCLONE) += cyclone.o obj-$(CONFIG_CPU_FREQ) += cpufreq/ obj-$(CONFIG_IA64_MCA_RECOVERY) += mca_recovery.o obj-$(CONFIG_KPROBES) += kprobes.o jprobes.o +obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o crash.o obj-$(CONFIG_IA64_UNCACHED_ALLOCATOR) += uncached.o mca_recovery-y += mca_drv.o mca_drv_asm.o
arch/ia64/kernel/relocate_kernel.S +359 -0
359 lines not on this page · raw message
arch/ia64/kernel/smp.c +29 -0
@@ -30,6 +30,7 @@#include <linux/delay.h> #include <linux/efi.h> #include <linux/bitops.h> +#include <linux/kexec.h> #include <asm/atomic.h> #include <asm/current.h>
@@ -84,6 +85,34 @@ unlock_ipi_calllock(void)spin_unlock_irq (&call_lock); } +#ifdef CONFIG_KEXEC +/* +* Stop the CPU and put it in fake SAL rendezvous. This allows CPU to wake +* up with IPI from boot processor +*/ +void +kexec_stop_this_cpu (void *func) +{ +unsigned long pta, impl_va_bits, pal_base; + +/* +* Remove this CPU by putting it into fake SAL rendezvous +*/ +cpu_clear (smp_processor_id (), cpu_online_map); +max_xtp (); +ia64_eoi (); + +/* Disable VHPT */ + impl_va_bits =ffz (~(local_cpu_data->unimpl_va_mask | (7UL <<61 ))); + pta =POW2 (61 ) -POW2 (vmlpt_bits); +ia64_set_pta (pta | (0 <<8 ) | (vmlpt_bits <<2 ) |0 ); + +local_irq_disable (); + pal_base =__get_cpu_var (ia64_mca_pal_base); +kexec_fake_sal_rendez (func, ap_wakeup_vector, pal_base); +} +#endif +static void stop_this_cpu (void ) {
include/asm-ia64/kexec.h +36 -0
@@ -0,0 +1,36 @@ +#ifndef _ASM_IA64_KEXEC_H +#define _ASM_IA64_KEXEC_H + + +/* Maximum physical address we can use pages from */ +#define KEXEC_SOURCE_MEMORY_LIMIT (-1UL) +/* Maximum address we can reach in physical address mode */ +#define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL) +/* Maximum address we can use for the control code buffer */ +#define KEXEC_CONTROL_MEMORY_LIMIT TASK_SIZE + +#define KEXEC_CONTROL_CODE_SIZE (8192 + 8192 + 4096) + +/* The native architecture */ +#define KEXEC_ARCH KEXEC_ARCH_IA_64 + +#define MAX_NOTE_BYTES 1024 + +#define pte_bits 3 +#define vmlpt_bits (impl_va_bits - PAGE_SHIFT + pte_bits) +#define POW2 (n) (1ULL << (n)) + +DECLARE_PER_CPU (u64, ia64_mca_pal_base); + +const extern unsigned int relocate_new_kernel_size; +volatile extern long kexec_rendez; +extern void relocate_new_kernel (unsigned long ,unsigned long , +struct ia64_boot_param *,unsigned long ); +extern void kexec_fake_sal_rendez (void *start,unsigned long wake_up, +unsigned long pal_base); + +static inline void +crash_setup_regs (struct pt_regs *newregs,struct pt_regs *oldregs) +{ +} +#endif /* _ASM_IA64_KEXEC_H */
include/asm-ia64/machvec_hpzx1.h +2 -0
@@ -34,4 +34,6 @@ extern ia64_mv_dma_mapping_error sba_dma#define platform_dma_supported sba_dma_supported#define platform_dma_mapping_error sba_dma_mapping_error +extern void ioc_iova_disable (void ); +#endif /* _ASM_IA64_MACHVEC_HPZX1_h */
include/asm-ia64/smp.h +3 -0
@@ -129,6 +129,9 @@ extern void smp_send_reschedule (int cpuextern void lock_ipi_calllock (void );extern void unlock_ipi_calllock (void );extern void identify_siblings (struct cpuinfo_ia64 *); +#ifdef CONFIG_KEXEC +extern void kexec_stop_this_cpu (void *); +#endif #else
include/linux/irq.h +1 -0
@@ -94,6 +94,7 @@ irq_descp (int irq)#include <asm/hw_irq.h> /* the arch dependent stuff */ extern int setup_irq (unsigned int irq,struct irqaction * new); +extern void terminate_irqs (void );#ifdef CONFIG_GENERIC_HARDIRQS extern cpumask_t irq_affinity[NR_IRQS ];
kernel/irq/manage.c +19 -0
@@ -377,3 +377,22 @@ int request_irq(unsigned int irq,EXPORT_SYMBOL (request_irq); +/* +* Terminate any outstanding interrupts +*/ +void terminate_irqs (void ) +{ +struct irqaction * action; +irq_desc_t *idesc; +int i; + +for (i=0 ; i<NR_IRQS ; i++) { + idesc =irq_descp (i); + action = idesc->action; +if (!action) +continue ; +if (idesc->handler->end) + idesc->handler->end (i); + } +} +
Quoted 3 lines · Khalid Aziz
Add kexec support on ia64.
Neat. How well does it work?
Quoted 14 lines
arch/ia64/kernel/machine_kexec.c +14
-0+#ifdef CONFIG_PCI +void machine_shutdown (void ) +{ +struct pci_dev *dev; +irq_desc_t *idesc; +cpumask_t mask =CPU_MASK_NONE ; + +/* Disable all PCI devices */ +list_for_each_entry (dev, &pci_devices, global_list) { +if (!(dev->is_enabled)) +continue ; + idesc =irq_descp (dev->irq); +if (!idesc) +continue ;
arch/ia64/kernel/machine_kexec.c line 90
Quoted 10 lines
arch/ia64/kernel/machine_kexec.c +10
-0+cpu_set (0 , mask); +disable_irq_nosync (dev->irq); + idesc->handler->end (dev->irq); + idesc->handler->set_affinity (dev->irq, mask); + idesc->action =NULL ; +pci_disable_device (dev); + pci_set_power_state(dev, 0); + } +} +#endif
Ahem.
/* Do NOT directly access these two variables, unless you are arch specific pci
* code, or pci core code. */
extern struct list_head pci_root_buses; /* list of all known PCI buses */
extern struct list_head pci_devices; /* list of all devices */
I think it would be kinder to the API to use pci_find_device(PCI_ANY_ID, PCI_ANY_ID, ...) here.
Quoted 10 lines
arch/ia64/kernel/machine_kexec.c +10
-0+/* +* Do not allocate memory (or fail in any way) in machine_kexec(). +* We are past the point of no return, committed to rebooting now. +*/ +void machine_kexec (struct kimage *image) +{ +unsigned long indirection_page; +relocate_new_kernel_t rnk; +unsigned long pta, impl_va_bits; +void *pal_addr =efi_get_pal_addr ();
arch/ia64/kernel/machine_kexec.c line 111
Quoted 10 lines
arch/ia64/kernel/machine_kexec.c +10
-0+unsigned long code_addr = (unsigned long )page_address (image->control_code_page); + +#ifdef CONFIG_HOTPLUG_CPU +int cpu; + +for_each_online_cpu (cpu) { +if (cpu !=smp_processor_id ()) +cpu_down (cpu); + } +#elif CONFIG_SMP
This will generate a CPP warning if CONFIG_SMP is not defined.
#elif defined(CONFIG_SMP)
would be preferred.
Quoted 6 lines
kernel/irq/manage.c +0
-0@@ -377,3 +377,22 @@ int request_irq(unsigned int irq,EXPORT_SYMBOL (request_irq);
kernel/irq/manage.c int request_irq(unsigned int irq, · line 389
Quoted 10 lines
kernel/irq/manage.c +10
-0+/* +* Terminate any outstanding interrupts +*/ +void terminate_irqs (void ) +{ +struct irqaction * action; +irq_desc_t *idesc; +int i; + +for (i=0 ; i<NR_IRQS ; i++) {
for (i = 0; i < NR_IRQS; i++) {kernel/irq/manage.c int request_irq(unsigned int irq, · line 397
Quoted 8 lines
kernel/irq/manage.c +8
-0+ idesc =irq_descp (i); + action = idesc->action; +if (!action) +continue ; +if (idesc->handler->end) + idesc->handler->end (i); + } +}
Could we have a bit more description of what this function does, and why we need it?
Should other kexec-using architectures be using this? If not, why does ia64 need it?
Thanks.
Quoted 26 lines · Andrew Morton
kernel/irq/manage.c int request_irq(unsigned int irq, · line 389
Quoted 10 lines · Khalid Aziz
kernel/irq/manage.c +10
-0+/* +* Terminate any outstanding interrupts +*/ +void terminate_irqs (void ) +{ +struct irqaction * action; +irq_desc_t *idesc; +int i; + +for (i=0 ; i<NR_IRQS ; i++) {for (i = 0; i < NR_IRQS; i++) {kernel/irq/manage.c int request_irq(unsigned int irq, · line 397
Quoted 8 lines
kernel/irq/manage.c +8
-0+ idesc =irq_descp (i); + action = idesc->action; +if (!action) +continue ; +if (idesc->handler->end) + idesc->handler->end (i); + } +}Could we have a bit more description of what this function does, and why we need it?
Quoted 2 lines
Should other kexec-using architectures be using this? If not, why does ia64 need it?
We've been kicking around a patch to do something similar, we also eoi anything that's outstanding. I can't find the patch just now, but it's on linuxppc somewhere I think.
cheers
Signature · 8 lines
Michael Ellerman IBM OzLabs wwweb: http://michael.ellerman.id.au phone: +61 2 6212 1183 (tie line 70 21183) We do not inherit the earth from our ancestors, we borrow it from our children. - S.M.A.R.T Person
Quoted 6 lines · Andrew Morton
Quoted 3 lines · Khalid Aziz
Add kexec support on ia64.
Neat. How well does it work?
Works well on my test machines - HP rx2600 and HP cx2600. Hopefully others can test it on other machines.
Quoted 25 lines
kernel/irq/manage.c int request_irq(unsigned int irq, · line 389
Quoted 10 lines
kernel/irq/manage.c +10
-0+/* +* Terminate any outstanding interrupts +*/ +void terminate_irqs (void ) +{ +struct irqaction * action; +irq_desc_t *idesc; +int i; + +for (i=0 ; i<NR_IRQS ; i++) {for (i = 0; i < NR_IRQS; i++) {kernel/irq/manage.c int request_irq(unsigned int irq, · line 397
Quoted 8 lines
kernel/irq/manage.c +8
-0+ idesc =irq_descp (i); + action = idesc->action; +if (!action) +continue ; +if (idesc->handler->end) + idesc->handler->end (i); + } +}Could we have a bit more description of what this function does, and why we need it?
Quoted 4 lines
Should other kexec-using architectures be using this? If not, why does ia64 need it?
Thanks.
This funtion terminates any outstanding interrupts. I found it to be necessary for devices that use level interrupt. If a device, using level interrupt, asserted its interrupt as kernel goes into panic, nobody acknowledges its interrupt. As a result, this interrupt stays asserted as the new kernel comes up. All drivers in their initialization routine should clear any pending interrupts, but most do not. As a result, when driver attempts to use the interrupt, it is unable to since the interrupt was already asserted and any new interrupts from the device simply cause interrupt line to continue to be asserted. terminate_irqs() tries to acknowledge any pending interrupts so the interrupts will be usable when the new kernel comes up. This is not specific to ia64 and I would think this problem would show up on other architectures as well. I happened to find it on ia64 because HP rx2600 uses level interrupts for SCSI controller.
--
Khalid
==================================
Khalid Aziz Open Source and Linux Organization
(970)898-9214 Hewlett-Packard
[email protected] Fort Collins, CO
"The Linux kernel is subject to relentless development"
- Alessandro Rubini
Quoted 1 line · Khalid Aziz
Add kexec support on ia64.
This looks like a starting place but this patch needs some more work.
Quoted 105 lines
Signed-off-by Khalid Aziz <[email protected]>---
diff -urNp
linux-2.6.16/arch/ia64/hp/common/sba_iommu.clinux-2.6.16-kexec/arch/ia64/hp/common/sba_iommu.c
---linux-2.6.16/arch/ia64/hp/common/sba_iommu.c2006-03-19 22:53:29.000000000 -0700
+++linux-2.6.16-kexec/arch/ia64/hp/common/sba_iommu.c2006-03-27 15:42:47.000000000 -0700arch/ia64/hp/common/sba_iommu.c +22
-0@@ -1624,6 +1624,28 @@ ioc_iova_init(struct ioc *ioc)READ_REG (ioc->ioc_hpa +IOC_IBASE ); } +#ifdef CONFIG_KEXEC +void +ioc_iova_disable (void ) +{ +struct ioc *ioc; + + ioc = ioc_list; + +while (ioc !=NULL ) { +/* Disable IOVA translation */ +WRITE_REG (ioc->ibase &0xfffffffffffffffe , ioc->ioc_hpa +IOC_IBASE ); +READ_REG (ioc->ioc_hpa +IOC_IBASE ); + +/* Clear I/O TLB of any possible entries */ +WRITE_REG (ioc->ibase | (get_iovp_order (ioc->iov_size) + iovp_shift), ioc->ioc_hpa +IOC_PCOM ); +READ_REG (ioc->ioc_hpa +IOC_PCOM ); + + ioc = ioc->next; + } +} +#endif +static void __init ioc_resource_init (struct ioc *ioc){
diff -urNp linux-2.6.16/arch/ia64/Kconfig linux-2.6.16-kexec/arch/ia64/Kconfigarch/ia64/Kconfig 2006-03-27 15:42:47.000000000 -0700 renamed from arch/ia64/Kconfig +17
-0@@ -376,6 +376,23 @@ config IA64_PALINFO config SGI_SN def_bool y if (IA64_SGI_SN2 || IA64_GENERIC) +config KEXEC + bool "kexec system call (EXPERIMENTAL)" + depends on EXPERIMENTAL + help + kexec is a system call that implements the ability to shutdown your + current kernel, and to start another kernel. It is like a reboot + but it is indepedent of the system firmware. And like a reboot + you can start any kernel with it, not just Linux. + + The name comes from the similiarity to the exec system call. + + It is an ongoing process to be certain the hardware in a machine + is properly shutdown, so do not be surprised if this code does not + initially work for you. It may help to enable device hotplugging + support. As of this writing the exact hardware interface is + strongly in flux, so no good recommendation can be made. + source "drivers/firmware/Kconfig" source "fs/Kconfig.binfmt"diff -urNp
linux-2.6.16/arch/ia64/kernel/crash.clinux-2.6.16-kexec/arch/ia64/kernel/crash.carch/ia64/kernel/crash.c 2006-03-27 15:49:44.000000000 renamed from arch/ia64/kernel/crash.c 1969-12-31 17:00:00.000000000 -0700 +33
-1-0700@@ -0,0 +1,43 @@ +/* + * arch/ia64/kernel/crash.c + * + * Architecture specific (ia64) functions for kexec based crash dumps. + * + * Created by: Khalid Aziz <[email protected]> + * + * Copyright (C) 2005 Hewlett-Packard Development Company, L.P. + * + */ +#include <linux/init.h> +#include <linux/types.h> +#include <linux/kernel.h> +#include <linux/smp.h> +#include <linux/irq.h> +#include <linux/reboot.h> +#include <linux/kexec.h> +#include <linux/irq.h> +#include <linux/delay.h> +#include <linux/elf.h> +#include <linux/elfcore.h> +#include <linux/device.h> + +void +machine_crash_shutdown(struct pt_regs *pt) +{ + /* This function is only called after the system + * has paniced or is otherwise in a critical state. + * The minimum amount of code to allow a kexec'd kernel + * to run successfully needs to happen here. + * + * In practice this means shooting down the other cpus in + * an SMP system.
arch/ia64/kernel/crash.c 2006-03-27 15:49:44.000000000 line 43
Quoted 10 lines
arch/ia64/kernel/crash.c 2006-03-27 15:49:44.000000000 renamed from arch/ia64/kernel/crash.c 1969-12-31 17:00:00.000000000 -0700 +10
-0+ */ + if (in_interrupt()) { + terminate_irqs(); + ia64_eoi(); + } + system_state = SYSTEM_RESTART; + device_shutdown(); + system_state = SYSTEM_BOOTING; + machine_shutdown(); +}
machine_crash_shutdown must not call device_shutdown. That has been shown to way exceed the minimum necessary to shutdown a system. I would prefer this to be a noop stub that doesn't work at all than something like this that does way too much, and makes people think the code will work.
As for terminate_irqs on x86 we do that on bootup not in the middle of a crash shutdown. The apics and xapics are close enough you should be able to do the same on ia64.
You display remarkable faith in a kernel that has paniced.
Quoted 14 lines
arch/ia64/kernel/crash.c 2006-03-27 15:49:44.000000000 renamed from arch/ia64/kernel/crash.c 1969-12-31 17:00:00.000000000 -0700 +14
-0+#ifdef CONFIG_PCI +void machine_shutdown(void) +{ + struct pci_dev *dev; + irq_desc_t *idesc; + cpumask_t mask = CPU_MASK_NONE; + + /* Disable all PCI devices */ + list_for_each_entry(dev, &pci_devices, global_list) { + if (!(dev->is_enabled)) + continue; + idesc = irq_descp(dev->irq); + if (!idesc) + continue;
arch/ia64/kernel/crash.c 2006-03-27 15:49:44.000000000
Quoted 10 lines
arch/ia64/kernel/crash.c 2006-03-27 15:49:44.000000000 renamed from arch/ia64/kernel/crash.c 1969-12-31 17:00:00.000000000 -0700 +10
-0+ cpu_set(0, mask); + disable_irq_nosync(dev->irq); + idesc->handler->end(dev->irq); + idesc->handler->set_affinity(dev->irq, mask); + idesc->action = NULL; + pci_disable_device(dev); + pci_set_power_state(dev, 0); + } +} +#endif
This is peculiar but almost sane. We don't do this on x86, because devices are peculiar enough that no generic sequence works. What you have above belongs in the shutdown methods of the pci devices. There is no way to get this right in the general case.
some of the irq disable logic may in fact be sane.
Unless there is a good reason not to machine_shutdown needs to be called from machine_restart. So the code is routinely used and tested.
Having machine_shutdown only build when you have PCI present and then not making KEXEC depend on PCI is wrong.
The #ifdef needs to move inside machine_shutdown.
Quoted 14 lines
arch/ia64/kernel/crash.c 2006-03-27 15:49:44.000000000 renamed from arch/ia64/kernel/crash.c 1969-12-31 17:00:00.000000000 -0700 +12
-0+ +/* + * Do not allocate memory (or fail in any way) in machine_kexec(). + * We are past the point of no return, committed to rebooting now. + */ +void machine_kexec(struct kimage *image) +{ + unsigned long indirection_page; + relocate_new_kernel_t rnk; + unsigned long pta, impl_va_bits; + void *pal_addr = efi_get_pal_addr(); + unsigned long code_addr = (unsignedlong)page_address(image->control_code_page);
arch/ia64/kernel/crash.c 2006-03-27 15:49:44.000000000 renamed from arch/ia64/kernel/crash.c 1969-12-31 17:00:00.000000000 -0700 +1
-0+
arch/ia64/kernel/crash.c 2006-03-27 15:49:44.000000000
Quoted 10 lines
arch/ia64/kernel/crash.c 2006-03-27 15:49:44.000000000 renamed from arch/ia64/kernel/crash.c 1969-12-31 17:00:00.000000000 -0700 +10
-0+#ifdef CONFIG_HOTPLUG_CPU + int cpu; + + for_each_online_cpu(cpu) { + if (cpu != smp_processor_id()) + cpu_down(cpu); + } +#elif CONFIG_SMP + smp_call_function(kexec_stop_this_cpu, (void *)image->start, 0, 0); +#endif
This CPU and HOTPUG_CPU stuff belongs in machine shutdown.
Quoted 6 lines
arch/ia64/kernel/crash.c 2006-03-27 15:49:44.000000000 renamed from arch/ia64/kernel/crash.c 1969-12-31 17:00:00.000000000 -0700 +6
-0+ + ia64_set_itv(1<<16); + /* Interrupts aren't acceptable while we reboot */ + local_irq_disable(); + + /* set kr0 to the appropriate address */
arch/ia64/kernel/crash.c 2006-03-27 15:49:44.000000000
Quoted 10 lines
arch/ia64/kernel/crash.c 2006-03-27 15:49:44.000000000 renamed from arch/ia64/kernel/crash.c 1969-12-31 17:00:00.000000000 -0700 +10
-0+ set_io_base(); + + /* Disable VHPT */ + impl_va_bits = ffz(~(local_cpu_data->unimpl_va_mask | (7UL << 61))); + pta = POW2(61) - POW2(vmlpt_bits); + ia64_set_pta(pta | (0 << 8) | (vmlpt_bits << 2) | 0); + +#ifdef CONFIG_IA64_HP_ZX1 + ioc_iova_disable(); +#endif
This also looks like it needs to be part of machine_shutdown. I have no confidence in ioc_iova_disable when the machine is crashing. Basically anything that touches a pointer is likely to be bad.
Quoted 11 lines
arch/ia64/kernel/crash.c 2006-03-27 15:49:44.000000000 renamed from arch/ia64/kernel/crash.c 1969-12-31 17:00:00.000000000 -0700 +3
-0+ /* now execute the control code. + * We will start by executing the control code linked into the + * kernel as opposed to the code we copied in control code buffer * page. Whenthis code switches to physical mode, we will start
arch/ia64/kernel/crash.c 2006-03-27 15:49:44.000000000 renamed from arch/ia64/kernel/crash.c 1969-12-31 17:00:00.000000000 -0700 +7
-0+ * executing the code in control code buffer page. Reason for + * doing this is we start code execution in virtual address space. + * If we were to try to execute the newly copied code in virtual + * address space, we will need to make an ITLB entry to avoid ITLB + * miss. By executing the code linked into kernel, we take advantage + * of the ITLB entry already in place for kernel and avoid making + * a new entry.
arch/ia64/kernel/crash.c 2006-03-27 15:49:44.000000000
Quoted 10 lines
arch/ia64/kernel/crash.c 2006-03-27 15:49:44.000000000 renamed from arch/ia64/kernel/crash.c 1969-12-31 17:00:00.000000000 -0700 +10
-0+ */ + indirection_page = image->head & PAGE_MASK; + + rnk = (relocate_new_kernel_t)&code_addr; + (*rnk)(indirection_page, image->start, ia64_boot_param, + GRANULEROUNDDOWN((unsigned long) pal_addr)); + BUG(); + for (;;) + ; +}
Eric
Quoted 28 lines · Eric W. Biederman
Quoted 10 lines · Khalid Aziz
arch/ia64/kernel/crash.c +10
-0+void +machine_crash_shutdown (struct pt_regs *pt) +{ +/* This function is only called after the system +* has paniced or is otherwise in a critical state. +* The minimum amount of code to allow a kexec'd kernel +* to run successfully needs to happen here. +* +* In practice this means shooting down the other cpus in +* an SMP system. arch/ia64/kernel/crash.c line 43
Quoted 10 lines
arch/ia64/kernel/crash.c +10
-0+*/ +if (in_interrupt ()) { +terminate_irqs (); +ia64_eoi (); + } + system_state =SYSTEM_RESTART ; +device_shutdown (); + system_state =SYSTEM_BOOTING ; +machine_shutdown (); +}
machine_crash_shutdownmust not calldevice_shutdown. That has been shown to way exceed the minimum necessary to shutdown a system. I would prefer this to be a noop stub that doesn't work at all than something like this that does way too much, and makes people think the code will work.
Quoted 5 lines
As for
terminate_irqson x86 we do that on bootup not in the middle of a crash shutdown. The apics and xapics are close enough you should be able to do the same on ia64.You display remarkable faith in a kernel that has paniced.
I will look into eliminating this as much as possible.
Quoted 4 lines
Having
machine_shutdownonly build when you have PCI present and then not making KEXEC depend on PCI is wrong.The #ifdef needs to move inside
machine_shutdown.
Fixed.
Quoted 19 lines
Quoted 19 lines
arch/ia64/kernel/machine_kexec.c +12
-0+ +/* +* Do not allocate memory (or fail in any way) in machine_kexec(). +* We are past the point of no return, committed to rebooting now. +*/ +void machine_kexec (struct kimage *image) +{ +unsigned long indirection_page; +relocate_new_kernel_t rnk; +unsigned long pta, impl_va_bits; +void *pal_addr =efi_get_pal_addr (); + unsigned long code_addr = (unsignedlong)page_address(image->control_code_page);
arch/ia64/kernel/machine_kexec.c +5
-0+ +#ifdef CONFIG_HOTPLUG_CPU +int cpu; + +for_each_online_cpu (cpu) {
Quoted 8 lines
arch/ia64/kernel/machine_kexec.c line 113
Quoted 6 lines
arch/ia64/kernel/machine_kexec.c +6
-0+if (cpu !=smp_processor_id ()) + cpu_down(cpu); + } +#elif CONFIG_SMP +smp_call_function (kexec_stop_this_cpu, (void *)image->start,0 ,0 ); +#endif This CPU and
HOTPUG_CPUstuff belongs in machine shutdown.
Moved to machine_shutdown().
Quoted 13 lines
Quoted 13 lines
arch/ia64/kernel/machine_kexec.c +12
-0+ +ia64_set_itv (1 <<16 ); +/* Interrupts aren't acceptable while we reboot */ +local_irq_disable (); + +/* set kr0 to the appropriate address */ +set_io_base (); + +/* Disable VHPT */ + impl_va_bits =ffz (~(local_cpu_data->unimpl_va_mask | (7UL <<61 ))); + pta =POW2 (61 ) -POW2 (vmlpt_bits); +ia64_set_pta (pta | (0 <<8 ) | (vmlpt_bits <<2 ) |0 );
Quoted 8 lines
arch/ia64/kernel/machine_kexec.c line 129
Quoted 4 lines
arch/ia64/kernel/machine_kexec.c +4
-0+ +#ifdef CONFIG_IA64_HP_ZX1 +ioc_iova_disable (); +#endif This also looks like it needs to be part of
machine_shutdown. I have no confidence inioc_iova_disablewhen the machine is crashing. Basically anything that touches a pointer is likely to be bad.
I have moved above code to machine_shutdown. I would prefer to delay disabling VHPT as much as possible, but since machine_kexec gets called soon after machine_shutdown and we should be executing kernel code strictly at this point which uses pinned TR entries, disabling VHPT should not have any deleterious effect.
Quoted 17 lines
Quoted 17 lines
arch/ia64/kernel/machine_kexec.c +3
-0+/* now execute the control code. +* We will start by executing the control code linked into the +* kernel as opposed to the code we copied in control code buffer * page. When this code switches to physical mode, we will start
arch/ia64/kernel/machine_kexec.c +12
-0+* executing the code in control code buffer page. Reason for +* doing this is we start code execution in virtual address space. +* If we were to try to execute the newly copied code in virtual +* address space, we will need to make an ITLB entry to avoid ITLB +* miss. By executing the code linked into kernel, we take advantage +* of the ITLB entry already in place for kernel and avoid making +* a new entry. +*/ + indirection_page = image->head &PAGE_MASK ; + + rnk = (relocate_new_kernel_t)&code_addr; + (*rnk)(indirection_page, image->start, ia64_boot_param,
Quoted 8 lines
arch/ia64/kernel/machine_kexec.c line 149
Quoted 5 lines
arch/ia64/kernel/machine_kexec.c +5
-0+ GRANULEROUNDDOWN((unsigned long) pal_addr)); +BUG (); +for (;;) + ; +}Eric
Thanks for the review.
Signature · 9 lines
Khalid ================================== Khalid Aziz Open Source and Linux Organization (970)898-9214 Hewlett-Packard [email protected] Fort Collins, CO "The Linux kernel is subject to relentless development" - Alessandro Rubini