Fix for kexec reboot failing after multiple continued
PATCH 1/1 Fix for kexec reboot failing after multiple continued
kexec patch I had sent out earlier has bug where it appends "kexec_reboot" to kernel parameters blindly. After several kexec reboots from kexec'd kernel, kernel parameters line becomes too long and kernel fails to boot. Attached patch will cure this. Patch kexec-ia64-reboot.diff can be applied on top of the previous patch I had sent. Patch 2.6.8.1-kexec3-ia64-2.diff includes this fix and is repalcement for my previous patch.
My current kexec patches for ia64 can also be found at
<http://free.linux.hp.com/~khalid/kexec-ia64/>.
Signature · 9 lines
Khalid ==================================================================== Khalid Aziz Linux and Open Source Lab (970)898-9214 Hewlett-Packard [email protected] Fort Collins, CO "The Linux kernel is subject to relentless development" - Alessandro Rubini
arch/ia64/kernel/machine_kexec.c +3 -1
@@ -22,6 +22,7 @@static struct ia64_boot_param boot_param;extern unsigned long saved_efi_memmap_size;extern void *saved_efi_memmap; +extern unsigned long kexec_reboot;static void set_io_base (void ) {
@@ -155,7 +156,8 @@*/ control_code_buffer = relocate_new_kernel; rnk = &control_code_buffer; -strcat (saved_command_line," kexec_reboot" ); +if (!kexec_reboot) +strcat (saved_command_line," kexec_reboot" ); cmdline =__va (ia64_boot_param->command_line);strlcpy (cmdline, saved_command_line,COMMAND_LINE_SIZE );/* Restore original EFI memory map */
arch/ia64/Kconfig +17 -0
@@ -278,6 +278,23 @@ little bigger and slows down execution a bit, but it is generally a good idea to turn this on. If you're unsure, say Y. +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. + config IA64_PALINFO tristate "/proc/pal support" help
arch/ia64/kernel/Makefile +1 -0
@@ -17,6 +17,7 @@ obj-$(CONFIG_SMP) += smp.o smpboot.o obj-$(CONFIG_PERFMON) += perfmon_default_smpl.o obj-$(CONFIG_IA64_CYCLONE) += cyclone.o +obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o # The gate DSO image is built using a special linker script. targets += gate.so gate-syms.o
arch/ia64/kernel/efi.c +29 -1
@@ -17,6 +17,9 @@* * Goutham Rao: <[email protected]> * Skip non-WB memory and ignore empty memory ranges. +* +* Nov 12, 2004: Added initial support for kexec +* - Khalid Aziz <[email protected]> */ #include <linux/config.h> #include <linux/module.h>
@@ -37,6 +40,10 @@extern efi_status_t efi_call_phys (void *, ...);struct efi efi; +#ifdef CONFIG_KEXEC +unsigned long kexec_reboot =0 ; +unsigned long saved_efi_memmap_size; +#endif EXPORT_SYMBOL (efi);static efi_runtime_services_t *runtime;static unsigned long mem_limit = ~0UL , max_addr = ~0UL ;
@@ -464,6 +471,9 @@* Cannot write to CRx with PSR.ic=1 */ psr =ia64_clear_ic (); +#if CONFIG_KEXEC +ia64_ptr (0x01 , vaddr & mask,IA64_GRANULE_SHIFT ); +#endif ia64_itr (0x1 ,IA64_TR_PALCODE , vaddr & mask,pte_val (pfn_pte (md->phys_addr >>PAGE_SHIFT ,PAGE_KERNEL )),IA64_GRANULE_SHIFT );
@@ -503,6 +513,14 @@if (end != cp)break ; cp = end; +#ifdef CONFIG_KEXEC + }else if (memcmp (cp,"kexec_reboot" ,12 ) ==0 ) { + cp +=12 ; + kexec_reboot =1 ; +if (end != cp) +break ; + cp = end; +#endif }else {while (*cp !=' ' && *cp) ++cp;
@@ -595,6 +613,9 @@ }#endif +#ifdef CONFIG_KEXEC + saved_efi_memmap_size = ia64_boot_param->efi_memmap_size; +#endif efi_map_pal_code ();efi_enter_virtual_mode (); }
@@ -647,10 +668,17 @@ } } - status =efi_call_phys (__va (runtime->set_virtual_address_map), +#ifdef CONFIG_KEXEC +if (kexec_reboot ==0 ) + status =efi_call_phys (__va (runtime->set_virtual_address_map), ia64_boot_param->efi_memmap_size, efi_desc_size, ia64_boot_param->efi_memdesc_version, ia64_boot_param->efi_memmap); +else { +printk (KERN_INFO "kexec'd kernel: Not virtualizing EFI\n" ); + status =EFI_SUCCESS ; + } +#endif if (status !=EFI_SUCCESS ) {printk (KERN_WARNING "warning: unable to switch EFI into virtual mode " "(status=%lu)\n" , status);
arch/ia64/kernel/entry.S +1 -1
@@ -1525,7 +1525,7 @@ 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 data8 sys_ni_syscall // 1270 data8 sys_ni_syscall
arch/ia64/kernel/machine_kexec.c +181 -0
181 lines not on this page · raw message
arch/ia64/kernel/relocate_kernel.S +228 -0
228 lines not on this page · raw message
arch/ia64/mm/contig.c +10 -0
@@ -29,6 +29,11 @@static unsigned long num_dma_physpages;#endif +#ifdef CONFIG_KEXEC +void *saved_efi_memmap; +extern unsigned long saved_efi_memmap_size; +#endif +/** * show_mem - display a memory statistics summary *
@@ -164,6 +169,11 @@/* Free all available memory, then mark bootmem-map as being in use. */ efi_memmap_walk (filter_rsvd_memory, free_bootmem);reserve_bootmem (bootmap_start, bootmap_size); +#ifdef CONFIG_KEXEC +/* Save EFI memory map for use later when kexec'ing a kernel */ + saved_efi_memmap =alloc_bootmem (saved_efi_memmap_size); +memcpy (saved_efi_memmap,__va (ia64_boot_param->efi_memmap), saved_efi_memmap_size); +#endif find_initrd (); }
arch/ia64/mm/discontig.c +11 -0
@@ -40,6 +40,11 @@static struct early_node_data mem_data[NR_NODES ]__initdata ; +#ifdef CONFIG_KEXEC +void *saved_efi_memmap; +extern unsigned long saved_efi_memmap_size; +#endif +/** * reassign_cpu_only_nodes - called from find_memory to move CPU-only nodes to a memory node *
@@ -459,6 +464,12 @@reserve_pernode_space ();initialize_pernode_data (); +#ifdef CONFIG_KEXEC +/* Save EFI memory map for use later when kexec'ing a kernel */ + saved_efi_memmap =alloc_bootmem (saved_efi_memmap_size); +memcpy (saved_efi_memmap,__va (ia64_boot_param->efi_memmap), saved_efi_memmap_size); +#endif + max_pfn = max_low_pfn;find_initrd ();
include/asm-ia64/kexec.h +14 -0
@@ -0,0 +1,14 @@ +#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) + +#endif /* _ASM_IA64_KEXEC_H */
include/asm-ia64/mmu_context.h +2 -0
@@ -203,5 +203,7 @@#define switch_mm (prev_mm,next_mm,next_task) activate_mm(prev_mm, next_mm) +extern void use_mm (struct mm_struct *mm); +# endif /* ! __ASSEMBLY__ */ #endif /* _ASM_IA64_MMU_CONTEXT_H */
kernel/sys.c +1 -1
@@ -516,7 +516,7 @@return -EINVAL ; }notifier_call_chain (&reboot_notifier_list,SYS_RESTART ,NULL ); - system_state =SYSTEM_BOOTING ; + system_state =SYSTEM_RESTART ;device_shutdown ();printk (KERN_EMERG "Starting new kernel\n" );machine_shutdown ();
Re: [PATCH] Fix for kexec reboot failing after multiple continued kexec reboots
Quoted 10 lines · Khalid Aziz
kexec patch I had sent out earlier has bug where it appends "
kexec_reboot" to kernel parameters blindly. After several kexec reboots from kexec'd kernel, kernel parameters line becomes too long and kernel fails to boot. Attached patch will cure this. Patch kexec-ia64-reboot.diff can be applied on top of the previous patch I had sent. Patch 2.6.8.1-kexec3-ia64-2.diff includes this fix and is repalcement for my previous patch.My current kexec patches for ia64 can also be found at
<http://free.linux.hp.com/~khalid/kexec-ia64/>.
This is really neat! It patched pretty cleanly against the latest bk (this stuff should get into -mm asap to help prevent it from getting stale) and my new boot got this far:
[root@flatearth ~]# kexec -e
Starting new kernel
Linux version 2.6.10-rc2 ([email protected]) (gcc version 3.4.1) #1SMP Wed Nov 17 14:34:56 PST 2004
EFI v1.02 by SGI: SALsystab=0x3002514a60 ACPI 2.0=0x3002514b60 kexec'd kernel: Not virtualizing EFI
Number of logical nodes in system = 1
Number of memory chunks in system = 1
This may be due to the lack of args though, I'll fix it up so that the console= stuff is passed in correctly and then debug it further.
Thanks,
Jesse
Re: [PATCH] Fix for kexec reboot failing after multiple continued kexec reboots
In reply to Khalid AzizQuoted 13 lines · Jesse Barnes
This is really neat! It patched pretty cleanly against the latest bk (this stuff should get into -mm asap to help prevent it from getting stale) and my new boot got this far:
[root@flatearth ~]# kexec -e
Starting new kernel
Linux version 2.6.10-rc2 ([email protected]) (gcc version 3.4.1) #1SMP Wed Nov 17 14:34:56 PST 2004
EFI v1.02 by SGI: SALsystab=0x3002514a60 ACPI 2.0=0x3002514b60 kexec'd kernel: Not virtualizing EFI
Number of logical nodes in system = 1
Number of memory chunks in system = 1
Quoted 2 lines
This may be due to the lack of args though, I'll fix it up so that the console= stuff is passed in correctly and then debug it further.
It's dying in find_pernode_space. The efi memmap, though trimmed, should be ok at this point, so I'm still trying to figure out what's going on in that routine.
Jesse
Re: [PATCH] Fix for kexec reboot failing after multiple continued kexec reboots
In reply to Khalid AzizQuoted 3 lines · Jesse Barnes
It's dying in
find_pernode_space. The efi memmap, though trimmed, should be ok at this point, so I'm still trying to figure out what's going on in that routine.
Actually, it looks like the EFI memmap isn't the same between a regular boot
and a kexec boot even though I'm not messing with it via mem= or anything.
I check it in find_pernode_space and though the start is the same, the length isn't. In the kexec kernel, the length that's passed in is much bigger in fact.
Regular boot:find_pernode_space(0000003003000000, 0000000011000000, 0): pernodesize = 33783808 found space at 0000003003000000
kexec boot:find_pernode_space(0000003003000000, 0000000079000000, 0): pernodesize = 163840 found space at 0000003003000000
(the kexec kernel was configured for 2p, while the regular one was 512p, which explains the difference in pernodesize requirements). I think the kexec kernel is corrupting all sorts of important memory since it thinks it's got pages that it shouldn't be touching.
Thanks,
Jesse
Jesse,
EFI mem map gets trimmed by efi_memmap_walk(). What you are seeing might be the effect of trimming as opposed to corruption. Once we have code in place to save unmodified EFI memory map, kexec might work better for you.
--
Khalid
Quoted 26 lines · Jesse Barnes
Quoted 3 lines · Jesse Barnes
It's dying in
find_pernode_space. The efi memmap, though trimmed, should be ok at this point, so I'm still trying to figure out what's going on in that routine.Actually, it looks like the EFI memmap isn't the same between a regular boot
and a kexec boot even though I'm not messing with it via mem= or anything.
I check it infind_pernode_spaceand though the start is the same, the length isn't. In the kexec kernel, the length that's passed in is much bigger in fact.Regular boot:
find_pernode_space(0000003003000000, 0000000011000000, 0): pernodesize = 33783808 found space at 0000003003000000kexec boot:
find_pernode_space(0000003003000000, 0000000079000000, 0): pernodesize = 163840 found space at 0000003003000000(the kexec kernel was configured for 2p, while the regular one was 512p, which explains the difference in pernodesize requirements). I think the kexec kernel is corrupting all sorts of important memory since it thinks it's got pages that it shouldn't be touching.
Thanks,
Jesse
Signature · 7 lines
================================== Khalid Aziz Linux and Open Source Lab (970)898-9214 Hewlett-Packard [email protected] Fort Collins, CO "The Linux kernel is subject to relentless development" - Alessandro Rubini