Don't crash system when have excess memory

This commit is contained in:
Mark
2020-06-14 18:17:55 +03:00
parent f05e7d2640
commit 89c48841e0
3 changed files with 12 additions and 7 deletions
+7 -4
View File
@@ -103,17 +103,20 @@ void kernel_early_init(void) {
amd64_gdt_init();
amd64_idt_init(0);
amd64_mm_init();
ps2_register_device();
amd64_acpi_init();
// Console can only be initialized after memory buffers can be allocated
#if defined(VESA_ENABLE)
if (multiboot_tag_framebuffer) {
amd64_vesa_init(multiboot_tag_framebuffer);
}
#endif
amd64_con_init();
#endif
ps2_register_device();
amd64_acpi_init();
// Print kernel version now
kinfo("yggdrasil " KERNEL_VERSION_STR "\n");
+3 -1
View File
@@ -95,7 +95,9 @@ void amd64_phys_memory_map(const struct multiboot_tag_mmap *mmap) {
for (uintptr_t addr = page_aligned_begin - PHYS_ALLOWED_BEGIN;
addr < (page_aligned_end - PHYS_ALLOWED_BEGIN); addr += 0x1000) {
size_t index = addr / MM_PAGE_SIZE;
_assert(index < PHYS_MAX_PAGES);
if (index >= PHYS_MAX_PAGES) {
break;
}
phys_add_page(index);
++_total_pages;
}
+2 -2
View File
@@ -26,7 +26,7 @@ struct type_descriptor {
#endif
static __ubsan_abort__ void ubsan_abort(struct source_location *loc, const char *error) {
kfatal("%s:%d: %s\n", loc->file, loc->line, error);
//kfatal("%s:%d: %s\n", loc->file, loc->line, error);
#if defined(UBSAN_ABORT)
panic("Undefined behavior detected\n");
#endif
@@ -137,7 +137,7 @@ void __ubsan_handle_type_mismatch_v1(struct type_mismatch_info *type_mismatch,
// Most useful on architectures with stricter memory alignment requirements, like ARM.
kfatal("Unaligned memory access: %p\n", pointer);
} else {
kfatal("Insufficient size:\n");
//kfatal("Insufficient size:\n");
if (type_mismatch->type_check_kind < sizeof(Type_Check_Kinds) / sizeof(Type_Check_Kinds[0])) {
kfatal("%s address %p with insufficient space for object of type %s\n",
Type_Check_Kinds[type_mismatch->type_check_kind], (void *) pointer,