Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (C) 2003,2004  Eric Biederman (ebiederm@xmission.com)
0004  * Copyright (C) 2014  Red Hat Inc.
0005 
0006  * Author(s): Vivek Goyal <vgoyal@redhat.com>
0007  *
0008  * This code has been taken from kexec-tools.
0009  */
0010 
0011 #include <linux/linkage.h>
0012 
0013     .text
0014     .balign 16
0015     .code64
0016 
0017 SYM_CODE_START(entry64)
0018     /* Setup a gdt that should be preserved */
0019     lgdt gdt(%rip)
0020 
0021     /* load the data segments */
0022     movl    $0x18, %eax     /* data segment */
0023     movl    %eax, %ds
0024     movl    %eax, %es
0025     movl    %eax, %ss
0026     movl    %eax, %fs
0027     movl    %eax, %gs
0028 
0029     /* Setup new stack */
0030     leaq    stack_init(%rip), %rsp
0031     pushq   $0x10 /* CS */
0032     leaq    new_cs_exit(%rip), %rax
0033     pushq   %rax
0034     lretq
0035 new_cs_exit:
0036 
0037     /* Load the registers */
0038     movq    rax(%rip), %rax
0039     movq    rbx(%rip), %rbx
0040     movq    rcx(%rip), %rcx
0041     movq    rdx(%rip), %rdx
0042     movq    rsi(%rip), %rsi
0043     movq    rdi(%rip), %rdi
0044     movq    rsp(%rip), %rsp
0045     movq    rbp(%rip), %rbp
0046     movq    r8(%rip), %r8
0047     movq    r9(%rip), %r9
0048     movq    r10(%rip), %r10
0049     movq    r11(%rip), %r11
0050     movq    r12(%rip), %r12
0051     movq    r13(%rip), %r13
0052     movq    r14(%rip), %r14
0053     movq    r15(%rip), %r15
0054 
0055     /* Jump to the new code... */
0056     jmpq    *rip(%rip)
0057 SYM_CODE_END(entry64)
0058 
0059     .section ".rodata"
0060     .balign 4
0061 SYM_DATA_START(entry64_regs)
0062 rax:    .quad 0x0
0063 rcx:    .quad 0x0
0064 rdx:    .quad 0x0
0065 rbx:    .quad 0x0
0066 rsp:    .quad 0x0
0067 rbp:    .quad 0x0
0068 rsi:    .quad 0x0
0069 rdi:    .quad 0x0
0070 r8: .quad 0x0
0071 r9: .quad 0x0
0072 r10:    .quad 0x0
0073 r11:    .quad 0x0
0074 r12:    .quad 0x0
0075 r13:    .quad 0x0
0076 r14:    .quad 0x0
0077 r15:    .quad 0x0
0078 rip:    .quad 0x0
0079 SYM_DATA_END(entry64_regs)
0080 
0081     /* GDT */
0082     .section ".rodata"
0083     .balign 16
0084 SYM_DATA_START_LOCAL(gdt)
0085     /*
0086      * 0x00 unusable segment
0087      * 0x08 unused
0088      * so use them as gdt ptr
0089      */
0090     .word gdt_end - gdt - 1
0091     .quad gdt
0092     .word 0, 0, 0
0093 
0094     /* 0x10 4GB flat code segment */
0095     .word 0xFFFF, 0x0000, 0x9A00, 0x00AF
0096 
0097     /* 0x18 4GB flat data segment */
0098     .word 0xFFFF, 0x0000, 0x9200, 0x00CF
0099 SYM_DATA_END_LABEL(gdt, SYM_L_LOCAL, gdt_end)
0100 
0101 SYM_DATA_START_LOCAL(stack)
0102     .quad   0, 0
0103 SYM_DATA_END_LABEL(stack, SYM_L_LOCAL, stack_init)