Skip to content

Commit 03fd984

Browse files
committed
f
1 parent ec4d70a commit 03fd984

1 file changed

Lines changed: 10 additions & 45 deletions

File tree

  • src/arch/x86_64/platform/pvh

src/arch/x86_64/platform/pvh/entry.s

Lines changed: 10 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@
55

66
.code32
77

8-
.macro gotpcrel reg, sym
8+
.macro movgot reg, sym
99
call 2f
1010
2:
11-
pop eax
11+
pop \reg
1212
3:
13+
// LLVM currently rejects the equivalent Intel syntax:
14+
// https://github.com/llvm/llvm-project/issues/161550
1315
.att_syntax prefix
14-
addl $_GLOBAL_OFFSET_TABLE_ + (3b - 2b), %eax
16+
addl $_GLOBAL_OFFSET_TABLE_ + (3b - 2b), %\reg
1517
.intel_syntax noprefix
16-
mov \reg, dword ptr [eax + \sym@GOT]
18+
mov \reg, dword ptr [\reg + \sym@GOT]
1719
.endm
1820

1921
.section .text
@@ -23,16 +25,7 @@ _start:
2325
mov edi, ebx
2426
cli # avoid any interrupt
2527

26-
call 2f
27-
2:
28-
pop eax
29-
3:
30-
.att_syntax prefix
31-
addl $_GLOBAL_OFFSET_TABLE_ + (3b - 2b), %eax
32-
.intel_syntax noprefix
33-
mov esp, dword ptr [eax + {stack}@GOT]
34-
35-
28+
movgot esp, {stack}
3629
# Initialize stack pointer
3730
add esp, {stack_top_offset}
3831

@@ -44,36 +37,8 @@ _start:
4437
# Bootstrap page tables are loaded and page size
4538
# extensions (huge pages) enabled.
4639
cpu_init:
47-
# check for long mode
48-
49-
# do we have the instruction cpuid?
50-
pushfd
51-
pop eax
52-
mov ecx, eax
53-
xor eax, 1 << 21
54-
push eax
55-
popfd
56-
pushfd
57-
pop eax
58-
push ecx
59-
popfd
60-
xor eax, ecx
61-
jz Linvalid
62-
63-
# cpuid > 0x80000000?
64-
mov eax, 0x80000000
65-
cpuid
66-
cmp eax, 0x80000001
67-
jb Linvalid # It is less, there is no long mode.
68-
69-
# do we have a long mode?
70-
mov eax, 0x80000001
71-
cpuid
72-
test edx, 1 << 29 # Test if the LM-bit, which is bit 29, is set in the D-register.
73-
jz Linvalid # They aren't, there is no long mode.
74-
7540
# Set CR3
76-
gotpcrel eax, {level_4_table}
41+
movgot eax, {level_4_table}
7742
mov cr3, eax
7843

7944
# we need to enable PAE modus
@@ -103,12 +68,12 @@ cpu_init:
10368
or eax, (1 << 31) # enable paging
10469
mov cr0, eax
10570

106-
gotpcrel eax, {gdt_ptr}
71+
movgot eax, {gdt_ptr}
10772

10873
lgdt [eax] # Load the 64-bit global descriptor table.
10974

11075
push {kernel_code_selector}
111-
gotpcrel eax, start64
76+
movgot eax, start64
11277
push eax
11378
retf
11479
# https://github.com/llvm/llvm-project/issues/46048

0 commit comments

Comments
 (0)