source:
trunk/packages/xen-3.1/xen-3.1/patches/linux-2.6.18/linux-2.6.19-rc1-kexec-move_segment_code-i386.patch
@
34
Last change on this file since 34 was 34, checked in by hartmans, 18 years ago | |
---|---|
|
|
File size: 4.0 KB |
-
arch/i386/kernel/machine_kexec.c
diff -pruN ../orig-linux-2.6.18/arch/i386/kernel/machine_kexec.c ./arch/i386/kernel/machine_kexec.c
old new static u32 kexec_pmd1[1024] PAGE_ALIGNED 28 28 static u32 kexec_pte0[1024] PAGE_ALIGNED; 29 29 static u32 kexec_pte1[1024] PAGE_ALIGNED; 30 30 31 static void set_idt(void *newidt, __u16 limit)32 {33 struct Xgt_desc_struct curidt;34 35 /* ia32 supports unaliged loads & stores */36 curidt.size = limit;37 curidt.address = (unsigned long)newidt;38 39 load_idt(&curidt);40 };41 42 43 static void set_gdt(void *newgdt, __u16 limit)44 {45 struct Xgt_desc_struct curgdt;46 47 /* ia32 supports unaligned loads & stores */48 curgdt.size = limit;49 curgdt.address = (unsigned long)newgdt;50 51 load_gdt(&curgdt);52 };53 54 static void load_segments(void)55 {56 #define __STR(X) #X57 #define STR(X) __STR(X)58 59 __asm__ __volatile__ (60 "\tljmp $"STR(__KERNEL_CS)",$1f\n"61 "\t1:\n"62 "\tmovl $"STR(__KERNEL_DS)",%%eax\n"63 "\tmovl %%eax,%%ds\n"64 "\tmovl %%eax,%%es\n"65 "\tmovl %%eax,%%fs\n"66 "\tmovl %%eax,%%gs\n"67 "\tmovl %%eax,%%ss\n"68 ::: "eax", "memory");69 #undef STR70 #undef __STR71 }72 73 31 /* 74 32 * A architecture hook called to validate the 75 33 * proposed image and prepare the control pages … … NORET_TYPE void machine_kexec(struct kim 126 84 page_list[PA_PTE_1] = __pa(kexec_pte1); 127 85 page_list[VA_PTE_1] = (unsigned long)kexec_pte1; 128 86 129 /* The segment registers are funny things, they have both a130 * visible and an invisible part. Whenever the visible part is131 * set to a specific selector, the invisible part is loaded132 * with from a table in memory. At no other time is the133 * descriptor table in memory accessed.134 *135 * I take advantage of this here by force loading the136 * segments, before I zap the gdt with an invalid value.137 */138 load_segments();139 /* The gdt & idt are now invalid.140 * If you want to load them you must set up your own idt & gdt.141 */142 set_gdt(phys_to_virt(0),0);143 set_idt(phys_to_virt(0),0);144 145 /* now call it */146 87 relocate_kernel((unsigned long)image->head, (unsigned long)page_list, 147 88 image->start, cpu_has_pae); 148 89 } -
arch/i386/kernel/relocate_kernel.S
diff -pruN ../orig-linux-2.6.18/arch/i386/kernel/relocate_kernel.S ./arch/i386/kernel/relocate_kernel.S
old new relocate_new_kernel: 154 154 movl PTR(PA_PGD)(%ebp), %eax 155 155 movl %eax, %cr3 156 156 157 /* setup idt */ 158 movl %edi, %eax 159 addl $(idt_48 - relocate_kernel), %eax 160 lidtl (%eax) 161 162 /* setup gdt */ 163 movl %edi, %eax 164 addl $(gdt - relocate_kernel), %eax 165 movl %edi, %esi 166 addl $((gdt_48 - relocate_kernel) + 2), %esi 167 movl %eax, (%esi) 168 169 movl %edi, %eax 170 addl $(gdt_48 - relocate_kernel), %eax 171 lgdtl (%eax) 172 173 /* setup data segment registers */ 174 mov $(gdt_ds - gdt), %eax 175 mov %eax, %ds 176 mov %eax, %es 177 mov %eax, %fs 178 mov %eax, %gs 179 mov %eax, %ss 180 157 181 /* setup a new stack at the end of the physical control page */ 158 182 lea 4096(%edi), %esp 159 183 160 /* jump to identity mapped page */ 161 movl %edi, %eax 162 addl $(identity_mapped - relocate_kernel), %eax 163 pushl %eax 164 ret 184 /* load new code segment and jump to identity mapped page */ 185 movl %edi, %esi 186 xorl %eax, %eax 187 pushl %eax 188 pushl %esi 189 pushl %eax 190 movl $(gdt_cs - gdt), %eax 191 pushl %eax 192 movl %edi, %eax 193 addl $(identity_mapped - relocate_kernel),%eax 194 pushl %eax 195 iretl 165 196 166 197 identity_mapped: 167 198 /* store the start address on the stack */ … … identity_mapped: 250 281 xorl %edi, %edi 251 282 xorl %ebp, %ebp 252 283 ret 284 285 .align 16 286 gdt: 287 .quad 0x0000000000000000 /* NULL descriptor */ 288 gdt_cs: 289 .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */ 290 gdt_ds: 291 .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */ 292 gdt_end: 293 294 gdt_48: 295 .word gdt_end - gdt - 1 /* limit */ 296 .long 0 /* base - filled in by code above */ 297 298 idt_48: 299 .word 0 /* limit */ 300 .long 0 /* base */
Note: See TracBrowser
for help on using the repository browser.