ia64/xen-unstable

view patches/linux-2.6.18/linux-2.6.19-rc1-kexec-move_segment_code-i386.patch @ 14131:64d80037e524

Save elfnotes in VM sxpr under image/notes, and load them on restore.
Signed-off-by: Brendan Cully <brendan@cs.ubc.ca>
author kfraser@localhost.localdomain
date Mon Feb 26 09:59:56 2007 +0000 (2007-02-26)
parents 3adf00179a63
children
line source
1 diff -pruN ../orig-linux-2.6.18/arch/i386/kernel/machine_kexec.c ./arch/i386/kernel/machine_kexec.c
2 --- ../orig-linux-2.6.18/arch/i386/kernel/machine_kexec.c 2007-01-12 16:03:23.000000000 +0000
3 +++ ./arch/i386/kernel/machine_kexec.c 2007-01-12 16:03:37.000000000 +0000
4 @@ -28,48 +28,6 @@ static u32 kexec_pmd1[1024] PAGE_ALIGNED
5 static u32 kexec_pte0[1024] PAGE_ALIGNED;
6 static u32 kexec_pte1[1024] PAGE_ALIGNED;
8 -static void set_idt(void *newidt, __u16 limit)
9 -{
10 - struct Xgt_desc_struct curidt;
11 -
12 - /* ia32 supports unaliged loads & stores */
13 - curidt.size = limit;
14 - curidt.address = (unsigned long)newidt;
15 -
16 - load_idt(&curidt);
17 -};
18 -
19 -
20 -static void set_gdt(void *newgdt, __u16 limit)
21 -{
22 - struct Xgt_desc_struct curgdt;
23 -
24 - /* ia32 supports unaligned loads & stores */
25 - curgdt.size = limit;
26 - curgdt.address = (unsigned long)newgdt;
27 -
28 - load_gdt(&curgdt);
29 -};
30 -
31 -static void load_segments(void)
32 -{
33 -#define __STR(X) #X
34 -#define STR(X) __STR(X)
35 -
36 - __asm__ __volatile__ (
37 - "\tljmp $"STR(__KERNEL_CS)",$1f\n"
38 - "\t1:\n"
39 - "\tmovl $"STR(__KERNEL_DS)",%%eax\n"
40 - "\tmovl %%eax,%%ds\n"
41 - "\tmovl %%eax,%%es\n"
42 - "\tmovl %%eax,%%fs\n"
43 - "\tmovl %%eax,%%gs\n"
44 - "\tmovl %%eax,%%ss\n"
45 - ::: "eax", "memory");
46 -#undef STR
47 -#undef __STR
48 -}
49 -
50 /*
51 * A architecture hook called to validate the
52 * proposed image and prepare the control pages
53 @@ -126,23 +84,6 @@ NORET_TYPE void machine_kexec(struct kim
54 page_list[PA_PTE_1] = __pa(kexec_pte1);
55 page_list[VA_PTE_1] = (unsigned long)kexec_pte1;
57 - /* The segment registers are funny things, they have both a
58 - * visible and an invisible part. Whenever the visible part is
59 - * set to a specific selector, the invisible part is loaded
60 - * with from a table in memory. At no other time is the
61 - * descriptor table in memory accessed.
62 - *
63 - * I take advantage of this here by force loading the
64 - * segments, before I zap the gdt with an invalid value.
65 - */
66 - load_segments();
67 - /* The gdt & idt are now invalid.
68 - * If you want to load them you must set up your own idt & gdt.
69 - */
70 - set_gdt(phys_to_virt(0),0);
71 - set_idt(phys_to_virt(0),0);
72 -
73 - /* now call it */
74 relocate_kernel((unsigned long)image->head, (unsigned long)page_list,
75 image->start, cpu_has_pae);
76 }
77 diff -pruN ../orig-linux-2.6.18/arch/i386/kernel/relocate_kernel.S ./arch/i386/kernel/relocate_kernel.S
78 --- ../orig-linux-2.6.18/arch/i386/kernel/relocate_kernel.S 2007-01-12 16:03:23.000000000 +0000
79 +++ ./arch/i386/kernel/relocate_kernel.S 2007-01-12 16:03:37.000000000 +0000
80 @@ -154,14 +154,45 @@ relocate_new_kernel:
81 movl PTR(PA_PGD)(%ebp), %eax
82 movl %eax, %cr3
84 + /* setup idt */
85 + movl %edi, %eax
86 + addl $(idt_48 - relocate_kernel), %eax
87 + lidtl (%eax)
88 +
89 + /* setup gdt */
90 + movl %edi, %eax
91 + addl $(gdt - relocate_kernel), %eax
92 + movl %edi, %esi
93 + addl $((gdt_48 - relocate_kernel) + 2), %esi
94 + movl %eax, (%esi)
95 +
96 + movl %edi, %eax
97 + addl $(gdt_48 - relocate_kernel), %eax
98 + lgdtl (%eax)
99 +
100 + /* setup data segment registers */
101 + mov $(gdt_ds - gdt), %eax
102 + mov %eax, %ds
103 + mov %eax, %es
104 + mov %eax, %fs
105 + mov %eax, %gs
106 + mov %eax, %ss
107 +
108 /* setup a new stack at the end of the physical control page */
109 lea 4096(%edi), %esp
111 - /* jump to identity mapped page */
112 - movl %edi, %eax
113 - addl $(identity_mapped - relocate_kernel), %eax
114 - pushl %eax
115 - ret
116 + /* load new code segment and jump to identity mapped page */
117 + movl %edi, %esi
118 + xorl %eax, %eax
119 + pushl %eax
120 + pushl %esi
121 + pushl %eax
122 + movl $(gdt_cs - gdt), %eax
123 + pushl %eax
124 + movl %edi, %eax
125 + addl $(identity_mapped - relocate_kernel),%eax
126 + pushl %eax
127 + iretl
129 identity_mapped:
130 /* store the start address on the stack */
131 @@ -250,3 +281,20 @@ identity_mapped:
132 xorl %edi, %edi
133 xorl %ebp, %ebp
134 ret
135 +
136 + .align 16
137 +gdt:
138 + .quad 0x0000000000000000 /* NULL descriptor */
139 +gdt_cs:
140 + .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
141 +gdt_ds:
142 + .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
143 +gdt_end:
144 +
145 +gdt_48:
146 + .word gdt_end - gdt - 1 /* limit */
147 + .long 0 /* base - filled in by code above */
148 +
149 +idt_48:
150 + .word 0 /* limit */
151 + .long 0 /* base */