Changeset cb569e6 in mainline for kernel


Ignore:
Timestamp:
2010-11-18T21:58:27Z (15 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4e5c7ba
Parents:
69e0d6d (diff), 45f04f8 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

Location:
kernel
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/amd64/include/mm/as.h

    r69e0d6d rcb569e6  
    3636#define KERN_amd64_AS_H_
    3737
     38#define ADDRESS_SPACE_HOLE_START        0x0000800000000000ULL
     39#define ADDRESS_SPACE_HOLE_END          0xffff7fffffffffffULL
     40
    3841#define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH  0
    3942
    40 #define KERNEL_ADDRESS_SPACE_START_ARCH  (unsigned long) 0xffff800000000000
    41 #define KERNEL_ADDRESS_SPACE_END_ARCH    (unsigned long) 0xffffffffffffffff
     43#define KERNEL_ADDRESS_SPACE_START_ARCH 0xffff800000000000ULL
     44#define KERNEL_ADDRESS_SPACE_END_ARCH   0xffffffffffffffffULL
    4245
    43 #define USER_ADDRESS_SPACE_START_ARCH    (unsigned long) 0x0000000000000000
    44 #define USER_ADDRESS_SPACE_END_ARCH      (unsigned long) 0x00007fffffffffff
     46#define USER_ADDRESS_SPACE_START_ARCH   0x0000000000000000ULL
     47#define USER_ADDRESS_SPACE_END_ARCH     0x00007fffffffffffULL
    4548
    4649#define USTACK_ADDRESS_ARCH  (USER_ADDRESS_SPACE_END_ARCH - (PAGE_SIZE - 1))
  • kernel/arch/amd64/include/pm.h

    r69e0d6d rcb569e6  
    8383
    8484#define TSS_BASIC_SIZE  104
    85 #define TSS_IOMAP_SIZE  (16 * 1024 + 1)  /* 16K for bitmap + 1 terminating byte for convenience */
     85#define TSS_IOMAP_SIZE  (8 * 1024 + 1)  /* 8K for bitmap + 1 terminating byte for convenience */
    8686
    8787#define IO_PORTS  (64 * 1024)
  • kernel/arch/amd64/src/ddi/ddi.c

    r69e0d6d rcb569e6  
    126126                bitmap_initialize(&iomap, CPU->arch.tss->iomap,
    127127                    TSS_IOMAP_SIZE * 8);
    128                 bitmap_copy(&iomap, &TASK->arch.iomap, TASK->arch.iomap.bits);
     128                bitmap_copy(&iomap, &TASK->arch.iomap, bits);
    129129               
     130                /*
     131                 * Set the trailing bits in the last byte of the map to disable
     132                 * I/O access.
     133                 */
     134                bitmap_set_range(&iomap, bits, ALIGN_UP(bits, 8) - bits);
    130135                /*
    131136                 * It is safe to set the trailing eight bits because of the
    132137                 * extra convenience byte in TSS_IOMAP_SIZE.
    133138                 */
    134                 bitmap_set_range(&iomap, ALIGN_UP(TASK->arch.iomap.bits, 8), 8);
     139                bitmap_set_range(&iomap, ALIGN_UP(bits, 8), 8);
    135140        }
    136141        irq_spinlock_unlock(&TASK->lock, false);
  • kernel/arch/ia32/include/pm.h

    r69e0d6d rcb569e6  
    7575
    7676#define TSS_BASIC_SIZE  104
    77 #define TSS_IOMAP_SIZE  (16 * 1024 + 1)  /* 16K for bitmap + 1 terminating byte for convenience */
     77#define TSS_IOMAP_SIZE  (8 * 1024 + 1)  /* 8K for bitmap + 1 terminating byte for convenience */
    7878
    7979#define IO_PORTS  (64 * 1024)
  • kernel/arch/ia32/src/ddi/ddi.c

    r69e0d6d rcb569e6  
    127127                bitmap_initialize(&iomap, CPU->arch.tss->iomap,
    128128                    TSS_IOMAP_SIZE * 8);
    129                 bitmap_copy(&iomap, &TASK->arch.iomap, TASK->arch.iomap.bits);
     129                bitmap_copy(&iomap, &TASK->arch.iomap, bits);
    130130               
     131                /*
     132                 * Set the trailing bits in the last byte of the map to disable
     133                 * I/O access.
     134                 */
     135                bitmap_set_range(&iomap, bits, ALIGN_UP(bits, 8) - bits);
    131136                /*
    132137                 * It is safe to set the trailing eight bits because of the
    133138                 * extra convenience byte in TSS_IOMAP_SIZE.
    134139                 */
    135                 bitmap_set_range(&iomap, ALIGN_UP(TASK->arch.iomap.bits, 8), 8);
     140                bitmap_set_range(&iomap, ALIGN_UP(bits, 8), 8);
    136141        }
    137142        irq_spinlock_unlock(&TASK->lock, false);
  • kernel/generic/include/typedefs.h

    r69e0d6d rcb569e6  
    4040#include <arch/types.h>
    4141
    42 #define NULL  0
     42#define NULL  0UL
    4343
    4444#define false  0
  • kernel/generic/src/adt/bitmap.c

    r69e0d6d rcb569e6  
    3232/**
    3333 * @file
    34  * @brief       Implementation of bitmap ADT.
     34 * @brief Implementation of bitmap ADT.
    3535 *
    3636 * This file implements bitmap ADT and provides functions for
     
    5151 * No portion of the bitmap is set or cleared by this function.
    5252 *
    53  * @param bitmap Bitmap structure.
    54  * @param map Address of the memory used to hold the map.
    55  * @param bits Number of bits stored in bitmap.
     53 * @param bitmap        Bitmap structure.
     54 * @param map           Address of the memory used to hold the map.
     55 * @param bits          Number of bits stored in bitmap.
    5656 */
    5757void bitmap_initialize(bitmap_t *bitmap, uint8_t *map, size_t bits)
     
    6363/** Set range of bits.
    6464 *
    65  * @param bitmap Bitmap structure.
    66  * @param start Starting bit.
    67  * @param bits Number of bits to set.
     65 * @param bitmap        Bitmap structure.
     66 * @param start         Starting bit.
     67 * @param bits          Number of bits to set.
    6868 */
    6969void bitmap_set_range(bitmap_t *bitmap, size_t start, size_t bits)
     
    7171        size_t i = 0;
    7272        size_t aligned_start;
    73         size_t lub;             /* leading unaligned bits */
    74         size_t amb;             /* aligned middle bits */
    75         size_t tab;             /* trailing aligned bits */
     73        size_t lub;     /* leading unaligned bits */
     74        size_t amb;     /* aligned middle bits */
     75        size_t tab;     /* trailing aligned bits */
    7676       
    7777        ASSERT(start + bits <= bitmap->bits);
     
    8282        tab = amb % 8;
    8383       
    84         if ( start + bits < aligned_start ) {
    85             /*
    86             * Set bits in the middle of byte
    87             */
    88             bitmap->map[start / 8] |= ((1 << lub)-1) << (start&7);
    89             return;
     84        if (!bits)
     85                return;
     86
     87        if (start + bits < aligned_start) {
     88                /* Set bits in the middle of byte. */
     89                bitmap->map[start / 8] |= ((1 << lub) - 1) << (start & 7);
     90                return;
    9091        }
    9192       
    9293        if (lub) {
    93                 /*
    94                  * Make sure to set any leading unaligned bits.
    95                  */
     94                /* Make sure to set any leading unaligned bits. */
    9695                bitmap->map[start / 8] |= ~((1 << (8 - lub)) - 1);
    9796        }
    9897        for (i = 0; i < amb / 8; i++) {
    99                 /*
    100                  * The middle bits can be set byte by byte.
    101                  */
     98                /* The middle bits can be set byte by byte. */
    10299                bitmap->map[aligned_start / 8 + i] = ALL_ONES;
    103100        }
    104101        if (tab) {
    105                 /*
    106                  * Make sure to set any trailing aligned bits.
    107                  */
     102                /* Make sure to set any trailing aligned bits. */
    108103                bitmap->map[aligned_start / 8 + i] |= (1 << tab) - 1;
    109104        }
     
    113108/** Clear range of bits.
    114109 *
    115  * @param bitmap Bitmap structure.
    116  * @param start Starting bit.
    117  * @param bits Number of bits to clear.
     110 * @param bitmap        Bitmap structure.
     111 * @param start         Starting bit.
     112 * @param bits          Number of bits to clear.
    118113 */
    119114void bitmap_clear_range(bitmap_t *bitmap, size_t start, size_t bits)
     
    121116        size_t i = 0;
    122117        size_t aligned_start;
    123         size_t lub;             /* leading unaligned bits */
    124         size_t amb;             /* aligned middle bits */
    125         size_t tab;             /* trailing aligned bits */
     118        size_t lub;     /* leading unaligned bits */
     119        size_t amb;     /* aligned middle bits */
     120        size_t tab;     /* trailing aligned bits */
    126121       
    127122        ASSERT(start + bits <= bitmap->bits);
     
    132127        tab = amb % 8;
    133128
    134         if ( start + bits < aligned_start )
    135         {
    136             /*
    137             * Set bits in the middle of byte
    138             */
    139             bitmap->map[start / 8] &= ~(((1 << lub)-1) << (start&7));
    140             return;
     129        if (!bits)
     130                return;
     131
     132        if (start + bits < aligned_start) {
     133                /* Set bits in the middle of byte */
     134                bitmap->map[start / 8] &= ~(((1 << lub) - 1) << (start & 7));
     135                return;
    141136        }
    142137
    143 
    144138        if (lub) {
    145                 /*
    146                  * Make sure to clear any leading unaligned bits.
    147                  */
     139                /* Make sure to clear any leading unaligned bits. */
    148140                bitmap->map[start / 8] &= (1 << (8 - lub)) - 1;
    149141        }
    150142        for (i = 0; i < amb / 8; i++) {
    151                 /*
    152                  * The middle bits can be cleared byte by byte.
    153                  */
     143                /* The middle bits can be cleared byte by byte. */
    154144                bitmap->map[aligned_start / 8 + i] = ALL_ZEROES;
    155145        }
    156146        if (tab) {
    157                 /*
    158                  * Make sure to clear any trailing aligned bits.
    159                  */
     147                /* Make sure to clear any trailing aligned bits. */
    160148                bitmap->map[aligned_start / 8 + i] &= ~((1 << tab) - 1);
    161149        }
     
    165153/** Copy portion of one bitmap into another bitmap.
    166154 *
    167  * @param dst Destination bitmap.
    168  * @param src Source bitmap.
    169  * @param bits Number of bits to copy.
     155 * @param dst           Destination bitmap.
     156 * @param src           Source bitmap.
     157 * @param bits          Number of bits to copy.
    170158 */
    171159void bitmap_copy(bitmap_t *dst, bitmap_t *src, size_t bits)
  • kernel/generic/src/syscall/copy.c

    r69e0d6d rcb569e6  
    6868        if (!KERNEL_ADDRESS_SPACE_SHADOWED) {
    6969                if (overlaps((uintptr_t) uspace_src, size,
    70                         KERNEL_ADDRESS_SPACE_START, KERNEL_ADDRESS_SPACE_END-KERNEL_ADDRESS_SPACE_START)) {
     70                        KERNEL_ADDRESS_SPACE_START,
     71                        KERNEL_ADDRESS_SPACE_END - KERNEL_ADDRESS_SPACE_START)) {
    7172                        /*
    7273                         * The userspace source block conflicts with kernel address space.
     
    7576                }
    7677        }
     78
     79#ifdef ADDRESS_SPACE_HOLE_START
     80        /*
     81         * Check whether the address is outside the address space hole.
     82         */
     83        if (overlaps((uintptr_t) uspace_src, size, ADDRESS_SPACE_HOLE_START,
     84            ADDRESS_SPACE_HOLE_END - ADDRESS_SPACE_HOLE_START))
     85                return EPERM;
     86#endif
    7787       
    7888        ipl = interrupts_disable();
     
    109119        if (!KERNEL_ADDRESS_SPACE_SHADOWED) {
    110120                if (overlaps((uintptr_t) uspace_dst, size,
    111                         KERNEL_ADDRESS_SPACE_START, KERNEL_ADDRESS_SPACE_END-KERNEL_ADDRESS_SPACE_START)) {
     121                        KERNEL_ADDRESS_SPACE_START,
     122                        KERNEL_ADDRESS_SPACE_END - KERNEL_ADDRESS_SPACE_START)) {
    112123                        /*
    113124                         * The userspace destination block conflicts with kernel address space.
     
    116127                }
    117128        }
     129
     130#ifdef ADDRESS_SPACE_HOLE_START
     131        /*
     132         * Check whether the address is outside the address space hole.
     133         */
     134        if (overlaps((uintptr_t) uspace_dst, size, ADDRESS_SPACE_HOLE_START,
     135            ADDRESS_SPACE_HOLE_END - ADDRESS_SPACE_HOLE_START))
     136                return EPERM;
     137#endif
    118138       
    119139        ipl = interrupts_disable();
Note: See TracChangeset for help on using the changeset viewer.