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 {
|
71 | 71 | #define B_LOMEM 4 /* B_CONTIGUOUS, < 16 MB physical address */ |
72 | 72 | #define B_32_BIT_FULL_LOCK 5 /* B_FULL_LOCK, < 4 GB physical addresses */ |
73 | 73 | #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 */ |
74 | 75 | |
75 | 76 | /* address spec for create_area(), and clone_area() */ |
76 | 77 | #define B_ANY_ADDRESS 0 |
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)
|
58 | 58 | |
59 | 59 | size = round_to_pagesize(size); |
60 | 60 | 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 |
64 | 63 | if (areaid < B_OK) { |
65 | 64 | TRACE("couldn't allocate area %s\n",name); |
66 | 65 | return B_ERROR; |
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,
|
1280 | 1280 | wiring = B_CONTIGUOUS; |
1281 | 1281 | doReserveMemory = true; |
1282 | 1282 | 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; |
1283 | 1295 | default: |
1284 | 1296 | return B_BAD_VALUE; |
1285 | 1297 | } |