@@ -274,30 +274,22 @@ again:
274
274
lgdt [ gdtr ]
275
275
276
276
; Switch to compatibility mode
277
- push SYS32_DATA_SEL
278
- push 0x8000
279
- pushf
280
- push SYS32_CODE_SEL
281
- push testcode
282
- iretq
283
-
284
- ; Switch to compatibility mode
285
- ; mov rax, SYS32_CODE_SEL ; Compatibility mode
286
- ; push rax
287
- ; lea rax, [compatmode]
288
- ; push rax
289
- ; retfq
277
+ mov rax , SYS32_CODE_SEL ; Compatibility mode
278
+ push rax
279
+ lea rax , [ compatmode ]
280
+ push rax
281
+ retfq
290
282
291
283
BITS 32
292
284
compatmode:
293
- testcode:
294
285
295
286
; Switch to 32-bit mode
296
287
mov eax , SYS32_DATA_SEL ; Clear the segment registers
297
288
mov ds , ax
298
289
mov es , ax
299
290
mov fs , ax
300
291
mov gs , ax
292
+ mov ss , ax
301
293
302
294
; Deactivate IA-32e mode by clearing CR0.PG
303
295
mov eax , cr0
@@ -311,20 +303,14 @@ testcode:
311
303
; Disable IA-32e mode by setting IA32_EFER.LME = 0
312
304
mov ecx , 0xC0000080 ; EFER MSR number
313
305
rdmsr ; Read EFER
314
- and eax , 0xFFFFFEFF ; LME (Bit 8)
306
+ and eax , 0xFFFFFEFF ; Clear LME (Bit 8)
315
307
wrmsr ; Write EFER
316
308
317
- xor eax , eax
318
- ; mov eax, cr4
319
- ; btc eax, 7 ; Clear PGE (Bit 7)
320
- ; btc eax, 5 ; Clear PAE (Bit 5)
321
- ; bts eax, 4 ; Set PSE (bit 4) - Enable 4MB pages
309
+ mov eax , 0x00000010 ; Set PSE (Bit 4)
322
310
mov cr4 , eax
323
311
324
312
; Enable legacy paged-protected mode by setting CR0.PG
325
- mov eax , 0x11
326
- ; mov eax, cr0
327
- ; bts eax, 31 ; Set PG (Bit 31)
313
+ mov eax , 0x00000001 ; Set PM (Bit 0)
328
314
mov cr0 , eax
329
315
330
316
jmp SYS32_CODE_SEL: 0x8000 ; 32-bit jump to set CS
0 commit comments