Changes in / [1f7753a:a7f7ed12] in mainline


Ignore:
Files:
2 deleted
22 edited

Legend:

Unmodified
Added
Removed
  • abi/include/mm/as.h

    r1f7753a ra7f7ed12  
    3737
    3838/** Address space area flags. */
    39 #define AS_AREA_READ         0x01
    40 #define AS_AREA_WRITE        0x02
    41 #define AS_AREA_EXEC         0x04
    42 #define AS_AREA_CACHEABLE    0x08
    43 #define AS_AREA_GUARD        0x10
    44 #define AS_AREA_LATE_RESERVE 0x20
     39#define AS_AREA_READ       0x01
     40#define AS_AREA_WRITE      0x02
     41#define AS_AREA_EXEC       0x04
     42#define AS_AREA_CACHEABLE  0x08
     43#define AS_AREA_GUARD      0x10
    4544
    4645/** Address space area info exported to uspace. */
  • boot/arch/ia64/src/main.c

    r1f7753a ra7f7ed12  
    4848
    4949#define DEFAULT_MEMORY_BASE             0x4000000ULL
    50 #define DEFAULT_MEMORY_SIZE             (256 * 1024 * 1024)
     50#define DEFAULT_MEMORY_SIZE             0x4000000ULL
    5151#define DEFAULT_LEGACY_IO_BASE          0x00000FFFFC000000ULL
    5252#define DEFAULT_LEGACY_IO_SIZE          0x4000000ULL
  • contrib/conf/ski.conf

    r1f7753a ra7f7ed12  
    1 load image.boot
     1load HelenOS/image.boot
  • kernel/arch/ia64/include/mm/as.h

    r1f7753a ra7f7ed12  
    4343#define USER_ADDRESS_SPACE_END_ARCH      UINT64_C(0xdfffffffffffffff)
    4444
     45#define USTACK_ADDRESS_ARCH  UINT64_C(0x0000000ff0000000)
     46
    4547typedef struct {
    4648} as_arch_t;
  • kernel/arch/ia64/src/mm/tlb.c

    r1f7753a ra7f7ed12  
    113113        va = page;
    114114       
    115         rr.word = rr_read(VA2VRN(page));
    116         if ((restore_rr = (rr.map.rid != ASID2RID(asid, VA2VRN(page))))) {
     115        rr.word = rr_read(VA2VRN(va));
     116        if ((restore_rr = (rr.map.rid != ASID2RID(asid, VA2VRN(va))))) {
    117117                /*
    118118                 * The selected region register does not contain required RID.
     
    122122               
    123123                rr0 = rr;
    124                 rr0.map.rid = ASID2RID(asid, VA2VRN(page));
    125                 rr_write(VA2VRN(page), rr0.word);
     124                rr0.map.rid = ASID2RID(asid, VA2VRN(va));
     125                rr_write(VA2VRN(va), rr0.word);
    126126                srlz_d();
    127127                srlz_i();
     
    139139        case 1: /* cnt 4 - 15 */
    140140                ps = PAGE_WIDTH + 2;
    141                 va &= ~((1UL << ps) - 1);
     141                va &= ~((1 << ps) - 1);
    142142                break;
    143143        case 2: /* cnt 16 - 63 */
    144144                ps = PAGE_WIDTH + 4;
    145                 va &= ~((1UL << ps) - 1);
     145                va &= ~((1 << ps) - 1);
    146146                break;
    147147        case 3: /* cnt 64 - 255 */
    148148                ps = PAGE_WIDTH + 6;
    149                 va &= ~((1UL << ps) - 1);
     149                va &= ~((1 << ps) - 1);
    150150                break;
    151151        case 4: /* cnt 256 - 1023 */
    152152                ps = PAGE_WIDTH + 8;
    153                 va &= ~((1UL << ps) - 1);
     153                va &= ~((1 << ps) - 1);
    154154                break;
    155155        case 5: /* cnt 1024 - 4095 */
    156156                ps = PAGE_WIDTH + 10;
    157                 va &= ~((1UL << ps) - 1);
     157                va &= ~((1 << ps) - 1);
    158158                break;
    159159        case 6: /* cnt 4096 - 16383 */
    160160                ps = PAGE_WIDTH + 12;
    161                 va &= ~((1UL << ps) - 1);
     161                va &= ~((1 << ps) - 1);
    162162                break;
    163163        case 7: /* cnt 16384 - 65535 */
    164164        case 8: /* cnt 65536 - (256K - 1) */
    165165                ps = PAGE_WIDTH + 14;
    166                 va &= ~((1UL << ps) - 1);
     166                va &= ~((1 << ps) - 1);
    167167                break;
    168168        default:
    169169                ps = PAGE_WIDTH + 18;
    170                 va &= ~((1UL << ps) - 1);
     170                va &= ~((1 << ps) - 1);
    171171                break;
    172172        }
    173173       
    174         for (; va < (page + cnt * PAGE_SIZE); va += (1UL << ps))
     174        for (; va < (page + cnt * PAGE_SIZE); va += (1 << ps))
    175175                asm volatile (
    176176                        "ptc.l %[va], %[ps] ;;"
     
    183183       
    184184        if (restore_rr) {
    185                 rr_write(VA2VRN(page), rr.word);
     185                rr_write(VA2VRN(va), rr.word);
    186186                srlz_d();
    187187                srlz_i();
  • kernel/genarch/src/mm/page_ht.c

    r1f7753a ra7f7ed12  
    209209                pte->frame = ALIGN_DOWN(frame, FRAME_SIZE);
    210210
    211                 /*
    212                  * Make sure that a concurrent ht_mapping_find() will see the
    213                  * new entry only after it is fully initialized.
    214                  */
    215211                write_barrier();
    216212               
  • kernel/genarch/src/mm/page_pt.c

    r1f7753a ra7f7ed12  
    8989                    PAGE_NOT_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE |
    9090                    PAGE_WRITE);
    91                 /*
    92                  * Make sure that a concurrent hardware page table walk or
    93                  * pt_mapping_find() will see the new PTL1 only after it is
    94                  * fully initialized.
    95                  */
    9691                write_barrier();
    9792                SET_PTL1_PRESENT(ptl0, PTL0_INDEX(page));
     
    108103                    PAGE_NOT_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE |
    109104                    PAGE_WRITE);
    110                 /*
    111                  * Make the new PTL2 visible only after it is fully initialized.
    112                  */
    113105                write_barrier();
    114106                SET_PTL2_PRESENT(ptl1, PTL1_INDEX(page));       
     
    125117                    PAGE_NOT_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE |
    126118                    PAGE_WRITE);
    127                 /*
    128                  * Make the new PTL3 visible only after it is fully initialized.
    129                  */
    130119                write_barrier();
    131120                SET_PTL3_PRESENT(ptl2, PTL2_INDEX(page));
     
    136125        SET_FRAME_ADDRESS(ptl3, PTL3_INDEX(page), frame);
    137126        SET_FRAME_FLAGS(ptl3, PTL3_INDEX(page), flags | PAGE_NOT_PRESENT);
    138         /*
    139          * Make the new mapping visible only after it is fully initialized.
    140          */
    141127        write_barrier();
    142128        SET_FRAME_PRESENT(ptl3, PTL3_INDEX(page));
     
    310296
    311297#if (PTL1_ENTRIES != 0)
    312         /*
    313          * Always read ptl2 only after we are sure it is present.
    314          */
    315298        read_barrier();
    316299#endif
     
    321304
    322305#if (PTL2_ENTRIES != 0)
    323         /*
    324          * Always read ptl3 only after we are sure it is present.
    325          */
    326306        read_barrier();
    327307#endif
  • kernel/generic/include/config.h

    r1f7753a ra7f7ed12  
    4444#define STACK_FRAMES  TWO_FRAMES
    4545#define STACK_SIZE    ((1 << STACK_FRAMES) << PAGE_WIDTH)
    46 
    47 #define STACK_SIZE_USER (1 * 1024 * 1024)
    4846
    4947#define CONFIG_INIT_TASKS        32
  • kernel/generic/include/mm/as.h

    r1f7753a ra7f7ed12  
    6161#define USER_ADDRESS_SPACE_END      USER_ADDRESS_SPACE_END_ARCH
    6262
     63#ifdef USTACK_ADDRESS_ARCH
     64        #define USTACK_ADDRESS  USTACK_ADDRESS_ARCH
     65#else
     66        #define USTACK_ADDRESS  (USER_ADDRESS_SPACE_END - (STACK_SIZE - 1))
     67#endif
     68
    6369/** Kernel address space. */
    6470#define FLAG_AS_KERNEL  (1 << 0)
     
    218224        void (* destroy)(as_area_t *);
    219225
    220         bool (* is_resizable)(as_area_t *);
    221         bool (* is_shareable)(as_area_t *);
    222 
    223226        int (* page_fault)(as_area_t *, uintptr_t, pf_access_t);
    224227        void (* frame_free)(as_area_t *, uintptr_t, uintptr_t);
  • kernel/generic/include/proc/task.h

    r1f7753a ra7f7ed12  
    134134        uint64_t ucycles;
    135135        uint64_t kcycles;
    136 
    137         /** If true, do not attempt to print a verbose kill message. */
    138         bool silent_kill;
    139136} task_t;
    140137
  • kernel/generic/src/interrupt/interrupt.c

    r1f7753a ra7f7ed12  
    168168static NO_TRACE void fault_from_uspace_core(istate_t *istate, const char *fmt, va_list args)
    169169{
    170         if (!TASK->silent_kill) {
    171                 printf("Task %s (%" PRIu64 ") killed due to an exception at "
    172                     "program counter %p.\n", TASK->name, TASK->taskid,
    173                     (void *) istate_get_pc(istate));
    174        
    175                 istate_decode(istate);
    176                 stack_trace_istate(istate);
    177        
    178                 printf("Kill message: ");
    179                 vprintf(fmt, args);
    180                 printf("\n");
    181         }
     170        printf("Task %s (%" PRIu64 ") killed due to an exception at "
     171            "program counter %p.\n", TASK->name, TASK->taskid,
     172            (void *) istate_get_pc(istate));
     173       
     174        istate_decode(istate);
     175        stack_trace_istate(istate);
     176       
     177        printf("Kill message: ");
     178        vprintf(fmt, args);
     179        printf("\n");
    182180       
    183181        task_kill_self(true);
  • kernel/generic/src/main/kinit.c

    r1f7753a ra7f7ed12  
    172172#endif /* CONFIG_KCONSOLE */
    173173       
    174         /*
    175          * Store the default stack size in sysinfo so that uspace can create
    176          * stack with this default size.
    177          */
    178         sysinfo_set_item_val("default.stack_size", NULL, STACK_SIZE_USER);
    179        
    180174        interrupts_enable();
    181175       
  • kernel/generic/src/mm/as.c

    r1f7753a ra7f7ed12  
    426426        /*
    427427         * So far, the area does not conflict with other areas.
    428          * Check if it is contained in the user address space.
     428         * Check if it doesn't conflict with kernel address space.
    429429         */
    430430        if (!KERNEL_ADDRESS_SPACE_SHADOWED) {
    431                 return iswithin(USER_ADDRESS_SPACE_START,
    432                     (USER_ADDRESS_SPACE_END - USER_ADDRESS_SPACE_START) + 1,
    433                     addr, P2SZ(count));
     431                return !overlaps(addr, P2SZ(count), KERNEL_ADDRESS_SPACE_START,
     432                    KERNEL_ADDRESS_SPACE_END - KERNEL_ADDRESS_SPACE_START);
    434433        }
    435434       
     
    697696                return ENOENT;
    698697        }
    699 
    700         if (!area->backend->is_resizable(area)) {
    701                 /*
    702                  * The backend does not support resizing for this area.
     698       
     699        if (area->backend == &phys_backend) {
     700                /*
     701                 * Remapping of address space areas associated
     702                 * with memory mapped devices is not supported.
    703703                 */
    704704                mutex_unlock(&area->lock);
     
    10571057        }
    10581058       
    1059         if (!src_area->backend->is_shareable(src_area)) {
    1060                 /*
    1061                  * The backend does not permit sharing of this area.
     1059        if ((!src_area->backend) || (!src_area->backend->share)) {
     1060                /*
     1061                 * There is no backend or the backend does not
     1062                 * know how to share the area.
    10621063                 */
    10631064                mutex_unlock(&src_area->lock);
  • kernel/generic/src/mm/backend_anon.c

    r1f7753a ra7f7ed12  
    5959static void anon_destroy(as_area_t *);
    6060
    61 static bool anon_is_resizable(as_area_t *);
    62 static bool anon_is_shareable(as_area_t *);
    63 
    6461static int anon_page_fault(as_area_t *, uintptr_t, pf_access_t);
    6562static void anon_frame_free(as_area_t *, uintptr_t, uintptr_t);
     
    7168        .destroy = anon_destroy,
    7269
    73         .is_resizable = anon_is_resizable,
    74         .is_shareable = anon_is_shareable,
    75 
    7670        .page_fault = anon_page_fault,
    7771        .frame_free = anon_frame_free,
     
    8074bool anon_create(as_area_t *area)
    8175{
    82         if (area->flags & AS_AREA_LATE_RESERVE)
    83                 return true;
    84 
    8576        return reserve_try_alloc(area->pages);
    8677}
     
    8879bool anon_resize(as_area_t *area, size_t new_pages)
    8980{
    90         if (area->flags & AS_AREA_LATE_RESERVE)
    91                 return true;
    92 
    9381        if (new_pages > area->pages)
    9482                return reserve_try_alloc(new_pages - area->pages);
     
    112100        ASSERT(mutex_locked(&area->as->lock));
    113101        ASSERT(mutex_locked(&area->lock));
    114         ASSERT(!(area->flags & AS_AREA_LATE_RESERVE));
    115102
    116103        /*
     
    152139void anon_destroy(as_area_t *area)
    153140{
    154         if (area->flags & AS_AREA_LATE_RESERVE)
    155                 return;
    156 
    157141        reserve_free(area->pages);
    158142}
    159143
    160 bool anon_is_resizable(as_area_t *area)
    161 {
    162         return true;
    163 }
    164 
    165 bool anon_is_shareable(as_area_t *area)
    166 {
    167         return !(area->flags & AS_AREA_LATE_RESERVE);
    168 }
    169144
    170145/** Service a page fault in the anonymous memory address space area.
     
    250225                 *   the different causes
    251226                 */
    252 
    253                 if (area->flags & AS_AREA_LATE_RESERVE) {
    254                         /*
    255                          * Reserve the memory for this page now.
    256                          */
    257                         if (!reserve_try_alloc(1)) {
    258                                 printf("Killing task %" PRIu64 " due to a "
    259                                     "failed late reservation request.\n",
    260                                     TASK->taskid);
    261                                 TASK->silent_kill = true;
    262                                 return AS_PF_FAULT;
    263                         }
    264                 }
    265 
    266227                kpage = km_temporary_page_get(&frame, FRAME_NO_RESERVE);
    267228                memsetb((void *) kpage, PAGE_SIZE, 0);
     
    294255        ASSERT(mutex_locked(&area->lock));
    295256
    296         if (area->flags & AS_AREA_LATE_RESERVE) {
    297                 /*
    298                  * In case of the late reserve areas, physical memory will not
    299                  * be unreserved when the area is destroyed so we need to use
    300                  * the normal unreserving frame_free().
    301                  */
    302                 frame_free(frame);
    303         } else {
    304                 /*
    305                  * The reserve will be given back when the area is destroyed or
    306                  * resized, so use the frame_free_noreserve() which does not
    307                  * manipulate the reserve or it would be given back twice.
    308                  */
    309                 frame_free_noreserve(frame);
    310         }
     257        frame_free_noreserve(frame);
    311258}
    312259
  • kernel/generic/src/mm/backend_elf.c

    r1f7753a ra7f7ed12  
    5858static void elf_destroy(as_area_t *);
    5959
    60 static bool elf_is_resizable(as_area_t *);
    61 static bool elf_is_shareable(as_area_t *);
    62 
    6360static int elf_page_fault(as_area_t *, uintptr_t, pf_access_t);
    6461static void elf_frame_free(as_area_t *, uintptr_t, uintptr_t);
     
    6966        .share = elf_share,
    7067        .destroy = elf_destroy,
    71 
    72         .is_resizable = elf_is_resizable,
    73         .is_shareable = elf_is_shareable,
    7468
    7569        .page_fault = elf_page_fault,
     
    219213}
    220214
    221 bool elf_is_resizable(as_area_t *area)
    222 {
    223         return true;
    224 }
    225 
    226 bool elf_is_shareable(as_area_t *area)
    227 {
    228         return true;
    229 }
    230 
    231 
    232215/** Service a page fault in the ELF backend address space area.
    233216 *
  • kernel/generic/src/mm/backend_phys.c

    r1f7753a ra7f7ed12  
    5252static void phys_destroy(as_area_t *);
    5353
    54 static bool phys_is_resizable(as_area_t *);
    55 static bool phys_is_shareable(as_area_t *);
    56 
    57 
    5854static int phys_page_fault(as_area_t *, uintptr_t, pf_access_t);
    5955
     
    6359        .share = phys_share,
    6460        .destroy = phys_destroy,
    65 
    66         .is_resizable = phys_is_resizable,
    67         .is_shareable = phys_is_shareable,
    6861
    6962        .page_fault = phys_page_fault,
     
    9487        /* Nothing to do. */
    9588}
    96 
    97 bool phys_is_resizable(as_area_t *area)
    98 {
    99         return false;
    100 }
    101 
    102 bool phys_is_shareable(as_area_t *area)
    103 {
    104         return true;
    105 }
    106 
    10789
    10890/** Service a page fault in the address space area backed by physical memory.
  • kernel/generic/src/mm/km.c

    r1f7753a ra7f7ed12  
    233233 * @param[inout] framep Pointer to a variable which will receive the physical
    234234 *                      address of the allocated frame.
    235  * @param[in] flags     Frame allocation flags. FRAME_NONE, FRAME_NO_RESERVE
    236  *                      and FRAME_ATOMIC bits are allowed.
     235 * @param[in] flags     Frame allocation flags. FRAME_NONE or FRAME_NO_RESERVE.
    237236 * @return              Virtual address of the allocated frame.
    238237 */
     
    244243        ASSERT(THREAD);
    245244        ASSERT(framep);
    246         ASSERT(!(flags & ~(FRAME_NO_RESERVE | FRAME_ATOMIC)));
     245        ASSERT(!(flags & ~FRAME_NO_RESERVE));
    247246
    248247        /*
     
    256255                ASSERT(page);   // FIXME
    257256        } else {
    258                 frame = (uintptr_t) frame_alloc(ONE_FRAME,
    259                     FRAME_LOWMEM | flags);
    260                 if (!frame)
    261                         return (uintptr_t) NULL;
     257                frame = (uintptr_t) frame_alloc_noreserve(ONE_FRAME,
     258                    FRAME_LOWMEM);
    262259                page = PA2KA(frame);
    263260        }
  • kernel/generic/src/proc/program.c

    r1f7753a ra7f7ed12  
    7979         * Create the stack address space area.
    8080         */
    81         uintptr_t virt = (uintptr_t) -1;
    82         uintptr_t bound = USER_ADDRESS_SPACE_END - (STACK_SIZE_USER - 1);
    83 
    84         /* Adjust bound to create space for the desired guard page. */
    85         bound -= PAGE_SIZE;
    86 
     81        uintptr_t virt = USTACK_ADDRESS;
    8782        as_area_t *area = as_area_create(as,
    88             AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE | AS_AREA_GUARD |
    89             AS_AREA_LATE_RESERVE, STACK_SIZE_USER, AS_AREA_ATTR_NONE,
    90             &anon_backend, NULL, &virt, bound);
     83            AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE,
     84            STACK_SIZE, AS_AREA_ATTR_NONE, &anon_backend, NULL, &virt, 0);
    9185        if (!area) {
    9286                task_destroy(prg->task);
     
    9993        kernel_uarg->uspace_entry = (void *) entry_addr;
    10094        kernel_uarg->uspace_stack = (void *) virt;
    101         kernel_uarg->uspace_stack_size = STACK_SIZE_USER;
     95        kernel_uarg->uspace_stack_size = STACK_SIZE;
    10296        kernel_uarg->uspace_thread_function = NULL;
    10397        kernel_uarg->uspace_thread_arg = NULL;
  • kernel/generic/src/proc/task.c

    r1f7753a ra7f7ed12  
    196196        task->ucycles = 0;
    197197        task->kcycles = 0;
    198 
    199         task->silent_kill = false;
    200198       
    201199        task->ipc_info.call_sent = 0;
  • uspace/lib/c/Makefile

    r1f7753a ra7f7ed12  
    140140        generic/net/socket_client.c \
    141141        generic/net/socket_parse.c \
    142         generic/stack.c \
    143142        generic/stacktrace.c \
    144143        generic/arg_parse.c \
  • uspace/lib/c/generic/fibril.c

    r1f7753a ra7f7ed12  
    3737#include <fibril.h>
    3838#include <thread.h>
    39 #include <stack.h>
    4039#include <tls.h>
    4140#include <malloc.h>
    42 #include <abi/mm/as.h>
    43 #include <as.h>
    4441#include <unistd.h>
    4542#include <stdio.h>
     
    4946#include <assert.h>
    5047#include <async.h>
     48
     49#ifndef FIBRIL_INITIAL_STACK_PAGES_NO
     50        #define FIBRIL_INITIAL_STACK_PAGES_NO  1
     51#endif
    5152
    5253/**
     
    194195                                         * stack member filled.
    195196                                         */
    196                                         as_area_destroy(stack);
     197                                        free(stack);
    197198                                }
    198199                                fibril_teardown(srcf->clean_after_me);
     
    268269                return 0;
    269270       
    270         size_t stack_size = stack_size_get();
    271         fibril->stack = as_area_create((void *) -1, stack_size,
    272             AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE | AS_AREA_GUARD |
    273             AS_AREA_LATE_RESERVE);
    274         if (fibril->stack == (void *) -1) {
     271        fibril->stack =
     272            (char *) malloc(FIBRIL_INITIAL_STACK_PAGES_NO * getpagesize());
     273        if (!fibril->stack) {
    275274                fibril_teardown(fibril);
    276275                return 0;
     
    282281        context_save(&fibril->ctx);
    283282        context_set(&fibril->ctx, FADDR(fibril_main), fibril->stack,
    284             stack_size, fibril->tcb);
     283            FIBRIL_INITIAL_STACK_PAGES_NO * getpagesize(), fibril->tcb);
    285284
    286285        return (fid_t) fibril;
     
    299298        fibril_t *fibril = (fibril_t *) fid;
    300299       
    301         as_area_destroy(fibril->stack);
     300        free(fibril->stack);
    302301        fibril_teardown(fibril);
    303302}
  • uspace/lib/c/generic/thread.c

    r1f7753a ra7f7ed12  
    3939#include <abi/proc/uarg.h>
    4040#include <fibril.h>
    41 #include <stack.h>
    4241#include <str.h>
    4342#include <async.h>
     
    4544#include <as.h>
    4645#include "private/thread.h"
     46
     47#ifndef THREAD_INITIAL_STACK_PAGES
     48        #define THREAD_INITIAL_STACK_PAGES  2
     49#endif
    4750
    4851/** Main thread function.
     
    98101                return ENOMEM;
    99102       
    100         size_t stack_size = stack_size_get();
     103        size_t stack_size = getpagesize() * THREAD_INITIAL_STACK_PAGES;
    101104        void *stack = as_area_create(AS_AREA_ANY, stack_size,
    102             AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE | AS_AREA_GUARD |
    103             AS_AREA_LATE_RESERVE);
     105            AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
    104106        if (stack == AS_MAP_FAILED) {
    105107                free(uarg);
Note: See TracChangeset for help on using the changeset viewer.