|
Lines 267-273
ComputeRandomAllocationAddress()
Link Here
|
| 267 |
// x64 CPUs have a 48-bit address space and on some platforms the OS will |
267 |
// x64 CPUs have a 48-bit address space and on some platforms the OS will |
| 268 |
// give us access to 47 bits, so to be safe we right shift by 18 to leave |
268 |
// give us access to 47 bits, so to be safe we right shift by 18 to leave |
| 269 |
// 46 bits. |
269 |
// 46 bits. |
|
|
270 |
# ifdef __ia64__ |
| 271 |
// On ia64 virtual address space looks like one of: |
| 272 |
// virt_addr_64 = [ <63..61> | <unimplemented> | L3 | L2 | L1 | offset ] |
| 273 |
// virt_addr_64 = [ <63..61> | <unimplemented> | L4 | L3 | L2 | L1 | offset ] |
| 274 |
// where L{1..L4} are page tables. Each page table (except top-level L3 or L4) |
| 275 |
// is itself a page-size entry and can store PageSize / 8 entries. Top-level |
| 276 |
// entry is 1/8 of of L1/L2 (as 3 upper bits are part of <63..61> address part). |
| 277 |
// Note: that makes addressable size directly depend on page size. |
| 278 |
// |
| 279 |
// We conservatively assume 3 levels of page tables here. This makes the |
| 280 |
// following formula: |
| 281 |
// L3 = log2(PAGE / 8 / 8) = log2(PAGE / 8) - 3 |
| 282 |
// L2 = log2(PAGE / 8) |
| 283 |
// L1 = log2(PAGE / 8) |
| 284 |
// offset = log2(PAGE) = log2(PAGE / 8) + 3 |
| 285 |
// thus |
| 286 |
// L3 + L2 + L1 + offset = 4 * log2(PAGE / 8) |
| 287 |
// For more details see http://www.ia64-linux.org/doc/IA64linuxkernel.PDF |
| 288 |
// (slide 19: "user regions"). |
| 289 |
static uint64_t ia64_virt_bits = std::min<uint64_t>( |
| 290 |
4 * (mozilla::FloorLog2(gc::SystemPageSize() / 8)), |
| 291 |
46); |
| 292 |
rand >>= (64 - ia64_virt_bits); |
| 293 |
# else |
| 270 |
rand >>= 18; |
294 |
rand >>= 18; |
|
|
295 |
#endif |
| 271 |
# else |
296 |
# else |
| 272 |
// On 32-bit, right shift by 34 to leave 30 bits, range [0, 1GiB). Then add |
297 |
// On 32-bit, right shift by 34 to leave 30 bits, range [0, 1GiB). Then add |
| 273 |
// 512MiB to get range [512MiB, 1.5GiB), or [0x20000000, 0x60000000). This |
298 |
// 512MiB to get range [512MiB, 1.5GiB), or [0x20000000, 0x60000000). This |