Skip to content

Commit 2312b15

Browse files
committed
ram32: Better doucment 64-bit code descriptor
Signed-off-by: Joe Richey <joerichey@google.com>
1 parent 53b9635 commit 2312b15

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/asm/ram32.s

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,18 @@ gdt64_ptr:
5454
.short gdt64_end - gdt64_start - 1 # GDT length is actually (length - 1)
5555
.long gdt64_start
5656
gdt64_start:
57-
.quad 0 # First descriptor is null
57+
# First descriptor is null
58+
.quad 0
5859
code64_desc:
59-
.quad (1<<43) | (1<<44) | (1<<47) | (1<<53) # Only these bits do anything
60+
# For 64-bit code descriptors, all bits except the following are ignored:
61+
# - CS.A=1 (bit 40) segment is accessed, prevents a write on first use.
62+
# - CS.R=1 (bit 41) segment is readable. (this might not be necessary)
63+
# - CS.C=1 (bit 42) segment is conforming. (this might not be necessary)
64+
# - CS.E=1 (bit 43) required, we are a executable code segment.
65+
# - CS.S=1 (bit 44) required, we are not a system segment.
66+
# - CS.DPL=0 (bits 45/46) we are using this segment in Ring 0.
67+
# - CS.P=1 (bit 47) required, the segment is present.
68+
# - CS.L=1 (bit 53) required, we are a 64-bit (long mode) segment.
69+
# - CS.D=0 (bit 54) required, CS.L=1 && CS.D=1 is resevered for future use.
70+
.quad (1<<40) | (1<<41) | (1<<42) | (1<<43) | (1<<44) | (1<<47) | (1<<53)
6071
gdt64_end:

0 commit comments

Comments
 (0)