debuggers.hg
changeset 12845:562eee7568a8
[LINUX] Kexec: Reapply kexec patches to sparse tree.
Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
author | Ian Campbell <ian.campbell@xensource.com> |
---|---|
date | Fri Dec 08 11:47:09 2006 +0000 (2006-12-08) |
parents | d51e5a7317bb |
children | 6f0f80aa817d |
files | linux-2.6-xen-sparse/arch/i386/kernel/crash.c linux-2.6-xen-sparse/arch/i386/kernel/machine_kexec.c linux-2.6-xen-sparse/arch/x86_64/kernel/crash.c linux-2.6-xen-sparse/arch/x86_64/kernel/machine_kexec.c linux-2.6-xen-sparse/include/asm-i386/kexec.h linux-2.6-xen-sparse/include/asm-x86_64/kexec.h linux-2.6-xen-sparse/include/linux/kexec.h linux-2.6-xen-sparse/kernel/kexec.c |
line diff
1.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/crash.c Fri Dec 08 11:47:09 2006 +0000 1.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/crash.c Fri Dec 08 11:47:09 2006 +0000 1.3 @@ -90,6 +90,7 @@ static void crash_save_self(struct pt_re 1.4 crash_save_this_cpu(regs, cpu); 1.5 } 1.6 1.7 +#ifndef CONFIG_XEN 1.8 #ifdef CONFIG_SMP 1.9 static atomic_t waiting_for_crash_ipi; 1.10 1.11 @@ -158,6 +159,7 @@ static void nmi_shootdown_cpus(void) 1.12 /* There are no cpus to shootdown */ 1.13 } 1.14 #endif 1.15 +#endif /* CONFIG_XEN */ 1.16 1.17 void machine_crash_shutdown(struct pt_regs *regs) 1.18 { 1.19 @@ -174,10 +176,12 @@ void machine_crash_shutdown(struct pt_re 1.20 1.21 /* Make a note of crashing cpu. Will be used in NMI callback.*/ 1.22 crashing_cpu = smp_processor_id(); 1.23 +#ifndef CONFIG_XEN 1.24 nmi_shootdown_cpus(); 1.25 lapic_shutdown(); 1.26 #if defined(CONFIG_X86_IO_APIC) 1.27 disable_IO_APIC(); 1.28 #endif 1.29 +#endif /* CONFIG_XEN */ 1.30 crash_save_self(regs); 1.31 }
2.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/machine_kexec.c Fri Dec 08 11:47:09 2006 +0000 2.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/machine_kexec.c Fri Dec 08 11:47:09 2006 +0000 2.3 @@ -19,6 +19,10 @@ 2.4 #include <asm/desc.h> 2.5 #include <asm/system.h> 2.6 2.7 +#ifdef CONFIG_XEN 2.8 +#include <xen/interface/kexec.h> 2.9 +#endif 2.10 + 2.11 #define PAGE_ALIGNED __attribute__ ((__aligned__(PAGE_SIZE))) 2.12 static u32 kexec_pgd[1024] PAGE_ALIGNED; 2.13 #ifdef CONFIG_X86_PAE 2.14 @@ -28,6 +32,40 @@ static u32 kexec_pmd1[1024] PAGE_ALIGNED 2.15 static u32 kexec_pte0[1024] PAGE_ALIGNED; 2.16 static u32 kexec_pte1[1024] PAGE_ALIGNED; 2.17 2.18 +#ifdef CONFIG_XEN 2.19 + 2.20 +#define __ma(x) (pfn_to_mfn(__pa((x)) >> PAGE_SHIFT) << PAGE_SHIFT) 2.21 + 2.22 +#if PAGES_NR > KEXEC_XEN_NO_PAGES 2.23 +#error PAGES_NR is greater than KEXEC_XEN_NO_PAGES - Xen support will break 2.24 +#endif 2.25 + 2.26 +#if PA_CONTROL_PAGE != 0 2.27 +#error PA_CONTROL_PAGE is non zero - Xen support will break 2.28 +#endif 2.29 + 2.30 +void machine_kexec_setup_load_arg(xen_kexec_image_t *xki, struct kimage *image) 2.31 +{ 2.32 + void *control_page; 2.33 + 2.34 + memset(xki->page_list, 0, sizeof(xki->page_list)); 2.35 + 2.36 + control_page = page_address(image->control_code_page); 2.37 + memcpy(control_page, relocate_kernel, PAGE_SIZE); 2.38 + 2.39 + xki->page_list[PA_CONTROL_PAGE] = __ma(control_page); 2.40 + xki->page_list[PA_PGD] = __ma(kexec_pgd); 2.41 +#ifdef CONFIG_X86_PAE 2.42 + xki->page_list[PA_PMD_0] = __ma(kexec_pmd0); 2.43 + xki->page_list[PA_PMD_1] = __ma(kexec_pmd1); 2.44 +#endif 2.45 + xki->page_list[PA_PTE_0] = __ma(kexec_pte0); 2.46 + xki->page_list[PA_PTE_1] = __ma(kexec_pte1); 2.47 + 2.48 +} 2.49 + 2.50 +#endif /* CONFIG_XEN */ 2.51 + 2.52 /* 2.53 * A architecture hook called to validate the 2.54 * proposed image and prepare the control pages
3.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/crash.c Fri Dec 08 11:47:09 2006 +0000 3.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/crash.c Fri Dec 08 11:47:09 2006 +0000 3.3 @@ -92,6 +92,7 @@ static void crash_save_self(struct pt_re 3.4 crash_save_this_cpu(regs, cpu); 3.5 } 3.6 3.7 +#ifndef CONFIG_XEN 3.8 #ifdef CONFIG_SMP 3.9 static atomic_t waiting_for_crash_ipi; 3.10 3.11 @@ -156,6 +157,7 @@ static void nmi_shootdown_cpus(void) 3.12 /* There are no cpus to shootdown */ 3.13 } 3.14 #endif 3.15 +#endif /* CONFIG_XEN */ 3.16 3.17 void machine_crash_shutdown(struct pt_regs *regs) 3.18 { 3.19 @@ -173,6 +175,8 @@ void machine_crash_shutdown(struct pt_re 3.20 3.21 /* Make a note of crashing cpu. Will be used in NMI callback.*/ 3.22 crashing_cpu = smp_processor_id(); 3.23 + 3.24 +#ifndef CONFIG_XEN 3.25 nmi_shootdown_cpus(); 3.26 3.27 if(cpu_has_apic) 3.28 @@ -181,6 +185,6 @@ void machine_crash_shutdown(struct pt_re 3.29 #if defined(CONFIG_X86_IO_APIC) 3.30 disable_IO_APIC(); 3.31 #endif 3.32 - 3.33 +#endif /* CONFIG_XEN */ 3.34 crash_save_self(regs); 3.35 }
4.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/machine_kexec.c Fri Dec 08 11:47:09 2006 +0000 4.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/machine_kexec.c Fri Dec 08 11:47:09 2006 +0000 4.3 @@ -24,6 +24,104 @@ static u64 kexec_pud1[512] PAGE_ALIGNED; 4.4 static u64 kexec_pmd1[512] PAGE_ALIGNED; 4.5 static u64 kexec_pte1[512] PAGE_ALIGNED; 4.6 4.7 +#ifdef CONFIG_XEN 4.8 + 4.9 +/* In the case of Xen, override hypervisor functions to be able to create 4.10 + * a regular identity mapping page table... 4.11 + */ 4.12 + 4.13 +#include <xen/interface/kexec.h> 4.14 +#include <xen/interface/memory.h> 4.15 + 4.16 +#define x__pmd(x) ((pmd_t) { (x) } ) 4.17 +#define x__pud(x) ((pud_t) { (x) } ) 4.18 +#define x__pgd(x) ((pgd_t) { (x) } ) 4.19 + 4.20 +#define x_pmd_val(x) ((x).pmd) 4.21 +#define x_pud_val(x) ((x).pud) 4.22 +#define x_pgd_val(x) ((x).pgd) 4.23 + 4.24 +static inline void x_set_pmd(pmd_t *dst, pmd_t val) 4.25 +{ 4.26 + x_pmd_val(*dst) = x_pmd_val(val); 4.27 +} 4.28 + 4.29 +static inline void x_set_pud(pud_t *dst, pud_t val) 4.30 +{ 4.31 + x_pud_val(*dst) = phys_to_machine(x_pud_val(val)); 4.32 +} 4.33 + 4.34 +static inline void x_pud_clear (pud_t *pud) 4.35 +{ 4.36 + x_pud_val(*pud) = 0; 4.37 +} 4.38 + 4.39 +static inline void x_set_pgd(pgd_t *dst, pgd_t val) 4.40 +{ 4.41 + x_pgd_val(*dst) = phys_to_machine(x_pgd_val(val)); 4.42 +} 4.43 + 4.44 +static inline void x_pgd_clear (pgd_t * pgd) 4.45 +{ 4.46 + x_pgd_val(*pgd) = 0; 4.47 +} 4.48 + 4.49 +#define X__PAGE_KERNEL_LARGE_EXEC \ 4.50 + _PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_PSE 4.51 +#define X_KERNPG_TABLE _PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY 4.52 + 4.53 +#define __ma(x) (pfn_to_mfn(__pa((x)) >> PAGE_SHIFT) << PAGE_SHIFT) 4.54 + 4.55 +#if PAGES_NR > KEXEC_XEN_NO_PAGES 4.56 +#error PAGES_NR is greater than KEXEC_XEN_NO_PAGES - Xen support will break 4.57 +#endif 4.58 + 4.59 +#if PA_CONTROL_PAGE != 0 4.60 +#error PA_CONTROL_PAGE is non zero - Xen support will break 4.61 +#endif 4.62 + 4.63 +void machine_kexec_setup_load_arg(xen_kexec_image_t *xki, struct kimage *image) 4.64 +{ 4.65 + void *control_page; 4.66 + void *table_page; 4.67 + 4.68 + memset(xki->page_list, 0, sizeof(xki->page_list)); 4.69 + 4.70 + control_page = page_address(image->control_code_page) + PAGE_SIZE; 4.71 + memcpy(control_page, relocate_kernel, PAGE_SIZE); 4.72 + 4.73 + table_page = page_address(image->control_code_page); 4.74 + 4.75 + xki->page_list[PA_CONTROL_PAGE] = __ma(control_page); 4.76 + xki->page_list[PA_TABLE_PAGE] = __ma(table_page); 4.77 + 4.78 + xki->page_list[PA_PGD] = __ma(kexec_pgd); 4.79 + xki->page_list[PA_PUD_0] = __ma(kexec_pud0); 4.80 + xki->page_list[PA_PUD_1] = __ma(kexec_pud1); 4.81 + xki->page_list[PA_PMD_0] = __ma(kexec_pmd0); 4.82 + xki->page_list[PA_PMD_1] = __ma(kexec_pmd1); 4.83 + xki->page_list[PA_PTE_0] = __ma(kexec_pte0); 4.84 + xki->page_list[PA_PTE_1] = __ma(kexec_pte1); 4.85 +} 4.86 + 4.87 +#else /* CONFIG_XEN */ 4.88 + 4.89 +#define x__pmd(x) __pmd(x) 4.90 +#define x__pud(x) __pud(x) 4.91 +#define x__pgd(x) __pgd(x) 4.92 + 4.93 +#define x_set_pmd(x, y) set_pmd(x, y) 4.94 +#define x_set_pud(x, y) set_pud(x, y) 4.95 +#define x_set_pgd(x, y) set_pgd(x, y) 4.96 + 4.97 +#define x_pud_clear(x) pud_clear(x) 4.98 +#define x_pgd_clear(x) pgd_clear(x) 4.99 + 4.100 +#define X__PAGE_KERNEL_LARGE_EXEC __PAGE_KERNEL_LARGE_EXEC 4.101 +#define X_KERNPG_TABLE _KERNPG_TABLE 4.102 + 4.103 +#endif /* CONFIG_XEN */ 4.104 + 4.105 static void init_level2_page(pmd_t *level2p, unsigned long addr) 4.106 { 4.107 unsigned long end_addr; 4.108 @@ -31,7 +129,7 @@ static void init_level2_page(pmd_t *leve 4.109 addr &= PAGE_MASK; 4.110 end_addr = addr + PUD_SIZE; 4.111 while (addr < end_addr) { 4.112 - set_pmd(level2p++, __pmd(addr | __PAGE_KERNEL_LARGE_EXEC)); 4.113 + x_set_pmd(level2p++, x__pmd(addr | X__PAGE_KERNEL_LARGE_EXEC)); 4.114 addr += PMD_SIZE; 4.115 } 4.116 } 4.117 @@ -56,12 +154,12 @@ static int init_level3_page(struct kimag 4.118 } 4.119 level2p = (pmd_t *)page_address(page); 4.120 init_level2_page(level2p, addr); 4.121 - set_pud(level3p++, __pud(__pa(level2p) | _KERNPG_TABLE)); 4.122 + x_set_pud(level3p++, x__pud(__pa(level2p) | X_KERNPG_TABLE)); 4.123 addr += PUD_SIZE; 4.124 } 4.125 /* clear the unused entries */ 4.126 while (addr < end_addr) { 4.127 - pud_clear(level3p++); 4.128 + x_pud_clear(level3p++); 4.129 addr += PUD_SIZE; 4.130 } 4.131 out: 4.132 @@ -92,12 +190,12 @@ static int init_level4_page(struct kimag 4.133 if (result) { 4.134 goto out; 4.135 } 4.136 - set_pgd(level4p++, __pgd(__pa(level3p) | _KERNPG_TABLE)); 4.137 + x_set_pgd(level4p++, x__pgd(__pa(level3p) | X_KERNPG_TABLE)); 4.138 addr += PGDIR_SIZE; 4.139 } 4.140 /* clear the unused entries */ 4.141 while (addr < end_addr) { 4.142 - pgd_clear(level4p++); 4.143 + x_pgd_clear(level4p++); 4.144 addr += PGDIR_SIZE; 4.145 } 4.146 out: 4.147 @@ -108,8 +206,14 @@ out: 4.148 static int init_pgtable(struct kimage *image, unsigned long start_pgtable) 4.149 { 4.150 pgd_t *level4p; 4.151 + unsigned long x_end_pfn = end_pfn; 4.152 + 4.153 +#ifdef CONFIG_XEN 4.154 + x_end_pfn = HYPERVISOR_memory_op(XENMEM_maximum_ram_page, NULL); 4.155 +#endif 4.156 + 4.157 level4p = (pgd_t *)__va(start_pgtable); 4.158 - return init_level4_page(image, level4p, 0, end_pfn << PAGE_SHIFT); 4.159 + return init_level4_page(image, level4p, 0, x_end_pfn << PAGE_SHIFT); 4.160 } 4.161 4.162 int machine_kexec_prepare(struct kimage *image)
5.1 --- a/linux-2.6-xen-sparse/include/asm-i386/kexec.h Fri Dec 08 11:47:09 2006 +0000 5.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/kexec.h Fri Dec 08 11:47:09 2006 +0000 5.3 @@ -98,6 +98,20 @@ relocate_kernel(unsigned long indirectio 5.4 unsigned long start_address, 5.5 unsigned int has_pae) ATTRIB_NORET; 5.6 5.7 + 5.8 +/* Under Xen we need to work with machine addresses. These macros give the 5.9 + * machine address of a certain page to the generic kexec code instead of 5.10 + * the pseudo physical address which would be given by the default macros. 5.11 + */ 5.12 + 5.13 +#ifdef CONFIG_XEN 5.14 +#define KEXEC_ARCH_HAS_PAGE_MACROS 5.15 +#define kexec_page_to_pfn(page) pfn_to_mfn(page_to_pfn(page)) 5.16 +#define kexec_pfn_to_page(pfn) pfn_to_page(mfn_to_pfn(pfn)) 5.17 +#define kexec_virt_to_phys(addr) virt_to_machine(addr) 5.18 +#define kexec_phys_to_virt(addr) phys_to_virt(machine_to_phys(addr)) 5.19 +#endif 5.20 + 5.21 #endif /* __ASSEMBLY__ */ 5.22 5.23 #endif /* _I386_KEXEC_H */
6.1 --- a/linux-2.6-xen-sparse/include/asm-x86_64/kexec.h Fri Dec 08 11:47:09 2006 +0000 6.2 +++ b/linux-2.6-xen-sparse/include/asm-x86_64/kexec.h Fri Dec 08 11:47:09 2006 +0000 6.3 @@ -91,6 +91,19 @@ relocate_kernel(unsigned long indirectio 6.4 unsigned long page_list, 6.5 unsigned long start_address) ATTRIB_NORET; 6.6 6.7 +/* Under Xen we need to work with machine addresses. These macros give the 6.8 + * machine address of a certain page to the generic kexec code instead of 6.9 + * the pseudo physical address which would be given by the default macros. 6.10 + */ 6.11 + 6.12 +#ifdef CONFIG_XEN 6.13 +#define KEXEC_ARCH_HAS_PAGE_MACROS 6.14 +#define kexec_page_to_pfn(page) pfn_to_mfn(page_to_pfn(page)) 6.15 +#define kexec_pfn_to_page(pfn) pfn_to_page(mfn_to_pfn(pfn)) 6.16 +#define kexec_virt_to_phys(addr) virt_to_machine(addr) 6.17 +#define kexec_phys_to_virt(addr) phys_to_virt(machine_to_phys(addr)) 6.18 +#endif 6.19 + 6.20 #endif /* __ASSEMBLY__ */ 6.21 6.22 #endif /* _X86_64_KEXEC_H */
7.1 --- a/linux-2.6-xen-sparse/include/linux/kexec.h Fri Dec 08 11:47:09 2006 +0000 7.2 +++ b/linux-2.6-xen-sparse/include/linux/kexec.h Fri Dec 08 11:47:09 2006 +0000 7.3 @@ -31,6 +31,13 @@ 7.4 #error KEXEC_ARCH not defined 7.5 #endif 7.6 7.7 +#ifndef KEXEC_ARCH_HAS_PAGE_MACROS 7.8 +#define kexec_page_to_pfn(page) page_to_pfn(page) 7.9 +#define kexec_pfn_to_page(pfn) pfn_to_page(pfn) 7.10 +#define kexec_virt_to_phys(addr) virt_to_phys(addr) 7.11 +#define kexec_phys_to_virt(addr) phys_to_virt(addr) 7.12 +#endif 7.13 + 7.14 /* 7.15 * This structure is used to hold the arguments that are used when loading 7.16 * kernel binaries. 7.17 @@ -91,6 +98,13 @@ struct kimage { 7.18 extern NORET_TYPE void machine_kexec(struct kimage *image) ATTRIB_NORET; 7.19 extern int machine_kexec_prepare(struct kimage *image); 7.20 extern void machine_kexec_cleanup(struct kimage *image); 7.21 +#ifdef CONFIG_XEN 7.22 +extern int xen_machine_kexec_load(struct kimage *image); 7.23 +extern void xen_machine_kexec_unload(struct kimage *image); 7.24 +extern NORET_TYPE void xen_machine_kexec(struct kimage *image) ATTRIB_NORET; 7.25 +extern void xen_machine_kexec_setup_resources(void); 7.26 +extern void xen_machine_kexec_register_resources(struct resource *res); 7.27 +#endif 7.28 extern asmlinkage long sys_kexec_load(unsigned long entry, 7.29 unsigned long nr_segments, 7.30 struct kexec_segment __user *segments,
8.1 --- a/linux-2.6-xen-sparse/kernel/kexec.c Fri Dec 08 11:47:09 2006 +0000 8.2 +++ b/linux-2.6-xen-sparse/kernel/kexec.c Fri Dec 08 11:47:09 2006 +0000 8.3 @@ -403,7 +403,7 @@ static struct page *kimage_alloc_normal_ 8.4 pages = kimage_alloc_pages(GFP_KERNEL, order); 8.5 if (!pages) 8.6 break; 8.7 - pfn = page_to_pfn(pages); 8.8 + pfn = kexec_page_to_pfn(pages); 8.9 epfn = pfn + count; 8.10 addr = pfn << PAGE_SHIFT; 8.11 eaddr = epfn << PAGE_SHIFT; 8.12 @@ -437,6 +437,7 @@ static struct page *kimage_alloc_normal_ 8.13 return pages; 8.14 } 8.15 8.16 +#ifndef CONFIG_XEN 8.17 static struct page *kimage_alloc_crash_control_pages(struct kimage *image, 8.18 unsigned int order) 8.19 { 8.20 @@ -490,7 +491,7 @@ static struct page *kimage_alloc_crash_c 8.21 } 8.22 /* If I don't overlap any segments I have found my hole! */ 8.23 if (i == image->nr_segments) { 8.24 - pages = pfn_to_page(hole_start >> PAGE_SHIFT); 8.25 + pages = kexec_pfn_to_page(hole_start >> PAGE_SHIFT); 8.26 break; 8.27 } 8.28 } 8.29 @@ -517,6 +518,13 @@ struct page *kimage_alloc_control_pages( 8.30 8.31 return pages; 8.32 } 8.33 +#else /* !CONFIG_XEN */ 8.34 +struct page *kimage_alloc_control_pages(struct kimage *image, 8.35 + unsigned int order) 8.36 +{ 8.37 + return kimage_alloc_normal_control_pages(image, order); 8.38 +} 8.39 +#endif 8.40 8.41 static int kimage_add_entry(struct kimage *image, kimage_entry_t entry) 8.42 { 8.43 @@ -532,7 +540,7 @@ static int kimage_add_entry(struct kimag 8.44 return -ENOMEM; 8.45 8.46 ind_page = page_address(page); 8.47 - *image->entry = virt_to_phys(ind_page) | IND_INDIRECTION; 8.48 + *image->entry = kexec_virt_to_phys(ind_page) | IND_INDIRECTION; 8.49 image->entry = ind_page; 8.50 image->last_entry = ind_page + 8.51 ((PAGE_SIZE/sizeof(kimage_entry_t)) - 1); 8.52 @@ -593,13 +601,13 @@ static int kimage_terminate(struct kimag 8.53 #define for_each_kimage_entry(image, ptr, entry) \ 8.54 for (ptr = &image->head; (entry = *ptr) && !(entry & IND_DONE); \ 8.55 ptr = (entry & IND_INDIRECTION)? \ 8.56 - phys_to_virt((entry & PAGE_MASK)): ptr +1) 8.57 + kexec_phys_to_virt((entry & PAGE_MASK)): ptr +1) 8.58 8.59 static void kimage_free_entry(kimage_entry_t entry) 8.60 { 8.61 struct page *page; 8.62 8.63 - page = pfn_to_page(entry >> PAGE_SHIFT); 8.64 + page = kexec_pfn_to_page(entry >> PAGE_SHIFT); 8.65 kimage_free_pages(page); 8.66 } 8.67 8.68 @@ -611,6 +619,10 @@ static void kimage_free(struct kimage *i 8.69 if (!image) 8.70 return; 8.71 8.72 +#ifdef CONFIG_XEN 8.73 + xen_machine_kexec_unload(image); 8.74 +#endif 8.75 + 8.76 kimage_free_extra_pages(image); 8.77 for_each_kimage_entry(image, ptr, entry) { 8.78 if (entry & IND_INDIRECTION) { 8.79 @@ -686,7 +698,7 @@ static struct page *kimage_alloc_page(st 8.80 * have a match. 8.81 */ 8.82 list_for_each_entry(page, &image->dest_pages, lru) { 8.83 - addr = page_to_pfn(page) << PAGE_SHIFT; 8.84 + addr = kexec_page_to_pfn(page) << PAGE_SHIFT; 8.85 if (addr == destination) { 8.86 list_del(&page->lru); 8.87 return page; 8.88 @@ -701,12 +713,12 @@ static struct page *kimage_alloc_page(st 8.89 if (!page) 8.90 return NULL; 8.91 /* If the page cannot be used file it away */ 8.92 - if (page_to_pfn(page) > 8.93 + if (kexec_page_to_pfn(page) > 8.94 (KEXEC_SOURCE_MEMORY_LIMIT >> PAGE_SHIFT)) { 8.95 list_add(&page->lru, &image->unuseable_pages); 8.96 continue; 8.97 } 8.98 - addr = page_to_pfn(page) << PAGE_SHIFT; 8.99 + addr = kexec_page_to_pfn(page) << PAGE_SHIFT; 8.100 8.101 /* If it is the destination page we want use it */ 8.102 if (addr == destination) 8.103 @@ -729,7 +741,7 @@ static struct page *kimage_alloc_page(st 8.104 struct page *old_page; 8.105 8.106 old_addr = *old & PAGE_MASK; 8.107 - old_page = pfn_to_page(old_addr >> PAGE_SHIFT); 8.108 + old_page = kexec_pfn_to_page(old_addr >> PAGE_SHIFT); 8.109 copy_highpage(page, old_page); 8.110 *old = addr | (*old & ~PAGE_MASK); 8.111 8.112 @@ -779,7 +791,7 @@ static int kimage_load_normal_segment(st 8.113 result = -ENOMEM; 8.114 goto out; 8.115 } 8.116 - result = kimage_add_page(image, page_to_pfn(page) 8.117 + result = kimage_add_page(image, kexec_page_to_pfn(page) 8.118 << PAGE_SHIFT); 8.119 if (result < 0) 8.120 goto out; 8.121 @@ -811,6 +823,7 @@ out: 8.122 return result; 8.123 } 8.124 8.125 +#ifndef CONFIG_XEN 8.126 static int kimage_load_crash_segment(struct kimage *image, 8.127 struct kexec_segment *segment) 8.128 { 8.129 @@ -833,7 +846,7 @@ static int kimage_load_crash_segment(str 8.130 char *ptr; 8.131 size_t uchunk, mchunk; 8.132 8.133 - page = pfn_to_page(maddr >> PAGE_SHIFT); 8.134 + page = kexec_pfn_to_page(maddr >> PAGE_SHIFT); 8.135 if (page == 0) { 8.136 result = -ENOMEM; 8.137 goto out; 8.138 @@ -881,6 +894,13 @@ static int kimage_load_segment(struct ki 8.139 8.140 return result; 8.141 } 8.142 +#else /* CONFIG_XEN */ 8.143 +static int kimage_load_segment(struct kimage *image, 8.144 + struct kexec_segment *segment) 8.145 +{ 8.146 + return kimage_load_normal_segment(image, segment); 8.147 +} 8.148 +#endif 8.149 8.150 /* 8.151 * Exec Kernel system call: for obvious reasons only root may call it. 8.152 @@ -991,6 +1011,11 @@ asmlinkage long sys_kexec_load(unsigned 8.153 if (result) 8.154 goto out; 8.155 } 8.156 +#ifdef CONFIG_XEN 8.157 + result = xen_machine_kexec_load(image); 8.158 + if (result) 8.159 + goto out; 8.160 +#endif 8.161 /* Install the new kernel, and Uninstall the old */ 8.162 image = xchg(dest_image, image); 8.163 8.164 @@ -1045,7 +1070,6 @@ void crash_kexec(struct pt_regs *regs) 8.165 struct kimage *image; 8.166 int locked; 8.167 8.168 - 8.169 /* Take the kexec_lock here to prevent sys_kexec_load 8.170 * running on one cpu from replacing the crash kernel 8.171 * we are using after a panic on a different cpu. 8.172 @@ -1061,7 +1085,11 @@ void crash_kexec(struct pt_regs *regs) 8.173 struct pt_regs fixed_regs; 8.174 crash_setup_regs(&fixed_regs, regs); 8.175 machine_crash_shutdown(&fixed_regs); 8.176 +#ifdef CONFIG_XEN 8.177 + xen_machine_kexec(image); 8.178 +#else 8.179 machine_kexec(image); 8.180 +#endif 8.181 } 8.182 xchg(&kexec_lock, 0); 8.183 }