ia64/xen-unstable

view patches/linux-2.6.18/linux-2.6.19-rc1-kexec-move_segment_code-x86_64.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/x86_64/kernel/machine_kexec.c ./arch/x86_64/kernel/machine_kexec.c
2 --- ../orig-linux-2.6.18/arch/x86_64/kernel/machine_kexec.c 2007-01-12 16:03:49.000000000 +0000
3 +++ ./arch/x86_64/kernel/machine_kexec.c 2007-01-12 16:04:02.000000000 +0000
4 @@ -112,47 +112,6 @@ static int init_pgtable(struct kimage *i
5 return init_level4_page(image, level4p, 0, end_pfn << PAGE_SHIFT);
6 }
8 -static void set_idt(void *newidt, u16 limit)
9 -{
10 - struct desc_ptr curidt;
11 -
12 - /* x86-64 supports unaliged loads & stores */
13 - curidt.size = limit;
14 - curidt.address = (unsigned long)newidt;
15 -
16 - __asm__ __volatile__ (
17 - "lidtq %0\n"
18 - : : "m" (curidt)
19 - );
20 -};
21 -
22 -
23 -static void set_gdt(void *newgdt, u16 limit)
24 -{
25 - struct desc_ptr curgdt;
26 -
27 - /* x86-64 supports unaligned loads & stores */
28 - curgdt.size = limit;
29 - curgdt.address = (unsigned long)newgdt;
30 -
31 - __asm__ __volatile__ (
32 - "lgdtq %0\n"
33 - : : "m" (curgdt)
34 - );
35 -};
36 -
37 -static void load_segments(void)
38 -{
39 - __asm__ __volatile__ (
40 - "\tmovl %0,%%ds\n"
41 - "\tmovl %0,%%es\n"
42 - "\tmovl %0,%%ss\n"
43 - "\tmovl %0,%%fs\n"
44 - "\tmovl %0,%%gs\n"
45 - : : "a" (__KERNEL_DS) : "memory"
46 - );
47 -}
48 -
49 int machine_kexec_prepare(struct kimage *image)
50 {
51 unsigned long start_pgtable;
52 @@ -209,23 +168,6 @@ NORET_TYPE void machine_kexec(struct kim
53 page_list[PA_TABLE_PAGE] =
54 (unsigned long)__pa(page_address(image->control_code_page));
56 - /* The segment registers are funny things, they have both a
57 - * visible and an invisible part. Whenever the visible part is
58 - * set to a specific selector, the invisible part is loaded
59 - * with from a table in memory. At no other time is the
60 - * descriptor table in memory accessed.
61 - *
62 - * I take advantage of this here by force loading the
63 - * segments, before I zap the gdt with an invalid value.
64 - */
65 - load_segments();
66 - /* The gdt & idt are now invalid.
67 - * If you want to load them you must set up your own idt & gdt.
68 - */
69 - set_gdt(phys_to_virt(0),0);
70 - set_idt(phys_to_virt(0),0);
71 -
72 - /* now call it */
73 relocate_kernel((unsigned long)image->head, (unsigned long)page_list,
74 image->start);
75 }
76 diff -pruN ../orig-linux-2.6.18/arch/x86_64/kernel/relocate_kernel.S ./arch/x86_64/kernel/relocate_kernel.S
77 --- ../orig-linux-2.6.18/arch/x86_64/kernel/relocate_kernel.S 2007-01-12 16:03:49.000000000 +0000
78 +++ ./arch/x86_64/kernel/relocate_kernel.S 2007-01-12 16:04:02.000000000 +0000
79 @@ -159,13 +159,39 @@ relocate_new_kernel:
80 movq PTR(PA_PGD)(%rsi), %r9
81 movq %r9, %cr3
83 + /* setup idt */
84 + movq %r8, %rax
85 + addq $(idt_80 - relocate_kernel), %rax
86 + lidtq (%rax)
87 +
88 + /* setup gdt */
89 + movq %r8, %rax
90 + addq $(gdt - relocate_kernel), %rax
91 + movq %r8, %r9
92 + addq $((gdt_80 - relocate_kernel) + 2), %r9
93 + movq %rax, (%r9)
94 +
95 + movq %r8, %rax
96 + addq $(gdt_80 - relocate_kernel), %rax
97 + lgdtq (%rax)
98 +
99 + /* setup data segment registers */
100 + xorl %eax, %eax
101 + movl %eax, %ds
102 + movl %eax, %es
103 + movl %eax, %fs
104 + movl %eax, %gs
105 + movl %eax, %ss
106 +
107 /* setup a new stack at the end of the physical control page */
108 lea 4096(%r8), %rsp
110 - /* jump to identity mapped page */
111 - addq $(identity_mapped - relocate_kernel), %r8
112 - pushq %r8
113 - ret
114 + /* load new code segment and jump to identity mapped page */
115 + movq %r8, %rax
116 + addq $(identity_mapped - relocate_kernel), %rax
117 + pushq $(gdt_cs - gdt)
118 + pushq %rax
119 + lretq
121 identity_mapped:
122 /* store the start address on the stack */
123 @@ -272,5 +298,19 @@ identity_mapped:
124 xorq %r13, %r13
125 xorq %r14, %r14
126 xorq %r15, %r15
127 -
128 ret
129 +
130 + .align 16
131 +gdt:
132 + .quad 0x0000000000000000 /* NULL descriptor */
133 +gdt_cs:
134 + .quad 0x00af9a000000ffff
135 +gdt_end:
136 +
137 +gdt_80:
138 + .word gdt_end - gdt - 1 /* limit */
139 + .quad 0 /* base - filled in by code above */
140 +
141 +idt_80:
142 + .word 0 /* limit */
143 + .quad 0 /* base */