Changeset View
Changeset View
Standalone View
Standalone View
sys/vm/vm_map.c
Show First 20 Lines • Show All 1,974 Lines • ▼ Show 20 Lines | |||||
static const int aslr_pages_rnd_64[2] = {0x1000, 0x10}; | static const int aslr_pages_rnd_64[2] = {0x1000, 0x10}; | ||||
static const int aslr_pages_rnd_32[2] = {0x100, 0x4}; | static const int aslr_pages_rnd_32[2] = {0x100, 0x4}; | ||||
static int cluster_anon = 1; | static int cluster_anon = 1; | ||||
SYSCTL_INT(_vm, OID_AUTO, cluster_anon, CTLFLAG_RW, | SYSCTL_INT(_vm, OID_AUTO, cluster_anon, CTLFLAG_RW, | ||||
&cluster_anon, 0, | &cluster_anon, 0, | ||||
"Cluster anonymous mappings: 0 = no, 1 = yes if no hint, 2 = always"); | "Cluster anonymous mappings: 0 = no, 1 = yes if no hint, 2 = always"); | ||||
static int anon_low_pref = 0; | |||||
SYSCTL_INT(_vm, OID_AUTO, anon_low_pref, CTLFLAG_RW, | |||||
&anon_low_pref, 0, | |||||
"Prefer lower addresses when clustering anonymous mappings: 0 = no, 1 = yes"); | |||||
kib: I think that the description is not correct. For me, the function is like "Prefer lower… | |||||
austin.zhang_dell.comAuthorUnsubmitted Done Inline Actionsthis option doesn't change the value of cluster, so the cluster logic should be still applied. if (try == 1 && en_aslr && !cluster){ } else { //still enter this branch } update_anon would update the value of following curr_min_addr, without this logic, lower address is preferred. austin.zhang_dell.com: this option doesn't change the value of `cluster`, so the cluster logic should be still applied. | |||||
kibUnsubmitted Not Done Inline ActionsIt does change, but I suggest something different. Please try D39845 kib: It does change, but I suggest something different. Please try D39845 | |||||
static bool | static bool | ||||
clustering_anon_allowed(vm_offset_t addr) | clustering_anon_allowed(vm_offset_t addr) | ||||
{ | { | ||||
switch (cluster_anon) { | switch (cluster_anon) { | ||||
case 0: | case 0: | ||||
return (false); | return (false); | ||||
case 1: | case 1: | ||||
▲ Show 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | if (en_aslr && min_addr == 0 && !cluster && | ||||
(map->flags & MAP_ASLR_IGNSTART) != 0) | (map->flags & MAP_ASLR_IGNSTART) != 0) | ||||
curr_min_addr = min_addr = vm_map_min(map); | curr_min_addr = min_addr = vm_map_min(map); | ||||
try = 0; | try = 0; | ||||
vm_map_lock(map); | vm_map_lock(map); | ||||
if (cluster) { | if (cluster) { | ||||
curr_min_addr = map->anon_loc; | curr_min_addr = map->anon_loc; | ||||
if (curr_min_addr == 0) | if (curr_min_addr == 0) | ||||
cluster = false; | cluster = false; | ||||
else if (anon_low_pref) | |||||
update_anon = false; | |||||
} | } | ||||
if (find_space != VMFS_NO_SPACE) { | if (find_space != VMFS_NO_SPACE) { | ||||
KASSERT(find_space == VMFS_ANY_SPACE || | KASSERT(find_space == VMFS_ANY_SPACE || | ||||
find_space == VMFS_OPTIMAL_SPACE || | find_space == VMFS_OPTIMAL_SPACE || | ||||
find_space == VMFS_SUPER_SPACE || | find_space == VMFS_SUPER_SPACE || | ||||
alignment != 0, ("unexpected VMFS flag")); | alignment != 0, ("unexpected VMFS flag")); | ||||
again: | again: | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 3,229 Lines • Show Last 20 Lines |
I think that the description is not correct. For me, the function is like "Prefer lower address over clustering for anonymous mappings"