Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(547)

Unified Diff: base/allocator/partition_allocator/address_space_randomization.cc

Issue 2780733002: Use the full 47 bits of address space on Windows >= 8.1. (Closed)
Patch Set: `git cl format` is bad and should feel bad. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/allocator/partition_allocator/address_space_randomization.cc
diff --git a/base/allocator/partition_allocator/address_space_randomization.cc b/base/allocator/partition_allocator/address_space_randomization.cc
index d710e006bfdc686d9df3ab17befcbcde38f9b5a8..55ccf987c4e33765bc4a66d030a9081e81dc10c4 100644
--- a/base/allocator/partition_allocator/address_space_randomization.cc
+++ b/base/allocator/partition_allocator/address_space_randomization.cc
@@ -10,6 +10,7 @@
#if defined(OS_WIN)
#include <windows.h>
+#include <VersionHelpers.h>
#else
#include <sys/time.h>
#include <unistd.h>
@@ -89,11 +90,17 @@ void* GetRandomPageBase() {
// This address mask gives a low likelihood of address space collisions. We
// handle the situation gracefully if there is a collision.
#if defined(OS_WIN)
- // 64-bit Windows has a bizarrely small 8TB user address space. Allocates in
- // the 1-5TB region. TODO(palmer): See if Windows >= 8.1 has the full 47 bits,
- // and use it if so. crbug.com/672219
random &= 0x3ffffffffffUL;
- random += 0x10000000000UL;
+ // Windows >= 8.1 has the full 47 bits. Use them where available.
+ static bool windows_81 = false;
+ static bool windows_81_initialized = false;
+ if (!windows_81_initialized) {
+ windows_81 = IsWindows8Point1OrGreater();
Will Harris 2017/03/28 16:42:16 can this code use base::win::GetVersion - by conve
palmer 2017/03/28 19:05:35 Thanks. Using it now, although I might have to go
+ windows_81_initialized = true;
+ }
+ if (!windows_81) {
+ random += 0x10000000000UL;
+ }
#elif defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
// This range is copied from the TSan source, but works for all tools.
random &= 0x007fffffffffUL;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698