Patrick Georgi | 11f0079 | 2020-03-04 15:10:45 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Martin Roth | 9df9e939 | 2016-01-12 15:55:28 -0700 | [diff] [blame] | 2 | |
Stefan Reinauer | 5f5436f | 2010-04-25 20:42:02 +0000 | [diff] [blame] | 3 | #include <cpu/x86/post_code.h> |
Patrick Rudolph | 776da08 | 2019-10-25 08:09:33 +0200 | [diff] [blame] | 4 | #include <arch/ram_segs.h> |
Eric Biederman | f8a2ddd | 2004-10-30 08:05:41 +0000 | [diff] [blame] | 5 | |
Aaron Durbin | 633f112 | 2013-02-06 15:28:40 -0600 | [diff] [blame] | 6 | /* Place the stack in the bss section. It's not necessary to define it in the |
| 7 | * the linker script. */ |
| 8 | .section .bss, "aw", @nobits |
| 9 | .global _stack |
| 10 | .global _estack |
Julius Werner | 82d16b1 | 2020-12-30 15:51:10 -0800 | [diff] [blame] | 11 | .global _stack_size |
Aaron Durbin | 633f112 | 2013-02-06 15:28:40 -0600 | [diff] [blame] | 12 | |
Kyösti Mälkki | 2fbb677 | 2018-05-15 19:50:20 +0300 | [diff] [blame] | 13 | /* Stack alignment is not enforced with rmodule loader, reserve one |
| 14 | * extra CPU such that alignment can be enforced on entry. */ |
Aaron Durbin | 633f112 | 2013-02-06 15:28:40 -0600 | [diff] [blame] | 15 | .align CONFIG_STACK_SIZE |
| 16 | _stack: |
Kyösti Mälkki | 2fbb677 | 2018-05-15 19:50:20 +0300 | [diff] [blame] | 17 | .space (CONFIG_MAX_CPUS+1)*CONFIG_STACK_SIZE |
Aaron Durbin | 633f112 | 2013-02-06 15:28:40 -0600 | [diff] [blame] | 18 | _estack: |
Julius Werner | 82d16b1 | 2020-12-30 15:51:10 -0800 | [diff] [blame] | 19 | .set _stack_size, _estack - _stack |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 20 | #if CONFIG(COOP_MULTITASKING) |
Aaron Durbin | 38c326d | 2013-05-06 12:22:23 -0500 | [diff] [blame] | 21 | .global thread_stacks |
| 22 | thread_stacks: |
| 23 | .space CONFIG_STACK_SIZE*CONFIG_NUM_THREADS |
| 24 | #endif |
Aaron Durbin | 633f112 | 2013-02-06 15:28:40 -0600 | [diff] [blame] | 25 | |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 26 | .section ".text._start", "ax", @progbits |
Stefan Reinauer | 9693885 | 2015-06-18 01:23:48 -0700 | [diff] [blame] | 27 | #ifdef __x86_64__ |
| 28 | .code64 |
| 29 | #else |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 30 | .code32 |
Stefan Reinauer | 9693885 | 2015-06-18 01:23:48 -0700 | [diff] [blame] | 31 | #endif |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 32 | .globl _start |
| 33 | _start: |
| 34 | cli |
Patrick Rudolph | d023909 | 2021-06-11 21:24:10 +0200 | [diff] [blame^] | 35 | #ifdef __x86_64__ |
| 36 | movabs $gdtaddr, %rax |
| 37 | lgdt (%rax) |
| 38 | #else |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 39 | lgdt %cs:gdtaddr |
Patrick Rudolph | 776da08 | 2019-10-25 08:09:33 +0200 | [diff] [blame] | 40 | ljmp $RAM_CODE_SEG, $1f |
Stefan Reinauer | 9693885 | 2015-06-18 01:23:48 -0700 | [diff] [blame] | 41 | #endif |
Patrick Rudolph | 776da08 | 2019-10-25 08:09:33 +0200 | [diff] [blame] | 42 | 1: movl $RAM_DATA_SEG, %eax |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 43 | movl %eax, %ds |
| 44 | movl %eax, %es |
| 45 | movl %eax, %ss |
| 46 | movl %eax, %fs |
| 47 | movl %eax, %gs |
Stefan Reinauer | 9693885 | 2015-06-18 01:23:48 -0700 | [diff] [blame] | 48 | #ifdef __x86_64__ |
Patrick Rudolph | 776da08 | 2019-10-25 08:09:33 +0200 | [diff] [blame] | 49 | mov $RAM_CODE_SEG64, %ecx |
Elyes HAOUAS | 2ea751a | 2018-12-27 09:21:02 +0100 | [diff] [blame] | 50 | call SetCodeSelector |
Stefan Reinauer | 9693885 | 2015-06-18 01:23:48 -0700 | [diff] [blame] | 51 | #endif |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 52 | |
Alexandru Gagniuc | 5005bb06 | 2011-04-11 20:17:22 +0000 | [diff] [blame] | 53 | post_code(POST_ENTRY_C_START) /* post 13 */ |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 54 | |
arch import user (historical) | 6ca7636 | 2005-07-06 17:17:25 +0000 | [diff] [blame] | 55 | cld |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 56 | |
Arthur Heymans | 7c9a0e8 | 2019-10-23 17:02:50 +0200 | [diff] [blame] | 57 | #ifdef __x86_64__ |
Patrick Rudolph | d023909 | 2021-06-11 21:24:10 +0200 | [diff] [blame^] | 58 | mov %rdi, %rax |
| 59 | movabs %rax, _cbmem_top_ptr |
| 60 | movabs $_stack, %rdi |
Arthur Heymans | 7c9a0e8 | 2019-10-23 17:02:50 +0200 | [diff] [blame] | 61 | #else |
| 62 | /* The return argument is at 0(%esp), the calling argument at 4(%esp) */ |
| 63 | movl 4(%esp), %eax |
| 64 | movl %eax, _cbmem_top_ptr |
Patrick Rudolph | d023909 | 2021-06-11 21:24:10 +0200 | [diff] [blame^] | 65 | leal _stack, %edi |
Arthur Heymans | 7c9a0e8 | 2019-10-23 17:02:50 +0200 | [diff] [blame] | 66 | #endif |
| 67 | |
Aaron Durbin | 633f112 | 2013-02-06 15:28:40 -0600 | [diff] [blame] | 68 | /** poison the stack. Code should not count on the |
| 69 | * stack being full of zeros. This stack poisoning |
| 70 | * recently uncovered a bug in the broadcast SIPI |
| 71 | * code. |
| 72 | */ |
Aaron Durbin | 633f112 | 2013-02-06 15:28:40 -0600 | [diff] [blame] | 73 | movl $_estack, %ecx |
| 74 | subl %edi, %ecx |
| 75 | shrl $2, %ecx /* it is 32 bit aligned, right? */ |
| 76 | movl $0xDEADBEEF, %eax |
| 77 | rep |
| 78 | stosl |
| 79 | |
Kyösti Mälkki | 2fbb677 | 2018-05-15 19:50:20 +0300 | [diff] [blame] | 80 | /* Set new stack with enforced alignment. */ |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 81 | movl $_estack, %esp |
Kyösti Mälkki | 2fbb677 | 2018-05-15 19:50:20 +0300 | [diff] [blame] | 82 | andl $(~(CONFIG_STACK_SIZE-1)), %esp |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 83 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 84 | #if CONFIG(COOP_MULTITASKING) |
Aaron Durbin | 38c326d | 2013-05-06 12:22:23 -0500 | [diff] [blame] | 85 | /* Push the thread pointer. */ |
Stefan Reinauer | 9693885 | 2015-06-18 01:23:48 -0700 | [diff] [blame] | 86 | push $0 |
Aaron Durbin | 38c326d | 2013-05-06 12:22:23 -0500 | [diff] [blame] | 87 | #endif |
Elyes HAOUAS | 777ea89 | 2016-07-29 07:40:41 +0200 | [diff] [blame] | 88 | /* Push the CPU index and struct CPU */ |
Stefan Reinauer | 9693885 | 2015-06-18 01:23:48 -0700 | [diff] [blame] | 89 | push $0 |
| 90 | push $0 |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 91 | |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 92 | /* |
| 93 | * Now we are finished. Memory is up, data is copied and |
| 94 | * bss is cleared. Now we call the main routine and |
| 95 | * let it do the rest. |
Stefan Reinauer | 607cdf6 | 2010-04-26 12:08:51 +0000 | [diff] [blame] | 96 | */ |
Subrata Banik | 38e4a2d | 2021-05-05 19:34:07 +0530 | [diff] [blame] | 97 | post_code(POST_PRE_HARDWAREMAIN) /* post 6e */ |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 98 | |
Kyösti Mälkki | 4796c32 | 2017-03-15 08:07:22 +0200 | [diff] [blame] | 99 | andl $0xFFFFFFF0, %esp |
| 100 | |
Harshit Sharma | 9c88fb8 | 2020-06-17 20:19:00 -0700 | [diff] [blame] | 101 | #if CONFIG(ASAN_IN_RAMSTAGE) |
| 102 | call asan_init |
| 103 | #endif |
| 104 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 105 | #if CONFIG(GDB_WAIT) |
Kyösti Mälkki | f2f7f03 | 2014-04-04 15:05:28 +0300 | [diff] [blame] | 106 | call gdb_hw_init |
Denis 'GNUtoo' Carikli | e4cece0 | 2012-06-22 15:56:37 +0200 | [diff] [blame] | 107 | call gdb_stub_breakpoint |
| 108 | #endif |
Stefan Reinauer | 6adef08 | 2013-05-09 16:30:06 -0700 | [diff] [blame] | 109 | call main |
Stefan Reinauer | 607cdf6 | 2010-04-26 12:08:51 +0000 | [diff] [blame] | 110 | /* NOTREACHED */ |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 111 | .Lhlt: |
Alexandru Gagniuc | 5005bb06 | 2011-04-11 20:17:22 +0000 | [diff] [blame] | 112 | post_code(POST_DEAD_CODE) /* post ee */ |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 113 | hlt |
| 114 | jmp .Lhlt |
Stefan Reinauer | 607cdf6 | 2010-04-26 12:08:51 +0000 | [diff] [blame] | 115 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 116 | #if CONFIG(GDB_WAIT) |
Eric Biederman | f8a2ddd | 2004-10-30 08:05:41 +0000 | [diff] [blame] | 117 | |
| 118 | .globl gdb_stub_breakpoint |
| 119 | gdb_stub_breakpoint: |
Stefan Reinauer | 9693885 | 2015-06-18 01:23:48 -0700 | [diff] [blame] | 120 | #ifdef __x86_64__ |
| 121 | pop %rax /* Return address */ |
| 122 | pushfl |
| 123 | push %cs |
| 124 | push %rax /* Return address */ |
| 125 | push $0 /* No error code */ |
| 126 | push $32 /* vector 32 is user defined */ |
| 127 | #else |
Eric Biederman | f8a2ddd | 2004-10-30 08:05:41 +0000 | [diff] [blame] | 128 | popl %eax /* Return address */ |
Stefan Reinauer | 607cdf6 | 2010-04-26 12:08:51 +0000 | [diff] [blame] | 129 | pushfl |
Eric Biederman | f8a2ddd | 2004-10-30 08:05:41 +0000 | [diff] [blame] | 130 | pushl %cs |
| 131 | pushl %eax /* Return address */ |
| 132 | pushl $0 /* No error code */ |
| 133 | pushl $32 /* vector 32 is user defined */ |
Stefan Reinauer | 9693885 | 2015-06-18 01:23:48 -0700 | [diff] [blame] | 134 | #endif |
Eric Biederman | f8a2ddd | 2004-10-30 08:05:41 +0000 | [diff] [blame] | 135 | jmp int_hand |
Eric Biederman | f8a2ddd | 2004-10-30 08:05:41 +0000 | [diff] [blame] | 136 | #endif |
| 137 | |
Aaron Durbin | 4b032e4 | 2018-04-20 01:39:30 -0600 | [diff] [blame] | 138 | .globl gdt, gdt_end |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 139 | |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 140 | gdtaddr: |
Aaron Durbin | a146d58 | 2013-02-08 16:56:51 -0600 | [diff] [blame] | 141 | .word gdt_end - gdt - 1 |
Stefan Reinauer | 9693885 | 2015-06-18 01:23:48 -0700 | [diff] [blame] | 142 | #ifdef __x86_64__ |
| 143 | .quad gdt |
| 144 | #else |
Li-Ta Lo | f84926e | 2004-11-04 18:36:06 +0000 | [diff] [blame] | 145 | .long gdt /* we know the offset */ |
Stefan Reinauer | 9693885 | 2015-06-18 01:23:48 -0700 | [diff] [blame] | 146 | #endif |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 147 | |
Eric Biederman | f8a2ddd | 2004-10-30 08:05:41 +0000 | [diff] [blame] | 148 | .data |
Li-Ta Lo | f84926e | 2004-11-04 18:36:06 +0000 | [diff] [blame] | 149 | |
Stefan Reinauer | f8ee180 | 2008-01-18 15:08:58 +0000 | [diff] [blame] | 150 | /* This is the gdt for GCC part of coreboot. |
Arthur Heymans | 1cb9cd5 | 2019-11-28 16:05:08 +0100 | [diff] [blame] | 151 | * It is different from the gdt in ASM part of coreboot |
Kyösti Mälkki | 97b76f7 | 2020-11-19 16:41:28 +0200 | [diff] [blame] | 152 | * which is defined in gdt_init.S |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 153 | * |
| 154 | * When the machine is initially started, we use a very simple |
Kyösti Mälkki | 97b76f7 | 2020-11-19 16:41:28 +0200 | [diff] [blame] | 155 | * gdt from ROM (that in gdt_init.S) which only contains those |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 156 | * entries we need for protected mode. |
| 157 | * |
| 158 | * When we're executing code from RAM, we want to do more complex |
Elyes HAOUAS | 777ea89 | 2016-07-29 07:40:41 +0200 | [diff] [blame] | 159 | * stuff, like initializing PCI option ROMs in real mode, or doing |
| 160 | * a resume from a suspend to RAM. |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 161 | */ |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 162 | gdt: |
Li-Ta Lo | f84926e | 2004-11-04 18:36:06 +0000 | [diff] [blame] | 163 | /* selgdt 0, unused */ |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 164 | .word 0x0000, 0x0000 /* dummy */ |
| 165 | .byte 0x00, 0x00, 0x00, 0x00 |
| 166 | |
Li-Ta Lo | f84926e | 2004-11-04 18:36:06 +0000 | [diff] [blame] | 167 | /* selgdt 8, unused */ |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 168 | .word 0x0000, 0x0000 /* dummy */ |
| 169 | .byte 0x00, 0x00, 0x00, 0x00 |
| 170 | |
Stefan Reinauer | 607cdf6 | 2010-04-26 12:08:51 +0000 | [diff] [blame] | 171 | /* selgdt 0x10, flat code segment */ |
| 172 | .word 0xffff, 0x0000 |
Lee Leahy | 6f80ccc | 2017-03-16 15:18:22 -0700 | [diff] [blame] | 173 | .byte 0x00, 0x9b, 0xcf, 0x00 /* G=1 and 0x0f, So we get 4Gbytes for |
| 174 | * limit |
| 175 | */ |
Li-Ta Lo | f84926e | 2004-11-04 18:36:06 +0000 | [diff] [blame] | 176 | |
| 177 | /* selgdt 0x18, flat data segment */ |
Stefan Reinauer | 607cdf6 | 2010-04-26 12:08:51 +0000 | [diff] [blame] | 178 | .word 0xffff, 0x0000 |
Stefan Reinauer | 9693885 | 2015-06-18 01:23:48 -0700 | [diff] [blame] | 179 | #ifdef __x86_64__ |
| 180 | .byte 0x00, 0x92, 0xcf, 0x00 |
| 181 | #else |
Stefan Reinauer | 607cdf6 | 2010-04-26 12:08:51 +0000 | [diff] [blame] | 182 | .byte 0x00, 0x93, 0xcf, 0x00 |
Stefan Reinauer | 9693885 | 2015-06-18 01:23:48 -0700 | [diff] [blame] | 183 | #endif |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 184 | |
Li-Ta Lo | f84926e | 2004-11-04 18:36:06 +0000 | [diff] [blame] | 185 | /* selgdt 0x20, unused */ |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 186 | .word 0x0000, 0x0000 /* dummy */ |
| 187 | .byte 0x00, 0x00, 0x00, 0x00 |
| 188 | |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 189 | /* The next two entries are used for executing VGA option ROMs */ |
| 190 | |
Stefan Reinauer | 607cdf6 | 2010-04-26 12:08:51 +0000 | [diff] [blame] | 191 | /* selgdt 0x28 16 bit 64k code at 0x00000000 */ |
Elyes HAOUAS | 2ea751a | 2018-12-27 09:21:02 +0100 | [diff] [blame] | 192 | .word 0xffff, 0x0000 |
| 193 | .byte 0, 0x9a, 0, 0 |
Stefan Reinauer | f8a5c6e | 2009-05-29 13:08:27 +0000 | [diff] [blame] | 194 | |
Stefan Reinauer | 607cdf6 | 2010-04-26 12:08:51 +0000 | [diff] [blame] | 195 | /* selgdt 0x30 16 bit 64k data at 0x00000000 */ |
Elyes HAOUAS | 2ea751a | 2018-12-27 09:21:02 +0100 | [diff] [blame] | 196 | .word 0xffff, 0x0000 |
| 197 | .byte 0, 0x92, 0, 0 |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 198 | |
| 199 | /* The next two entries are used for ACPI S3 RESUME */ |
| 200 | |
Stefan Reinauer | 607cdf6 | 2010-04-26 12:08:51 +0000 | [diff] [blame] | 201 | /* selgdt 0x38, flat data segment 16 bit */ |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 202 | .word 0x0000, 0x0000 /* dummy */ |
Lee Leahy | 6f80ccc | 2017-03-16 15:18:22 -0700 | [diff] [blame] | 203 | .byte 0x00, 0x93, 0x8f, 0x00 /* G=1 and 0x0f, So we get 4Gbytes for |
| 204 | * limit |
| 205 | */ |
Stefan Reinauer | c0ac7e9 | 2009-11-10 22:17:15 +0000 | [diff] [blame] | 206 | |
Stefan Reinauer | 607cdf6 | 2010-04-26 12:08:51 +0000 | [diff] [blame] | 207 | /* selgdt 0x40, flat code segment 16 bit */ |
| 208 | .word 0xffff, 0x0000 |
Lee Leahy | 6f80ccc | 2017-03-16 15:18:22 -0700 | [diff] [blame] | 209 | .byte 0x00, 0x9b, 0x8f, 0x00 /* G=1 and 0x0f, So we get 4Gbytes for |
| 210 | * limit |
| 211 | */ |
Stefan Reinauer | 9693885 | 2015-06-18 01:23:48 -0700 | [diff] [blame] | 212 | |
| 213 | #ifdef __x86_64__ |
| 214 | /* selgdt 0x48, flat x64 code segment */ |
| 215 | .word 0xffff, 0x0000 |
| 216 | .byte 0x00, 0x9b, 0xaf, 0x00 |
| 217 | #endif |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 218 | gdt_end: |
| 219 | |
Patrick Georgi | 546f29d | 2016-01-22 12:43:43 +0100 | [diff] [blame] | 220 | .section ".text._start", "ax", @progbits |
Stefan Reinauer | 9693885 | 2015-06-18 01:23:48 -0700 | [diff] [blame] | 221 | #ifdef __x86_64__ |
| 222 | SetCodeSelector: |
Martin Roth | e369010 | 2016-01-06 15:21:02 -0700 | [diff] [blame] | 223 | # save rsp because iret will align it to a 16 byte boundary |
Patrick Georgi | 0302b06 | 2016-01-22 12:26:52 +0100 | [diff] [blame] | 224 | mov %rsp, %rdx |
Stefan Reinauer | 9693885 | 2015-06-18 01:23:48 -0700 | [diff] [blame] | 225 | |
Martin Roth | e369010 | 2016-01-06 15:21:02 -0700 | [diff] [blame] | 226 | # use iret to jump to a 64-bit offset in a new code segment |
| 227 | # iret will pop cs:rip, flags, then ss:rsp |
Patrick Georgi | 0302b06 | 2016-01-22 12:26:52 +0100 | [diff] [blame] | 228 | mov %ss, %ax # need to push ss.. |
Lee Leahy | 6f80ccc | 2017-03-16 15:18:22 -0700 | [diff] [blame] | 229 | push %rax # push ss instuction not valid in x64 mode, |
| 230 | # so use ax |
Patrick Georgi | 0302b06 | 2016-01-22 12:26:52 +0100 | [diff] [blame] | 231 | push %rsp |
Martin Roth | e369010 | 2016-01-06 15:21:02 -0700 | [diff] [blame] | 232 | pushfq |
Patrick Georgi | 0302b06 | 2016-01-22 12:26:52 +0100 | [diff] [blame] | 233 | push %rcx # cx is code segment selector from caller |
Patrick Rudolph | d023909 | 2021-06-11 21:24:10 +0200 | [diff] [blame^] | 234 | movabs $setCodeSelectorLongJump, %rax |
Patrick Georgi | 0302b06 | 2016-01-22 12:26:52 +0100 | [diff] [blame] | 235 | push %rax |
Stefan Reinauer | 9693885 | 2015-06-18 01:23:48 -0700 | [diff] [blame] | 236 | |
Lee Leahy | 6f80ccc | 2017-03-16 15:18:22 -0700 | [diff] [blame] | 237 | # the iret will continue at next instruction, with the new cs value |
| 238 | # loaded |
Martin Roth | e369010 | 2016-01-06 15:21:02 -0700 | [diff] [blame] | 239 | iretq |
Stefan Reinauer | 9693885 | 2015-06-18 01:23:48 -0700 | [diff] [blame] | 240 | |
| 241 | setCodeSelectorLongJump: |
Martin Roth | e369010 | 2016-01-06 15:21:02 -0700 | [diff] [blame] | 242 | # restore rsp, it might not have been 16-byte aligned on entry |
Patrick Georgi | 0302b06 | 2016-01-22 12:26:52 +0100 | [diff] [blame] | 243 | mov %rdx, %rsp |
Martin Roth | e369010 | 2016-01-06 15:21:02 -0700 | [diff] [blame] | 244 | ret |
Stefan Reinauer | 9693885 | 2015-06-18 01:23:48 -0700 | [diff] [blame] | 245 | #endif |