Ticket #9074: 0001-Fix-3079-and-9074-Memory-alocation-beyond-256MB.2.patch

File 0001-Fix-3079-and-9074-Memory-alocation-beyond-256MB.2.patch, 3.0 KB (added by jerl1, 10 years ago)
  • headers/os/kernel/OS.h

    From 17ac87d324b5666458ebc5a42b09ca020682adb1 Mon Sep 17 00:00:00 2001
    From: Jerome Leveque <leveque.jerome@gmail.com>
    Date: Sat, 31 Jan 2015 23:59:22 +0100
    Subject: [PATCH] Fix #3079 and #9074 Memory alocation beyond 256MB
    
    ICE1712 chipset does not support DMA access beyond 256MB.
    Also add in the driver a check of the address
    for not crashing the whole system, useless now but
    it's safer.
    ---
     headers/os/kernel/OS.h                          |  2 ++
     src/add-ons/kernel/drivers/audio/ice1712/util.c |  7 +++----
     src/system/kernel/vm/vm.cpp                     | 10 ++++++++++
     3 files changed, 15 insertions(+), 4 deletions(-)
    
    diff --git a/headers/os/kernel/OS.h b/headers/os/kernel/OS.h
    index 6165bff..6c61f47 100644
    a b typedef struct area_info {  
    7171#define B_LOMEM                 4   /* B_CONTIGUOUS, < 16 MB physical address */
    7272#define B_32_BIT_FULL_LOCK      5   /* B_FULL_LOCK, < 4 GB physical addresses */
    7373#define B_32_BIT_CONTIGUOUS     6   /* B_CONTIGUOUS, < 4 GB physical address */
     74#define B_CONTIGUOUS_WITH_LIMIT 8   /* B_CONTIGUOUS, < physical address passed
     75into the logaddr of the create_area function */
    7476
    7577/* address spec for create_area(), and clone_area() */
    7678#define B_ANY_ADDRESS               0
  • src/add-ons/kernel/drivers/audio/ice1712/util.c

    diff --git a/src/add-ons/kernel/drivers/audio/ice1712/util.c b/src/add-ons/kernel/drivers/audio/ice1712/util.c
    index 2feea67..f9f8cdf 100644
    a b alloc_mem(void **phy, void **log, size_t size, const char *name)  
    5050{
    5151// TODO: phy should be phys_addr_t*!
    5252    physical_entry pe;
    53     void * logadr;
     53    void * logadr = (void*)(1 << 28);
    5454    area_id areaid;
    5555    status_t rv;
    5656
    alloc_mem(void **phy, void **log, size_t size, const char *name)  
    5858
    5959    size = round_to_pagesize(size);
    6060    areaid = create_area(name, &logadr, B_ANY_KERNEL_ADDRESS, size,
    61         B_32_BIT_CONTIGUOUS, B_READ_AREA | B_WRITE_AREA);
    62         // TODO: The rest of the code doesn't deal correctly with physical
    63         // addresses > 4 GB, so we have to force 32 bit addresses here.
     61        B_CONTIGUOUS_WITH_LIMIT, B_READ_AREA | B_WRITE_AREA);
     62        // ICE1712 chipset can not deal with memory area beyond 256MB
    6463    if (areaid < B_OK) {
    6564        TRACE("couldn't allocate area %s\n",name);
    6665        return B_ERROR;
  • src/system/kernel/vm/vm.cpp

    diff --git a/src/system/kernel/vm/vm.cpp b/src/system/kernel/vm/vm.cpp
    index 569b62d..6afad9f 100644
    a b vm_create_anonymous_area(team_id team, const char *name, addr_t size,  
    12801280            wiring = B_CONTIGUOUS;
    12811281            doReserveMemory = true;
    12821282            break;
     1283        case B_CONTIGUOUS_WITH_LIMIT:
     1284                if (vm_page_max_address() >= (phys_addr_t)(*_address)) {
     1285                    stackPhysicalRestrictions = *physicalAddressRestrictions;
     1286                    stackPhysicalRestrictions.high_address
     1287                        = (phys_addr_t)(*_address);
     1288                    physicalAddressRestrictions = &stackPhysicalRestrictions;
     1289                }
     1290            wiring = B_CONTIGUOUS;
     1291            doReserveMemory = true;
     1292            break;
    12831293        default:
    12841294            return B_BAD_VALUE;
    12851295    }