2021-03-07 02:52:25 +03:00
|
|
|
section .rodata
|
|
|
|
|
|
|
|
invalid_idt:
|
|
|
|
dq 0, 0
|
|
|
|
|
|
|
|
section .text
|
|
|
|
|
2021-09-21 18:28:32 +03:00
|
|
|
extern flush_irqs
|
|
|
|
|
2021-03-07 02:52:25 +03:00
|
|
|
%macro push32 1
|
|
|
|
sub rsp, 4
|
|
|
|
mov dword [rsp], %1
|
|
|
|
%endmacro
|
|
|
|
|
2021-03-19 11:36:49 +03:00
|
|
|
extern gdt
|
|
|
|
|
2021-07-06 00:28:04 +03:00
|
|
|
global common_spinup
|
2021-03-07 02:52:25 +03:00
|
|
|
bits 64
|
2021-07-06 00:28:04 +03:00
|
|
|
common_spinup:
|
|
|
|
cli
|
|
|
|
|
2021-03-19 11:36:49 +03:00
|
|
|
lgdt [rel gdt]
|
2021-07-06 00:28:04 +03:00
|
|
|
lidt [rel invalid_idt]
|
2021-03-19 11:36:49 +03:00
|
|
|
|
2021-09-21 18:28:32 +03:00
|
|
|
lea rbx, [rel .reload_cs]
|
|
|
|
|
|
|
|
push 0x28
|
|
|
|
push rbx
|
|
|
|
retfq
|
|
|
|
.reload_cs:
|
|
|
|
mov eax, 0x30
|
|
|
|
mov ds, eax
|
|
|
|
mov es, eax
|
|
|
|
mov fs, eax
|
|
|
|
mov gs, eax
|
|
|
|
mov ss, eax
|
|
|
|
|
2021-09-21 19:34:41 +03:00
|
|
|
push r8
|
|
|
|
push r9
|
|
|
|
push rcx
|
|
|
|
push rdx
|
2021-09-21 18:28:32 +03:00
|
|
|
call flush_irqs
|
2021-09-21 19:34:41 +03:00
|
|
|
pop rdx
|
|
|
|
pop rcx
|
|
|
|
pop r9
|
|
|
|
pop r8
|
2021-09-21 18:28:32 +03:00
|
|
|
|
2021-03-07 02:52:25 +03:00
|
|
|
mov rbp, rsp
|
|
|
|
|
|
|
|
cmp esi, 4
|
|
|
|
jle .no_stack_args
|
|
|
|
|
|
|
|
.push_stack_args:
|
|
|
|
dec esi
|
|
|
|
mov eax, [rbp + 8 + rsi*8]
|
|
|
|
push32 eax
|
|
|
|
test esi, esi
|
|
|
|
jnz .push_stack_args
|
|
|
|
|
|
|
|
.no_stack_args:
|
|
|
|
push32 r9d
|
|
|
|
push32 r8d
|
|
|
|
push32 ecx
|
|
|
|
push32 edx
|
|
|
|
|
|
|
|
lea rbx, [rel .go_32]
|
|
|
|
|
|
|
|
push 0x18
|
|
|
|
push rbx
|
|
|
|
retfq
|
|
|
|
|
|
|
|
bits 32
|
|
|
|
.go_32:
|
2021-07-06 00:28:04 +03:00
|
|
|
mov eax, 0x20
|
|
|
|
mov ds, ax
|
|
|
|
mov es, ax
|
|
|
|
mov fs, ax
|
|
|
|
mov gs, ax
|
|
|
|
mov ss, ax
|
|
|
|
|
2021-07-06 03:13:25 +03:00
|
|
|
xor eax, eax
|
|
|
|
lldt ax
|
|
|
|
|
2021-05-20 02:16:39 +03:00
|
|
|
mov eax, 0x00000011
|
2021-03-07 02:52:25 +03:00
|
|
|
mov cr0, eax
|
|
|
|
|
|
|
|
mov ecx, 0xc0000080
|
2021-05-20 02:16:39 +03:00
|
|
|
xor eax, eax
|
|
|
|
xor edx, edx
|
2021-03-07 02:52:25 +03:00
|
|
|
wrmsr
|
|
|
|
|
2021-05-20 02:16:39 +03:00
|
|
|
xor eax, eax
|
2021-03-07 02:52:25 +03:00
|
|
|
mov cr4, eax
|
|
|
|
|
|
|
|
call edi
|
2023-09-28 12:15:33 +03:00
|
|
|
|
|
|
|
section .note.GNU-stack noalloc noexec nowrite progbits
|