From 01e39adb66c170bfdb9268cbd6c9ec7088ffd6f3 Mon Sep 17 00:00:00 2001 From: Adrian Danis Date: Tue, 19 May 2015 15:56:19 +1000 Subject: [PATCH] ia32: Use explicitly sized types for multiboot structs The multiboot specification states that these fields are 32bits in sized, not the size of machine pointer or integer. --- include/arch/ia32/arch/kernel/multiboot.h | 10 +++++----- src/arch/ia32/kernel/boot_sys.c | 21 +++++++++++---------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/include/arch/ia32/arch/kernel/multiboot.h b/include/arch/ia32/arch/kernel/multiboot.h index 69be63d45..04113ecea 100644 --- a/include/arch/ia32/arch/kernel/multiboot.h +++ b/include/arch/ia32/arch/kernel/multiboot.h @@ -19,9 +19,9 @@ #include typedef struct multiboot_module { - paddr_t start; - paddr_t end; - char* name; + uint32_t start; + uint32_t end; + uint32_t name; uint32_t reserved; } multiboot_module_t; @@ -30,9 +30,9 @@ typedef struct multiboot_info { uint32_t mem_lower; uint32_t mem_upper; uint32_t boot_device; - char* cmdline; + uint32_t cmdline; uint32_t mod_count; - multiboot_module_t* mod_list; + uint32_t mod_list; /* the multiboot spec includes more fields we don't need */ } multiboot_info_t; diff --git a/src/arch/ia32/kernel/boot_sys.c b/src/arch/ia32/kernel/boot_sys.c index 0cbb54598..8730f3ab2 100644 --- a/src/arch/ia32/kernel/boot_sys.c +++ b/src/arch/ia32/kernel/boot_sys.c @@ -433,6 +433,7 @@ try_boot_sys( paddr_t load_paddr; unsigned int i; p_region_t ui_p_regs; + multiboot_module_t *modules = (multiboot_module_t*)mbi->mod_list; glks.num_nodes = 1; /* needed to enable console output */ @@ -440,7 +441,7 @@ try_boot_sys( printf("Boot loader not multiboot compliant\n"); return false; } - cmdline_parse(mbi->cmdline, &cmdline_opt); + cmdline_parse((const char *)mbi->cmdline, &cmdline_opt); /* assert correct NDKS location and size */ assert((uint32_t)_ndks_start == PPTR_NDKS); @@ -557,17 +558,17 @@ try_boot_sys( printf( " module #%d: start=0x%x end=0x%x size=0x%x name='%s'\n", i, - mbi->mod_list[i].start, - mbi->mod_list[i].end, - mbi->mod_list[i].end - mbi->mod_list[i].start, - mbi->mod_list[i].name + modules[i].start, + modules[i].end, + modules[i].end - modules[i].start, + modules[i].name ); - if ((int32_t)(mbi->mod_list[i].end - mbi->mod_list[i].start) <= 0) { + if ((int32_t)(modules[i].end - modules[i].start) <= 0) { printf("Invalid boot module size! Possible cause: boot module file not found by QEMU\n"); return false; } - if (mods_end_paddr < mbi->mod_list[i].end) { - mods_end_paddr = mbi->mod_list[i].end; + if (mods_end_paddr < modules[i].end) { + mods_end_paddr = modules[i].end; } } mods_end_paddr = ROUND_UP(mods_end_paddr, PAGE_BITS); @@ -583,7 +584,7 @@ try_boot_sys( for (i = 0; i < mbi->mod_count && i < glks.num_nodes; i++) { printf(" module #%d for node #%d: ", i, i); - load_paddr = load_boot_module(i, mbi->mod_list + i, load_paddr); + load_paddr = load_boot_module(i, modules + i, load_paddr); if (!load_paddr) { return false; } @@ -591,7 +592,7 @@ try_boot_sys( for (i = mbi->mod_count; i < glks.num_nodes; i++) { printf(" module #%d for node #%d: ", mbi->mod_count - 1, i); - load_paddr = load_boot_module(i, mbi->mod_list + mbi->mod_count - 1, load_paddr); + load_paddr = load_boot_module(i, modules + mbi->mod_count - 1, load_paddr); if (!load_paddr) { return false; }