Changeset 2057572 in mainline for uspace


Ignore:
Timestamp:
2007-03-27T23:40:25Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
399ece9
Parents:
8d37a06
Message:

The Ultimate Solution To Illegal Virtual Aliases.
It is better to avoid them completely than to fight them.
Switch the sparc64 port to 16K pages. The TLBs and TSBs
continue to operate with 8K pages only. Page tables and
other generic parts operate with 16K pages.

Because the MMU doesn't support 16K directly, each 16K
page is emulated by a pair of 8K pages. With 16K pages,
illegal aliases cannot be created in 16K D-cache.

Location:
uspace
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • uspace/fb/ega.c

    r8d37a06 r2057572  
    316316
    317317        sz = scr_width * scr_height * 2;
    318         scr_addr = as_get_mappable_page(sz, (int)
    319                 sysinfo_value("fb.address.color"));
     318        scr_addr = as_get_mappable_page(sz);
    320319
    321320        physmem_map(ega_ph_addr, scr_addr, ALIGN_UP(sz, PAGE_SIZE) >>
  • uspace/fb/fb.c

    r8d37a06 r2057572  
    756756                /* We accept one area for data interchange */
    757757                if (IPC_GET_ARG1(*call) == shm_id) {
    758                         void *dest = as_get_mappable_page(IPC_GET_ARG2(*call),
    759                                 PAGE_COLOR(IPC_GET_ARG1(*call)));
     758                        void *dest = as_get_mappable_page(IPC_GET_ARG2(*call));
    760759                        shm_size = IPC_GET_ARG2(*call);
    761760                        if (!ipc_answer_fast(callid, 0, (sysarg_t) dest, 0))
     
    13701369
    13711370        asz = fb_scanline * fb_height;
    1372         fb_addr = as_get_mappable_page(asz, (int)
    1373                 sysinfo_value("fb.address.color"));
     1371        fb_addr = as_get_mappable_page(asz);
    13741372       
    13751373        physmem_map(fb_ph_addr, fb_addr, ALIGN_UP(asz, PAGE_SIZE) >>
  • uspace/fb/main.c

    r8d37a06 r2057572  
    4444        void *dest;
    4545
    46         dest = as_get_mappable_page(IPC_GET_ARG2(*call),
    47                 PAGE_COLOR(IPC_GET_ARG1(*call)));
     46        dest = as_get_mappable_page(IPC_GET_ARG2(*call));
    4847        if (ipc_answer_fast(callid, 0, (sysarg_t) dest, 0) == 0) {
    4948                if (*area)
  • uspace/klog/klog.c

    r8d37a06 r2057572  
    6363        printf("Kernel console output.\n");
    6464       
    65         mapping = as_get_mappable_page(PAGE_SIZE, sysinfo_value("klog.fcolor"));
     65        mapping = as_get_mappable_page(PAGE_SIZE);
    6666        res = ipc_call_sync_3(PHONE_NS, IPC_M_AS_AREA_RECV,
    6767                              (sysarg_t) mapping, PAGE_SIZE, SERVICE_MEM_KLOG,
  • uspace/libc/arch/sparc64/_link.ld.in

    r8d37a06 r2057572  
    88
    99SECTIONS {
    10         . = 0x2000;
     10        . = 0x4000;
    1111
    12         .init ALIGN(0x2000) : SUBALIGN(0x2000) {
     12        .init ALIGN(0x4000) : SUBALIGN(0x4000) {
    1313                *(.init);
    1414        } :text
     
    1818        } :text
    1919       
    20         .got ALIGN(0x2000) : SUBALIGN(0x2000) {
     20        .got ALIGN(0x4000) : SUBALIGN(0x4000) {
    2121                 _gp = .;
    2222                 *(.got*);
    2323        } :data
    24         .data ALIGN(0x2000) : SUBALIGN(0x2000) {
     24        .data ALIGN(0x4000) : SUBALIGN(0x4000) {
    2525                *(.data);
    2626                *(.sdata);
     
    4242        } :data
    4343
    44         . = ALIGN(0x2000);
     44        . = ALIGN(0x4000);
    4545        _heap = .;
    4646       
  • uspace/libc/arch/sparc64/include/config.h

    r8d37a06 r2057572  
    3636#define LIBC_sparc64_CONFIG_H_
    3737
    38 #define PAGE_WIDTH      13
    39 #define PAGE_SIZE       (1<<PAGE_WIDTH)
    40 #define PAGE_COLOR_BITS 1               /**< Bit 13 is the page color. */
     38#define PAGE_WIDTH      14
     39#define PAGE_SIZE       (1 << PAGE_WIDTH)
     40#define PAGE_COLOR_BITS 0               /**< Only one page color. */
    4141
    4242#endif
  • uspace/libc/arch/sparc64/include/stack.h

    r8d37a06 r2057572  
    4444 * 16-extended-word save area for %i[0-7] and %l[0-7] registers.
    4545 */
    46 #define STACK_WINDOW_SAVE_AREA_SIZE     (16*STACK_ITEM_SIZE)
     46#define STACK_WINDOW_SAVE_AREA_SIZE     (16 * STACK_ITEM_SIZE)
    4747
    4848/**
  • uspace/libc/generic/as.c

    r8d37a06 r2057572  
    5656{
    5757        return (void *) __SYSCALL3(SYS_AS_AREA_CREATE, (sysarg_t ) address,
    58                 (sysarg_t) size, (sysarg_t) flags);
     58            (sysarg_t) size, (sysarg_t) flags);
    5959}
    6060
     
    7070int as_area_resize(void *address, size_t size, int flags)
    7171{
    72         return __SYSCALL3(SYS_AS_AREA_RESIZE, (sysarg_t ) address, (sysarg_t)
    73                 size, (sysarg_t) flags);
     72        return __SYSCALL3(SYS_AS_AREA_RESIZE, (sysarg_t ) address,
     73            (sysarg_t) size, (sysarg_t) flags);
    7474}
    7575
     
    144144 *
    145145 * @param sz Requested size of the allocation.
    146  * @param color Requested virtual color of the allocation.
    147146 *
    148147 * @return Pointer to the beginning
     
    151150 *       the pointer to last area
    152151 */
    153 void *as_get_mappable_page(size_t sz, int color)
     152void *as_get_mappable_page(size_t sz)
    154153{
    155154        void *res;
     
    167166       
    168167        /*
    169          * Make sure we allocate from naturally aligned address and a page of
    170          * appropriate color.
     168         * Make sure we allocate from naturally aligned address.
    171169         */
    172170        i = 0;
    173         do {
    174                 if (!last_allocated) {
    175                         last_allocated = (void *) ALIGN_UP((void *) &_heap +
    176                                 maxheapsize, asz);
    177                 } else {
    178                         last_allocated = (void *) ALIGN_UP(((uintptr_t)
    179                                 last_allocated) + (int) (i > 0), asz);
    180                 }
    181         } while ((asz < (1 << (PAGE_COLOR_BITS + PAGE_WIDTH))) &&
    182                 (PAGE_COLOR((uintptr_t) last_allocated) != color) &&
    183                 (++i < (1 << PAGE_COLOR_BITS)));
     171        if (!last_allocated) {
     172                last_allocated = (void *) ALIGN_UP((void *) &_heap +
     173                    maxheapsize, asz);
     174        } else {
     175                last_allocated = (void *) ALIGN_UP(((uintptr_t)
     176                    last_allocated) + (int) (i > 0), asz);
     177        }
    184178
    185179        res = last_allocated;
  • uspace/libc/generic/mman.c

    r8d37a06 r2057572  
    3737#include <unistd.h>
    3838
    39 void *mmap(void  *start, size_t length, int prot, int flags, int fd, off_t offset)
     39void *mmap(void  *start, size_t length, int prot, int flags, int fd,
     40    off_t offset)
    4041{
    4142        if (!start)
    42                 start = as_get_mappable_page(length, 0);
     43                start = as_get_mappable_page(length);
    4344       
    4445//      if (! ((flags & MAP_SHARED) ^ (flags & MAP_PRIVATE)))
  • uspace/libc/generic/time.c

    r8d37a06 r2057572  
    7373
    7474        if (!ktime) {
    75                 mapping = as_get_mappable_page(PAGE_SIZE, (int)
    76                         sysinfo_value("clock.fcolor"));
     75                mapping = as_get_mappable_page(PAGE_SIZE);
    7776                /* Get the mapping of kernel clock */
    78                 res = ipc_call_sync_3(PHONE_NS, IPC_M_AS_AREA_RECV, (sysarg_t)
    79                         mapping, PAGE_SIZE, SERVICE_MEM_REALTIME, NULL, &rights,
    80                         NULL);
     77                res = ipc_call_sync_3(PHONE_NS, IPC_M_AS_AREA_RECV,
     78                    (sysarg_t) mapping, PAGE_SIZE, SERVICE_MEM_REALTIME, NULL,
     79                    &rights, NULL);
    8180                if (res) {
    8281                        printf("Failed to initialize timeofday memarea\n");
  • uspace/libc/include/as.h

    r8d37a06 r2057572  
    4141#include <libarch/config.h>
    4242
    43 #define PAGE_COLOR(va)  (((va) >> PAGE_WIDTH) & ((1 << PAGE_COLOR_BITS) - 1))
    44 
    4543extern void *as_area_create(void *address, size_t size, int flags);
    4644extern int as_area_resize(void *address, size_t size, int flags);
    4745extern int as_area_destroy(void *address);
    4846extern void *set_maxheapsize(size_t mhs);
    49 extern void * as_get_mappable_page(size_t sz, int color);
     47extern void * as_get_mappable_page(size_t sz);
    5048
    5149#endif
  • uspace/ns/ns.c

    r8d37a06 r2057572  
    8484static void *klogaddr = NULL;
    8585
    86 static void get_as_area(ipc_callid_t callid, ipc_call_t *call, char *name, char *colstr, void **addr)
     86static void get_as_area(ipc_callid_t callid, ipc_call_t *call, char *name, void **addr)
    8787{
    8888        void *ph_addr;
    89         int ph_color;
    9089
    9190        if (!*addr) {
     
    9594                        return;
    9695                }
    97                 ph_color = (int) sysinfo_value(colstr);
    98                 *addr = as_get_mappable_page(PAGE_SIZE, ph_color);
     96                *addr = as_get_mappable_page(PAGE_SIZE);
    9997                physmem_map(ph_addr, *addr, 1, AS_AREA_READ | AS_AREA_CACHEABLE);
    10098        }
     
    120118                        case SERVICE_MEM_REALTIME:
    121119                                get_as_area(callid, &call, "clock.faddr",
    122                                         "clock.fcolor", &clockaddr);
     120                                    &clockaddr);
    123121                                break;
    124122                        case SERVICE_MEM_KLOG:
    125123                                get_as_area(callid, &call, "klog.faddr",
    126                                         "klog.fcolor", &klogaddr);
     124                                    &klogaddr);
    127125                                break;
    128126                        default:
  • uspace/rd/rd.c

    r8d37a06 r2057572  
    7474        size_t rd_size = sysinfo_value("rd.size");
    7575        void * rd_ph_addr = (void *) sysinfo_value("rd.address.physical");
    76         int rd_color = (int) sysinfo_value("rd.address.color");
    7776       
    7877        if (rd_size == 0)
    7978                return false;
    8079       
    81         void * rd_addr = as_get_mappable_page(rd_size, rd_color);
     80        void * rd_addr = as_get_mappable_page(rd_size);
    8281       
    8382        physmem_map(rd_ph_addr, rd_addr, ALIGN_UP(rd_size, PAGE_SIZE) >> PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE);
Note: See TracChangeset for help on using the changeset viewer.