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 {
|
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_CONTIGUOUS_WITH_LIMIT 8 /* B_CONTIGUOUS, < physical address passed |
| 75 | into the logaddr of the create_area function */ |
74 | 76 | |
75 | 77 | /* address spec for create_area(), and clone_area() */ |
76 | 78 | #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..f9f8cdf 100644
a
|
b
|
alloc_mem(void **phy, void **log, size_t size, const char *name)
|
50 | 50 | { |
51 | 51 | // TODO: phy should be phys_addr_t*! |
52 | 52 | physical_entry pe; |
53 | | void * logadr; |
| 53 | void * logadr = (void*)(1 << 28); |
54 | 54 | area_id areaid; |
55 | 55 | status_t rv; |
56 | 56 | |
… |
… |
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_CONTIGUOUS_WITH_LIMIT, 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..6afad9f 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_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; |
1283 | 1293 | default: |
1284 | 1294 | return B_BAD_VALUE; |
1285 | 1295 | } |