2270 return anon_munmap(addr, size); |
2270 return anon_munmap(addr, size); |
2271 } |
2271 } |
2272 |
2272 |
2273 static bool bsd_mprotect(char* addr, size_t size, int prot) { |
2273 static bool bsd_mprotect(char* addr, size_t size, int prot) { |
2274 // Bsd wants the mprotect address argument to be page aligned. |
2274 // Bsd wants the mprotect address argument to be page aligned. |
2275 char* bottom = (char*)align_size_down((intptr_t)addr, os::Bsd::page_size()); |
2275 char* bottom = (char*)align_down((intptr_t)addr, os::Bsd::page_size()); |
2276 |
2276 |
2277 // According to SUSv3, mprotect() should only be used with mappings |
2277 // According to SUSv3, mprotect() should only be used with mappings |
2278 // established by mmap(), and mmap() always maps whole pages. Unaligned |
2278 // established by mmap(), and mmap() always maps whole pages. Unaligned |
2279 // 'addr' likely indicates problem in the VM (e.g. trying to change |
2279 // 'addr' likely indicates problem in the VM (e.g. trying to change |
2280 // protection of malloc'ed or statically allocated memory). Check the |
2280 // protection of malloc'ed or statically allocated memory). Check the |
2281 // caller if you hit this assert. |
2281 // caller if you hit this assert. |
2282 assert(addr == bottom, "sanity check"); |
2282 assert(addr == bottom, "sanity check"); |
2283 |
2283 |
2284 size = align_size_up(pointer_delta(addr, bottom, 1) + size, os::Bsd::page_size()); |
2284 size = align_up(pointer_delta(addr, bottom, 1) + size, os::Bsd::page_size()); |
2285 return ::mprotect(bottom, size, prot) == 0; |
2285 return ::mprotect(bottom, size, prot) == 0; |
2286 } |
2286 } |
2287 |
2287 |
2288 // Set protections specified |
2288 // Set protections specified |
2289 bool os::protect_memory(char* addr, size_t bytes, ProtType prot, |
2289 bool os::protect_memory(char* addr, size_t bytes, ProtType prot, |