Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset d59718e in mainline


Ignore:
Timestamp:
2018-10-21T21:57:23Z (3 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master
Children:
cfdeedc
Parents:
566457ad
Message:

Move stack to always be after all boot allocations

This works around an issue on pcc32.
Since this is not a proper solution and I've so far been unable
to determine root cause, I'm also opening a ticket to track it.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • boot/arch/ppc32/src/asm.S

    r566457ad rd59718e  
    403403        # pc = kernel's entry point (r7)
    404404        # r3 = bootinfo (physical address)
    405         # sprg0 = BOOT_OFFSET
    406405        # sprg3 = physical memory size
    407406        # sp = 0 (enforces the usage of sprg0 as exception stack)
     
    409408        mtspr srr0, r7
    410409
    411         lis r31, BOOT_OFFSET@ha
    412         addi r31, r31, BOOT_OFFSET@l
     410        # Clear sprg0. Kernel will set it.
     411        li r31, 0
    413412        mtsprg0 r31
    414413
     
    416415        # the physical memory size, get the lower 4 bytes
    417416
     417        // FIXME: unchecked magic offset
    418418        lwz r31, 4(r3)
    419419        mtsprg3 r31
  • boot/arch/ppc32/src/main.c

    r566457ad rd59718e  
    9797        size_t pages = (balloc_start + ALIGN_UP(BALLOC_MAX_SIZE, PAGE_SIZE)) >>
    9898            PAGE_WIDTH;
     99
     100        printf(" Boot allocations area: %p - %p\n", (void *) balloc_start,
     101            (void *) (pages << PAGE_WIDTH));
     102
     103        if ((pages << PAGE_WIDTH) >= (uintptr_t) loader_address_pa) {
     104                printf("Boot allocations overlap loader area.\n");
     105                printf("The boot image is too large. Halting.\n");
     106                halt();
     107        }
     108
    99109        void *transtable;
    100110        void *transtable_pa;
  • kernel/generic/src/main/main.c

    r566457ad rd59718e  
    172172        config.kernel_size =
    173173            ALIGN_UP((uintptr_t) kdata_end - config.base, PAGE_SIZE);
     174
     175        /* Place the stack after the kernel, init and ballocs. */
     176        config.stack_base = config.base + config.kernel_size;
    174177        config.stack_size = STACK_SIZE;
    175 
    176         /* Initialy the stack is placed just after the kernel */
    177         config.stack_base = config.base + config.kernel_size;
    178178
    179179        /* Avoid placing stack on top of init */
    180180        size_t i;
    181181        for (i = 0; i < init.cnt; i++) {
    182                 if (overlaps(KA2PA(config.stack_base), config.stack_size,
    183                     init.tasks[i].paddr, init.tasks[i].size)) {
    184                         /*
    185                          * The init task overlaps with the memory behind the
    186                          * kernel image so it must be in low memory and we can
    187                          * use PA2KA on the init task's physical address.
    188                          */
    189                         config.stack_base = ALIGN_UP(
    190                             PA2KA(init.tasks[i].paddr) + init.tasks[i].size,
    191                             config.stack_size);
    192                 }
     182                uintptr_t p = init.tasks[i].paddr + init.tasks[i].size;
     183                uintptr_t bottom = PA2KA(ALIGN_UP(p, PAGE_SIZE));
     184
     185                if (config.stack_base < bottom)
     186                        config.stack_base = bottom;
    193187        }
    194188
    195189        /* Avoid placing stack on top of boot allocations. */
    196190        if (ballocs.size) {
    197                 if (PA_OVERLAPS(config.stack_base, config.stack_size,
    198                     ballocs.base, ballocs.size))
    199                         config.stack_base = ALIGN_UP(ballocs.base +
    200                             ballocs.size, PAGE_SIZE);
     191                uintptr_t bottom =
     192                    ALIGN_UP(ballocs.base + ballocs.size, PAGE_SIZE);
     193                if (config.stack_base < bottom)
     194                        config.stack_base = bottom;
    201195        }
    202196
Note: See TracChangeset for help on using the changeset viewer.