Changeset d7533c7 in mainline


Ignore:
Timestamp:
2011-01-29T18:57:00Z (13 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6119f24
Parents:
0b6931a
Message:

add support for pareas mappable by unprivileged tasks
(currenty, only the clock page has this property)

Location:
kernel
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/arm32/src/mach/gta02/gta02.c

    r0b6931a rd7533c7  
    174174                fb_parea.pbase = GTA02_FB_BASE;
    175175                fb_parea.frames = 150;
     176                fb_parea.unpriv = false;
    176177                ddi_parea_register(&fb_parea);
    177178        }
  • kernel/arch/arm32/src/mach/integratorcp/integratorcp.c

    r0b6931a rd7533c7  
    300300                fb_parea.pbase = ICP_FB;
    301301                fb_parea.frames = 300;
     302                fb_parea.unpriv = false;
    302303                ddi_parea_register(&fb_parea);
    303304        }
  • kernel/arch/sparc64/src/drivers/niagara.c

    r0b6931a rd7533c7  
    216216        outbuf_parea.pbase = (uintptr_t) (KA2PA(&output_buffer));
    217217        outbuf_parea.frames = 1;
     218        outbuf_parea.unpriv = false;
    218219        ddi_parea_register(&outbuf_parea);
    219220
     
    221222        inbuf_parea.pbase = (uintptr_t) (KA2PA(&input_buffer));
    222223        inbuf_parea.frames = 1;
     224        inbuf_parea.unpriv = false;
    223225        ddi_parea_register(&inbuf_parea);
    224226
  • kernel/generic/include/ddi/ddi.h

    r0b6931a rd7533c7  
    4343/** Structure representing contiguous physical memory area. */
    4444typedef struct {
    45         uintptr_t pbase;    /**< Physical base of the area. */
    46         pfn_t frames;       /**< Number of frames in the area. */
     45        link_t link;      /**< Linked list link */
    4746       
    48         link_t link;        /**< Linked list link */
     47        uintptr_t pbase;  /**< Physical base of the area. */
     48        pfn_t frames;     /**< Number of frames in the area. */
     49        bool unpriv;      /**< Allow mapping by unprivileged tasks. */
    4950} parea_t;
    5051
     
    6061extern int ddi_iospace_enable_arch(task_t *, uintptr_t, size_t);
    6162
    62 
    6363#endif
    6464
  • kernel/generic/src/console/console.c

    r0b6931a rd7533c7  
    160160        klog_parea.pbase = (uintptr_t) faddr;
    161161        klog_parea.frames = SIZE2FRAMES(sizeof(klog));
     162        klog_parea.unpriv = false;
    162163        ddi_parea_register(&klog_parea);
    163164       
  • kernel/generic/src/ddi/ddi.c

    r0b6931a rd7533c7  
    104104{
    105105        ASSERT(TASK);
    106         ASSERT((pf % FRAME_SIZE) == 0);
    107         ASSERT((vp % PAGE_SIZE) == 0);
    108        
    109         /*
    110          * Make sure the caller is authorised to make this syscall.
    111          */
    112         cap_t caps = cap_get(TASK);
    113         if (!(caps & CAP_MEM_MANAGER))
    114                 return EPERM;
     106       
     107        if ((pf % FRAME_SIZE) != 0)
     108                return EBADMEM;
     109       
     110        if ((vp % PAGE_SIZE) != 0)
     111                return EBADMEM;
     112       
     113        /*
     114         * Unprivileged tasks are only allowed to map pareas
     115         * which are explicitly marked as such.
     116         */
     117        bool priv =
     118            ((cap_get(TASK) & CAP_MEM_MANAGER) == CAP_MEM_MANAGER);
    115119       
    116120        mem_backend_data_t backend_data;
     
    123127       
    124128        if (znum == (size_t) -1) {
    125                 /* Frames not found in any zones
    126                  * -> assume it is hardware device and allow mapping
     129                /*
     130                 * Frames not found in any zone
     131                 * -> assume it is a hardware device and allow mapping
     132                 *    for privileged tasks.
    127133                 */
    128134                irq_spinlock_unlock(&zones.lock, true);
     135               
     136                if (!priv)
     137                        return EPERM;
     138               
    129139                goto map;
    130140        }
    131141       
    132142        if (zones.info[znum].flags & ZONE_FIRMWARE) {
    133                 /* Frames are part of firmware */
     143                /*
     144                 * Frames are part of firmware
     145                 * -> allow mapping for privileged tasks.
     146                 */
    134147                irq_spinlock_unlock(&zones.lock, true);
     148               
     149                if (!priv)
     150                        return EPERM;
     151               
    135152                goto map;
    136153        }
     
    138155        if (zone_flags_available(zones.info[znum].flags)) {
    139156                /*
    140                  * Frames are part of physical memory, check if the memory
    141                  * region is enabled for mapping.
     157                 * Frames are part of physical memory, check
     158                 * if the memory region is enabled for mapping.
    142159                 */
    143160                irq_spinlock_unlock(&zones.lock, true);
     
    150167                if ((!parea) || (parea->frames < pages)) {
    151168                        mutex_unlock(&parea_lock);
    152                         goto err;
     169                        return ENOENT;
     170                }
     171               
     172                if (!priv) {
     173                        if (!parea->unpriv) {
     174                                mutex_unlock(&parea_lock);
     175                                return EPERM;
     176                        }
    153177                }
    154178               
     
    158182       
    159183        irq_spinlock_unlock(&zones.lock, true);
    160        
    161 err:
    162184        return ENOENT;
    163185       
  • kernel/generic/src/lib/rd.c

    r0b6931a rd7533c7  
    9090            FRAME_SIZE);
    9191        rd_parea.frames = SIZE2FRAMES(dsize);
     92        rd_parea.unpriv = false;
    9293        ddi_parea_register(&rd_parea);
    9394
  • kernel/generic/src/time/clock.c

    r0b6931a rd7533c7  
    9393        clock_parea.pbase = (uintptr_t) faddr;
    9494        clock_parea.frames = 1;
     95        clock_parea.unpriv = true;
    9596        ddi_parea_register(&clock_parea);
    9697       
     
    100101         *
    101102         */
    102         sysinfo_set_item_val("clock.cacheable", NULL, (sysarg_t) true);
    103103        sysinfo_set_item_val("clock.faddr", NULL, (sysarg_t) faddr);
    104104}
Note: See TracChangeset for help on using the changeset viewer.