From a002f05110b713d7a0af554faf04868368ca627e Mon Sep 17 00:00:00 2001 From: mintsuki Date: Tue, 11 Aug 2020 18:00:51 +0200 Subject: [PATCH] Fix broken memory types in stivale --- qloader2.bin | Bin 32768 -> 32768 bytes src/lib/elf.c | 8 ++++---- src/lib/elf.h | 4 ++-- src/lib/memmap.c | 4 ++-- src/lib/memmap.h | 2 +- src/protos/linux.c | 4 ++-- src/protos/stivale.c | 6 +++--- src/protos/stivale2.c | 14 +++++++------- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/qloader2.bin b/qloader2.bin index 2bc87efe0f743ad980d9a3a9855732de92e07a5b..a65f4fcef8f9304ffc6f7ad051ffe8745932f516 100644 GIT binary patch delta 8924 zcma)C4O~=J+P`<0K}2u{1suVTQ4u9IMMXs+Q5(O_fr$Y>PBfDIu z@oo3KZC2JRk*&40S!AK9p|Ff@W@MI>R#d2G8Z*sOw6**GpL1te`*`2o`Te~2InUR5 zzRq*bJy=<3sH`;Xh%)w+IwWaVb&@Qt4-$Csh2Xs`*?9Yslb0pQ9XF|OE8gY}uSt^R z%_RoOot&RvW>F-YB=PwEl2l7rZbK@+4;c5i z8Eac;oOFyGH};=?5O9Ite$e44>&eIE2rZZF2j%iX-m`I9)-jN^EE3S%F+O{{`Sm7; zvb`PC&g=&z!ZJ1MB+D^P?M`z$eD;PYdz^!BWDlE4qyJ8vyI6;5oT1w!HYz$fx{WY* zu({DG(ccqjXR824odP(RJsh3Vr7wY|3GAil-qB+TKE)14uam!FbGj_;Js*frOn!kw zSx2PHsxmqK{}>m8GA7M8Hp7`{c*G-6)eH6?`v>31mfM!-ZeG6tc)0A|m09cf7HVDEPw(tGlFNoqDF5-*bF ztN6zu(goeDXKZFR=~%d^BzW~lO#|BHRQG#xcPyTmoH8dqzY3laX6jB#4t4d-x2jC39Sdby{=l<#qYL4XT||lAPWkjpolH$X7l{g zguZ0LK4C&DOt|#kSL%B;LRE{mWB$6h`uU`(MOfr;T*v5$iYK|e9)*R*CQ#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d7)n|N_Fb%Pom40RLI#+ z$3rNfUymn!sw!0UNwzCDv*S{=cuf3rb}e_J$ZE#TA0tNOH?a?vUSWS)&?%xco_(}z zK!n`HepVMry`lkLj?BAdSr16kx-&1o`{qUYTQ<@1TfBpk?&gg#vsr;({^*BJZU-iE`Xy6q? zeZtb;vLOpodb(h#y+hIo=3|tY+MSGLYuU<$@!8MdWrp0~d(b4UrBO>^LhE);zCo4M zdf`;`!l%gCjlJ*zws&Fo2-5*pJ1@zc8wgo$?|Yjd-})mnEc%_k$8b*iy}lRG$ch$a zyAQ$yAK22~_s$TW3_O34Qxbmw(isQ^_kNu+Qc5Jsb@et13jU9l1`??iB(3kM8)4-Q zL7W^d+YNHhn}dk5!E(ITI1{m{3kVM`9TgME(Xq#pUg1+PO?k2@Fgc#0{r_4Dr{nKz zhc&oedWsIeXtYLOQgryt|i^3&QPnuup+P8Jl|>K&QESOJ~di)805^Gqrda1HNvnR zE2j-%+VO#>vgCrH9TU_{oA}dgLBTk2Ud=NFX!Y^`s`+4Pgc#AR_4yBuqR%fQZ0Yh3 z-316y`+YttT%V!-{yJ{$T7SPiBxdI)8bUR!_4hx5ffvhk@m~#TsT{ZsFX{HbM`BnQ z+OLxgWZnf=S-dtsrnrts|3ieqUyi{m7@&LwSaM(?epw(coeZ6JzPXlc^zffPCJ2KU z;9-;KDG7Mrz#TQGZaZa&t^5bx@8Yisf1lNSevd7N{o6I4xgYwQ{@AyQvW)e4q$|sL zc&PY2TlMfXz4^4FM5?r=hiBuTKlFU$KJgCr%p>!Xx8mnDY7g{BKOE!riwfhPtkj6B Jp;Rl5|6iDw *top) *top = this_top; - memmap_alloc_range((size_t)load_vaddr, (size_t)phdr.p_memsz); + memmap_alloc_range((size_t)load_vaddr, (size_t)phdr.p_memsz, alloc_type); fread(fd, (void *)(uint32_t)load_vaddr, phdr.p_offset, phdr.p_filesz); @@ -335,7 +335,7 @@ int elf64_load(struct file_handle *fd, uint64_t *entry_point, uint64_t *top, uin return 0; } -int elf32_load(struct file_handle *fd, uint32_t *entry_point, uint32_t *top) { +int elf32_load(struct file_handle *fd, uint32_t *entry_point, uint32_t *top, uint32_t alloc_type) { struct elf32_hdr hdr; fread(fd, &hdr, 0, sizeof(struct elf32_hdr)); @@ -368,7 +368,7 @@ int elf32_load(struct file_handle *fd, uint32_t *entry_point, uint32_t *top) { if (this_top > *top) *top = this_top; - memmap_alloc_range((size_t)phdr.p_paddr, (size_t)phdr.p_memsz); + memmap_alloc_range((size_t)phdr.p_paddr, (size_t)phdr.p_memsz, alloc_type); fread(fd, (void *)phdr.p_paddr, phdr.p_offset, phdr.p_filesz); diff --git a/src/lib/elf.h b/src/lib/elf.h index 4b4b1b6a..c3467e6b 100644 --- a/src/lib/elf.h +++ b/src/lib/elf.h @@ -8,10 +8,10 @@ int elf_bits(struct file_handle *fd); -int elf64_load(struct file_handle *fd, uint64_t *entry_point, uint64_t *top, uint64_t slide); +int elf64_load(struct file_handle *fd, uint64_t *entry_point, uint64_t *top, uint64_t slide, uint32_t alloc_type); int elf64_load_section(struct file_handle *fd, void *buffer, const char *name, size_t limit, uint64_t slide); -int elf32_load(struct file_handle *fd, uint32_t *entry_point, uint32_t *top); +int elf32_load(struct file_handle *fd, uint32_t *entry_point, uint32_t *top, uint32_t alloc_type); int elf32_load_section(struct file_handle *fd, void *buffer, const char *name, size_t limit); #endif diff --git a/src/lib/memmap.c b/src/lib/memmap.c index d4da5f96..4ab1d69c 100644 --- a/src/lib/memmap.c +++ b/src/lib/memmap.c @@ -165,7 +165,7 @@ void init_memmap(void) { sanitise_entries(); } -void memmap_alloc_range(uint64_t base, uint64_t length) { +void memmap_alloc_range(uint64_t base, uint64_t length, uint32_t type) { uint64_t top = base + length; for (size_t i = 0; i < memmap_entries; i++) { @@ -206,7 +206,7 @@ void memmap_alloc_range(uint64_t base, uint64_t length) { } target = &memmap[memmap_entries++]; - target->type = MEMMAP_KERNEL_AND_MODULES; + target->type = type; target->base = base; target->length = length; diff --git a/src/lib/memmap.h b/src/lib/memmap.h index b33282dc..da587d5d 100644 --- a/src/lib/memmap.h +++ b/src/lib/memmap.h @@ -5,7 +5,7 @@ #include void init_memmap(void); -void memmap_alloc_range(uint64_t base, uint64_t length); +void memmap_alloc_range(uint64_t base, uint64_t length, uint32_t type); struct e820_entry_t *get_memmap(size_t *entries); void print_memmap(struct e820_entry_t *mm, size_t size); diff --git a/src/protos/linux.c b/src/protos/linux.c index 59cb83a0..a8a60f68 100644 --- a/src/protos/linux.c +++ b/src/protos/linux.c @@ -103,7 +103,7 @@ void linux_load(char *cmdline, int boot_drive) { // load kernel print("Loading kernel...\n"); - memmap_alloc_range(KERNEL_LOAD_ADDR, fd->size - real_mode_code_size); + memmap_alloc_range(KERNEL_LOAD_ADDR, fd->size - real_mode_code_size, 0); fread(fd, (void *)KERNEL_LOAD_ADDR, real_mode_code_size, fd->size - real_mode_code_size); char initrd_path[64]; @@ -125,7 +125,7 @@ void linux_load(char *cmdline, int boot_drive) { } print("Loading initrd...\n"); - memmap_alloc_range(INITRD_LOAD_ADDR, initrd.size); + memmap_alloc_range(INITRD_LOAD_ADDR, initrd.size, 0); fread(&initrd, (void *)INITRD_LOAD_ADDR, 0, initrd.size); *((uint32_t *)(real_mode_code + 0x218)) = (uint32_t)INITRD_LOAD_ADDR; diff --git a/src/protos/stivale.c b/src/protos/stivale.c index 1c5b9bc3..b086b371 100644 --- a/src/protos/stivale.c +++ b/src/protos/stivale.c @@ -145,10 +145,10 @@ void stivale_load(char *cmdline, int boot_drive) { switch (bits) { case 64: - elf64_load(fd, &entry_point, &top_used_addr, slide); + elf64_load(fd, &entry_point, &top_used_addr, slide, 10); break; case 32: - elf32_load(fd, (uint32_t *)&entry_point, (uint32_t *)&top_used_addr); + elf32_load(fd, (uint32_t *)&entry_point, (uint32_t *)&top_used_addr, 10); break; } @@ -192,7 +192,7 @@ void stivale_load(char *cmdline, int boot_drive) { ((uint32_t)top_used_addr & ~((uint32_t)0xfff)) + 0x1000 : (uint32_t)top_used_addr); - memmap_alloc_range((size_t)module_addr, f.size); + memmap_alloc_range((size_t)module_addr, f.size, 10); fread(&f, module_addr, 0, f.size); m->begin = (uint64_t)(size_t)module_addr; diff --git a/src/protos/stivale2.c b/src/protos/stivale2.c index b9360dfd..18ea0206 100644 --- a/src/protos/stivale2.c +++ b/src/protos/stivale2.c @@ -232,10 +232,10 @@ void stivale2_load(char *cmdline, int boot_drive) { switch (bits) { case 64: - elf64_load(fd, &entry_point, &top_used_addr, slide); + elf64_load(fd, &entry_point, &top_used_addr, slide, 0x1001); break; case 32: - elf32_load(fd, (uint32_t *)&entry_point, (uint32_t *)&top_used_addr); + elf32_load(fd, (uint32_t *)&entry_point, (uint32_t *)&top_used_addr, 0x1001); break; } @@ -301,7 +301,7 @@ void stivale2_load(char *cmdline, int boot_drive) { ((uint32_t)top_used_addr & ~((uint32_t)0xfff)) + 0x1000 : (uint32_t)top_used_addr); - memmap_alloc_range((size_t)module_addr, f.size); + memmap_alloc_range((size_t)module_addr, f.size, 0x1001); fread(&f, module_addr, 0, f.size); m->begin = (uint64_t)(size_t)module_addr; @@ -310,10 +310,10 @@ void stivale2_load(char *cmdline, int boot_drive) { top_used_addr = (uint64_t)(size_t)m->end; print("stivale2: Requested module %u:\n", i); - print(" Path: %s\n", module_file); - print(" String: %s\n", m->string); - print(" Begin: %X\n", m->begin); - print(" End: %X\n", m->end); + print(" Path: %s\n", module_file); + print(" String: %s\n", m->string); + print(" Begin: %X\n", m->begin); + print(" End: %X\n", m->end); } append_tag(&stivale2_struct, (struct stivale2_tag *)tag);