trapframe-rs icon indicating copy to clipboard operation
trapframe-rs copied to clipboard

x86_64/gdt.rs panicked at 'attempt to create unaligned or null slice'

Open elliott10 opened this issue 3 years ago • 1 comments

Occasionally an error occurs when the x86 64 arch boot:

panicked at 'attempt to create unaligned or null slice'

The location of the error occurs in x86_64/gdt.rs

39         let old_gdt = core::slice::from_raw_parts(gdtp.base.as_ptr::<u64>(), entry_count);

elliott10 avatar Jan 20 '22 05:01 elliott10

The memory address of gdt must be aligned, in order to solve this panick. Like:

.align 4
gdt_64:
    .quad 0x0000000000000000          # Null Descriptor - should be present.
    .quad 0x00209A0000000000          # 64-bit code descriptor (exec/read).
    .quad 0x0000920000000000          # 64-bit data descriptor (read/write).

elliott10 avatar Jan 20 '22 05:01 elliott10