Fix GDT length being insufficient
The value of the GDTR register was set to be 8 bytes too small, with the effect that an accurate emulation software would error out because of trying to read over the buffer size, as was noticed when using KVM. This was due to the perception that the 0th index wouldn't be taken into account; for that reason, the length of the GDTR was one index short of what it should've been.
This commit is contained in:
parent
fd8b5bd57e
commit
5ba30e5f8b
|
@ -241,7 +241,7 @@ load_flat_gdt:
|
||||||
mov ebp, esp
|
mov ebp, esp
|
||||||
push dword 2 ; Segment Index
|
push dword 2 ; Segment Index
|
||||||
push dword 0 ; Start Offset
|
push dword 0 ; Start Offset
|
||||||
push dword 0xfffff ; Page Count
|
push dword 0x000fffff ; Page Count
|
||||||
push dword 0 ; Required privilege level
|
push dword 0 ; Required privilege level
|
||||||
call make_regular_data_segment_in_gdt
|
call make_regular_data_segment_in_gdt
|
||||||
mov esp, ebp
|
mov esp, ebp
|
||||||
|
@ -251,7 +251,7 @@ load_flat_gdt:
|
||||||
mov ebp, esp
|
mov ebp, esp
|
||||||
push dword 1 ; Segment Index
|
push dword 1 ; Segment Index
|
||||||
push dword 0x0000 ; Start Offset
|
push dword 0x0000 ; Start Offset
|
||||||
push dword 0xfffff ; Page Count
|
push dword 0x000fffff ; Page Count
|
||||||
push dword 0 ; Required privilege level
|
push dword 0 ; Required privilege level
|
||||||
call make_code_segment_in_gdt
|
call make_code_segment_in_gdt
|
||||||
mov esp, ebp
|
mov esp, ebp
|
||||||
|
@ -259,8 +259,20 @@ load_flat_gdt:
|
||||||
|
|
||||||
mov bx, 0
|
mov bx, 0
|
||||||
mov ds, bx
|
mov ds, bx
|
||||||
|
mov es, bx
|
||||||
|
mov fs, bx
|
||||||
|
mov gs, bx
|
||||||
|
mov ss, bx
|
||||||
lgdt [.gdtr]
|
lgdt [.gdtr]
|
||||||
|
|
||||||
|
mov ebx, cr0
|
||||||
|
or ebx, 1
|
||||||
|
mov cr0, ebx
|
||||||
|
|
||||||
|
jmp dword (1 << 3):.epilog
|
||||||
|
|
||||||
|
bits 32
|
||||||
|
.epilog:
|
||||||
mov bx, (2 << 3)
|
mov bx, (2 << 3)
|
||||||
mov ds, bx
|
mov ds, bx
|
||||||
mov es, bx
|
mov es, bx
|
||||||
|
@ -268,14 +280,6 @@ load_flat_gdt:
|
||||||
mov gs, bx
|
mov gs, bx
|
||||||
mov ss, bx
|
mov ss, bx
|
||||||
|
|
||||||
mov ebx, cr0
|
|
||||||
or ebx, 1
|
|
||||||
mov cr0, ebx
|
|
||||||
|
|
||||||
jmp dword 0x08:.epilog
|
|
||||||
|
|
||||||
bits 32
|
|
||||||
.epilog:
|
|
||||||
mov edi, [esi + (64 - 20)]
|
mov edi, [esi + (64 - 20)]
|
||||||
mov edx, [esi + (64 - 16)]
|
mov edx, [esi + (64 - 16)]
|
||||||
mov ecx, [esi + (64 - 12)]
|
mov ecx, [esi + (64 - 12)]
|
||||||
|
@ -287,7 +291,7 @@ bits 32
|
||||||
align 16
|
align 16
|
||||||
.gdtr:
|
.gdtr:
|
||||||
.gdtr.length:
|
.gdtr.length:
|
||||||
dw 15
|
dw 23
|
||||||
.gdtr.pointer:
|
.gdtr.pointer:
|
||||||
dd GDT_MEMORY_AREA
|
dd GDT_MEMORY_AREA
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue