Changeset 2902e1bb in mainline for kernel/arch


Ignore:
Timestamp:
2012-06-13T13:17:46Z (13 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1d4024cf, 375e501
Parents:
faba839
Message:

add support for variable uspace stack size
create individual address space areas for stacks of additional threads (instead of allocating the stack from heap)
avoid memory leaks in program_create()

Location:
kernel/arch
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/amd64/src/userspace.c

    rfaba839 r2902e1bb  
    5555        asm volatile (
    5656                "pushq %[udata_des]\n"
    57                 "pushq %[stack_size]\n"
     57                "pushq %[stack_top]\n"
    5858                "pushq %[ipl]\n"
    5959                "pushq %[utext_des]\n"
     
    6565                "iretq\n"
    6666                :: [udata_des] "i" (GDT_SELECTOR(UDATA_DES) | PL_USER),
    67                    [stack_size] "r" (kernel_uarg->uspace_stack + STACK_SIZE),
     67                   [stack_top] "r" ((uint8_t *) kernel_uarg->uspace_stack +
     68                       kernel_uarg->uspace_stack_size),
    6869                   [ipl] "r" (ipl),
    6970                   [utext_des] "i" (GDT_SELECTOR(UTEXT_DES) | PL_USER),
     
    7475       
    7576        /* Unreachable */
    76         while (1)
    77                 ;
     77        while (1);
    7878}
    7979
  • kernel/arch/arm32/src/userspace.c

    rfaba839 r2902e1bb  
    9292
    9393        /* set user stack */
    94         ustate.sp = ((uint32_t)kernel_uarg->uspace_stack) + STACK_SIZE;
     94        ustate.sp = ((uint32_t) kernel_uarg->uspace_stack) +
     95            kernel_uarg->uspace_stack_size;
    9596
    9697        /* set where uspace execution starts */
  • kernel/arch/ia32/src/userspace.c

    rfaba839 r2902e1bb  
    6363               
    6464                "pushl %[udata_des]\n"
    65                 "pushl %[stack_size]\n"
     65                "pushl %[stack_top]\n"
    6666                "pushl %[ipl]\n"
    6767                "pushl %[utext_des]\n"
     
    7575                :
    7676                : [udata_des] "i" (GDT_SELECTOR(UDATA_DES) | PL_USER),
    77                   [stack_size] "r" ((uint8_t *) kernel_uarg->uspace_stack + STACK_SIZE),
     77                  [stack_top] "r" ((uint8_t *) kernel_uarg->uspace_stack +
     78                      kernel_uarg->uspace_stack_size),
    7879                  [ipl] "r" (ipl),
    7980                  [utext_des] "i" (GDT_SELECTOR(UTEXT_DES) | PL_USER),
  • kernel/arch/ia64/src/ia64.c

    rfaba839 r2902e1bb  
    232232         *
    233233         * When calculating stack addresses, mind the stack split between the
    234          * memory stack and the RSE stack. Each occuppies STACK_SIZE / 2 bytes.
     234         * memory stack and the RSE stack. Each occuppies
     235         * uspace_stack_size / 2 bytes.
    235236         */
    236237        switch_to_userspace((uintptr_t) kernel_uarg->uspace_entry,
    237             ((uintptr_t) kernel_uarg->uspace_stack) + STACK_SIZE / 2 -
     238            ((uintptr_t) kernel_uarg->uspace_stack) +
     239            kernel_uarg->uspace_stack_size / 2 -
    238240            ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT),
    239             ((uintptr_t) kernel_uarg->uspace_stack) + STACK_SIZE / 2,
     241            ((uintptr_t) kernel_uarg->uspace_stack) +
     242            kernel_uarg->uspace_stack_size / 2,
    240243            (uintptr_t) kernel_uarg->uspace_uarg, psr.value, rsc.value);
    241 
    242         while (1)
    243                 ;
     244       
     245        while (1);
    244246}
    245247
  • kernel/arch/mips32/src/mips32.c

    rfaba839 r2902e1bb  
    211211            cp0_status_um_bit | cp0_status_ie_enabled_bit));
    212212        cp0_epc_write((uintptr_t) kernel_uarg->uspace_entry);
    213         userspace_asm(((uintptr_t) kernel_uarg->uspace_stack + STACK_SIZE),
     213        userspace_asm(((uintptr_t) kernel_uarg->uspace_stack +
     214            kernel_uarg->uspace_stack_size),
    214215            (uintptr_t) kernel_uarg->uspace_uarg,
    215216            (uintptr_t) kernel_uarg->uspace_entry);
  • kernel/arch/mips64/src/mips64.c

    rfaba839 r2902e1bb  
    188188            cp0_status_um_bit | cp0_status_ie_enabled_bit));
    189189        cp0_epc_write((uintptr_t) kernel_uarg->uspace_entry);
    190         userspace_asm(((uintptr_t) kernel_uarg->uspace_stack + STACK_SIZE),
     190        userspace_asm(((uintptr_t) kernel_uarg->uspace_stack +
     191            kernel_uarg->uspace_stack_size),
    191192            (uintptr_t) kernel_uarg->uspace_uarg,
    192193            (uintptr_t) kernel_uarg->uspace_entry);
  • kernel/arch/ppc32/src/ppc32.c

    rfaba839 r2902e1bb  
    269269{
    270270        userspace_asm((uintptr_t) kernel_uarg->uspace_uarg,
    271             (uintptr_t) kernel_uarg->uspace_stack + STACK_SIZE - SP_DELTA,
     271            (uintptr_t) kernel_uarg->uspace_stack +
     272            kernel_uarg->uspace_stack_size - SP_DELTA,
    272273            (uintptr_t) kernel_uarg->uspace_entry);
    273274       
  • kernel/arch/sparc64/src/sun4u/sparc64.c

    rfaba839 r2902e1bb  
    156156        (void) interrupts_disable();
    157157        switch_to_userspace((uintptr_t) kernel_uarg->uspace_entry,
    158             ((uintptr_t) kernel_uarg->uspace_stack) + STACK_SIZE
    159             - (ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT) + STACK_BIAS),
     158            ((uintptr_t) kernel_uarg->uspace_stack) +
     159            kernel_uarg->uspace_stack_size -
     160            (ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT) + STACK_BIAS),
    160161            (uintptr_t) kernel_uarg->uspace_uarg);
    161 
    162         for (;;)
    163                 ;
    164         /* not reached */
     162       
     163        /* Not reached */
     164        while (1);
    165165}
    166166
  • kernel/arch/sparc64/src/sun4v/sparc64.c

    rfaba839 r2902e1bb  
    154154        (void) interrupts_disable();
    155155        switch_to_userspace((uintptr_t) kernel_uarg->uspace_entry,
    156             ((uintptr_t) kernel_uarg->uspace_stack) + STACK_SIZE
    157             - (ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT) + STACK_BIAS),
     156            ((uintptr_t) kernel_uarg->uspace_stack) +
     157            kernel_uarg->uspace_stack_size -
     158            (ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT) + STACK_BIAS),
    158159            (uintptr_t) kernel_uarg->uspace_uarg);
    159 
    160         for (;;)
    161                 ;
    162         /* not reached */
     160       
     161        /* Not reached */
     162        while (1);
    163163}
    164164
Note: See TracChangeset for help on using the changeset viewer.