mirror of
https://github.com/limine-bootloader/limine
synced 2024-12-12 09:44:04 +03:00
stivale: Add requested stack sanity checks. Closes #95
This commit is contained in:
parent
9d68787fe1
commit
db561393dd
@ -174,6 +174,16 @@ void stivale_load(char *config, char *cmdline) {
|
|||||||
print("stivale: Requested stack at: %X\n", stivale_hdr.stack);
|
print("stivale: Requested stack at: %X\n", stivale_hdr.stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The spec says the stack has to be 16-byte aligned
|
||||||
|
if ((stivale_hdr.stack & (16 - 1)) != 0) {
|
||||||
|
panic("stivale: Requested stack is not 16-byte aligned\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// It also says the stack cannot be NULL for 32-bit kernels
|
||||||
|
if (bits == 32 && stivale_hdr.stack == 0) {
|
||||||
|
panic("stivale: The stack cannot be 0 for 32-bit kernels");
|
||||||
|
}
|
||||||
|
|
||||||
stivale_struct.module_count = 0;
|
stivale_struct.module_count = 0;
|
||||||
uint64_t *prev_mod_ptr = &stivale_struct.modules;
|
uint64_t *prev_mod_ptr = &stivale_struct.modules;
|
||||||
for (int i = 0; ; i++) {
|
for (int i = 0; ; i++) {
|
||||||
|
@ -193,6 +193,16 @@ failed_to_load_header_section:
|
|||||||
print("stivale2: Requested stack at: %X\n", stivale2_hdr.stack);
|
print("stivale2: Requested stack at: %X\n", stivale2_hdr.stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The spec says the stack has to be 16-byte aligned
|
||||||
|
if ((stivale2_hdr.stack & (16 - 1)) != 0) {
|
||||||
|
panic("stivale2: Requested stack is not 16-byte aligned");
|
||||||
|
}
|
||||||
|
|
||||||
|
// It also says the stack cannot be NULL for 32-bit kernels
|
||||||
|
if (bits == 32 && stivale2_hdr.stack == 0) {
|
||||||
|
panic("stivale2: The stack cannot be 0 for 32-bit kernels");
|
||||||
|
}
|
||||||
|
|
||||||
strcpy(stivale2_struct.bootloader_brand, "Limine");
|
strcpy(stivale2_struct.bootloader_brand, "Limine");
|
||||||
strcpy(stivale2_struct.bootloader_version, LIMINE_VERSION);
|
strcpy(stivale2_struct.bootloader_version, LIMINE_VERSION);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user