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

Add xen and xen-common

  • Property svn:mime-type set to text/x-patch
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 
    2828static u32 kexec_pte0[1024] PAGE_ALIGNED;
    2929static u32 kexec_pte1[1024] PAGE_ALIGNED;
    3030
    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) #X
    57 #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 STR
    70 #undef __STR
    71 }
    72 
    7331/*
    7432 * A architecture hook called to validate the
    7533 * proposed image and prepare the control pages
    NORET_TYPE void machine_kexec(struct kim 
    12684        page_list[PA_PTE_1] = __pa(kexec_pte1);
    12785        page_list[VA_PTE_1] = (unsigned long)kexec_pte1;
    12886
    129         /* The segment registers are funny things, they have both a
    130          * visible and an invisible part.  Whenever the visible part is
    131          * set to a specific selector, the invisible part is loaded
    132          * with from a table in memory.  At no other time is the
    133          * descriptor table in memory accessed.
    134          *
    135          * I take advantage of this here by force loading the
    136          * 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 */
    14687        relocate_kernel((unsigned long)image->head, (unsigned long)page_list,
    14788                        image->start, cpu_has_pae);
    14889}
  • 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: 
    154154        movl    PTR(PA_PGD)(%ebp), %eax
    155155        movl    %eax, %cr3
    156156
     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       
    157181        /* setup a new stack at the end of the physical control page */
    158182        lea     4096(%edi), %esp
    159183
    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
    165196
    166197identity_mapped:
    167198        /* store the start address on the stack */
    identity_mapped: 
    250281        xorl    %edi, %edi
    251282        xorl    %ebp, %ebp
    252283        ret
     284
     285        .align  16
     286gdt:
     287        .quad   0x0000000000000000      /* NULL descriptor */
     288gdt_cs:
     289        .quad   0x00cf9a000000ffff      /* kernel 4GB code at 0x00000000 */
     290gdt_ds:
     291        .quad   0x00cf92000000ffff      /* kernel 4GB data at 0x00000000 */
     292gdt_end:
     293       
     294gdt_48:
     295        .word   gdt_end - gdt - 1       /* limit */
     296        .long   0                       /* base - filled in by code above */
     297
     298idt_48:
     299        .word   0                       /* limit */
     300        .long   0                       /* base */
Note: See TracBrowser for help on using the repository browser.