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

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

    From f61a095c7815fdbacb8038498905a45437c1f6e5 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 1/2] 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                          |  1 +
     src/add-ons/kernel/drivers/audio/ice1712/util.c |  5 ++---
     src/system/kernel/vm/vm.cpp                     | 12 ++++++++++++
     3 files changed, 15 insertions(+), 3 deletions(-)
    
    diff --git a/headers/os/kernel/OS.h b/headers/os/kernel/OS.h
    index 6165bff..c3116c5 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_28_BIT_CONTIGUOUS     28  /* B_CONTIGUOUS, < 256 MB physical address */
    7475
    7576/* address spec for create_area(), and clone_area() */
    7677#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..86ea00d 100644
    a b 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_28_BIT_CONTIGUOUS, 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..739f8e3 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_28_BIT_CONTIGUOUS:
     1284            #if B_HAIKU_PHYSICAL_BITS > 28
     1285                if (vm_page_max_address() >= (phys_addr_t)1 << 28) {
     1286                    stackPhysicalRestrictions = *physicalAddressRestrictions;
     1287                    stackPhysicalRestrictions.high_address
     1288                        = (phys_addr_t)1 << 28;
     1289                    physicalAddressRestrictions = &stackPhysicalRestrictions;
     1290                }
     1291            #endif
     1292            wiring = B_CONTIGUOUS;
     1293            doReserveMemory = true;
     1294            break;
    12831295        default:
    12841296            return B_BAD_VALUE;
    12851297    }