From f697412ff81a6d6a4a9866abce93f1f20a68330f Mon Sep 17 00:00:00 2001 From: Pawel Dziepak Date: Wed, 3 Apr 2013 22:26:07 +0200 Subject: [PATCH] vm: place commpage and team data near the top of user address space Placing commpage and team user data somewhere at the top of the user accessible virtual address space prevents these areas from conflicting with elf images that require to be mapped at exact address (in most cases: runtime_loader). --- headers/private/kernel/arch/arm/arch_kernel.h | 2 +- headers/private/kernel/arch/m68k/arch_kernel.h | 2 +- headers/private/kernel/arch/mipsel/arch_kernel.h | 2 +- headers/private/kernel/arch/ppc/arch_kernel.h | 2 +- headers/private/kernel/arch/x86/arch_kernel.h | 4 ++-- src/system/kernel/commpage.cpp | 3 ++- src/system/kernel/team.cpp | 10 +++++++--- 7 files changed, 15 insertions(+), 10 deletions(-) diff --git a/headers/private/kernel/arch/arm/arch_kernel.h b/headers/private/kernel/arch/arm/arch_kernel.h index 44a05e74a6..766ab42b10 100644 --- a/headers/private/kernel/arch/arm/arch_kernel.h +++ b/headers/private/kernel/arch/arm/arch_kernel.h @@ -25,7 +25,7 @@ #define USER_SIZE (0x80000000 - (0x10000 + 0x100000)) #define USER_TOP (USER_BASE + (USER_SIZE - 1)) -#define KERNEL_USER_DATA_BASE 0x6fff0000 +#define KERNEL_USER_DATA_BASE 0x60000000 #define USER_STACK_REGION 0x70000000 #define USER_STACK_REGION_SIZE ((USER_TOP - USER_STACK_REGION) + 1) diff --git a/headers/private/kernel/arch/m68k/arch_kernel.h b/headers/private/kernel/arch/m68k/arch_kernel.h index 7f9806999a..cef14fb2f0 100644 --- a/headers/private/kernel/arch/m68k/arch_kernel.h +++ b/headers/private/kernel/arch/m68k/arch_kernel.h @@ -25,7 +25,7 @@ #define USER_SIZE (0x80000000 - (0x10000 + 0x100000)) #define USER_TOP (USER_BASE + (USER_SIZE - 1)) -#define KERNEL_USER_DATA_BASE 0x6fff0000 +#define KERNEL_USER_DATA_BASE 0x60000000 #define USER_STACK_REGION 0x70000000 #define USER_STACK_REGION_SIZE ((USER_TOP - USER_STACK_REGION) + 1) diff --git a/headers/private/kernel/arch/mipsel/arch_kernel.h b/headers/private/kernel/arch/mipsel/arch_kernel.h index 42f3c8fbaf..237459177d 100644 --- a/headers/private/kernel/arch/mipsel/arch_kernel.h +++ b/headers/private/kernel/arch/mipsel/arch_kernel.h @@ -28,7 +28,7 @@ #define USER_SIZE (0x80000000 - (0x10000 + 0x100000)) #define USER_TOP (USER_BASE + (USER_SIZE - 1)) -#define KERNEL_USER_DATA_BASE 0x6fff0000 +#define KERNEL_USER_DATA_BASE 0x60000000 #define USER_STACK_REGION 0x70000000 #define USER_STACK_REGION_SIZE ((USER_TOP - USER_STACK_REGION) + 1) diff --git a/headers/private/kernel/arch/ppc/arch_kernel.h b/headers/private/kernel/arch/ppc/arch_kernel.h index c7d448084b..803a9aade7 100644 --- a/headers/private/kernel/arch/ppc/arch_kernel.h +++ b/headers/private/kernel/arch/ppc/arch_kernel.h @@ -25,7 +25,7 @@ #define USER_SIZE (0x80000000 - (0x10000 + 0x100000)) #define USER_TOP (USER_BASE + (USER_SIZE - 1)) -#define KERNEL_USER_DATA_BASE 0x6fff0000 +#define KERNEL_USER_DATA_BASE 0x60000000 #define USER_STACK_REGION 0x70000000 #define USER_STACK_REGION_SIZE ((USER_TOP - USER_STACK_REGION) + 1) diff --git a/headers/private/kernel/arch/x86/arch_kernel.h b/headers/private/kernel/arch/x86/arch_kernel.h index 02f9b1588c..9736e0943a 100644 --- a/headers/private/kernel/arch/x86/arch_kernel.h +++ b/headers/private/kernel/arch/x86/arch_kernel.h @@ -48,7 +48,7 @@ #define USER_SIZE (0x800000000000 - 0x200000) #define USER_TOP (USER_BASE + (USER_SIZE - 1)) -#define KERNEL_USER_DATA_BASE 0x7fffefff0000 +#define KERNEL_USER_DATA_BASE 0x7fffe0000000 #define USER_STACK_REGION 0x7ffff0000000 #define USER_STACK_REGION_SIZE ((USER_TOP - USER_STACK_REGION) + 1) @@ -76,7 +76,7 @@ #define USER_SIZE (KERNEL_BASE - 0x10000) #define USER_TOP (USER_BASE + (USER_SIZE - 1)) -#define KERNEL_USER_DATA_BASE 0x6fff0000 +#define KERNEL_USER_DATA_BASE 0x60000000 #define USER_STACK_REGION 0x70000000 #define USER_STACK_REGION_SIZE ((USER_TOP - USER_STACK_REGION) + 1) diff --git a/src/system/kernel/commpage.cpp b/src/system/kernel/commpage.cpp index 3172dd927e..c54a674b07 100644 --- a/src/system/kernel/commpage.cpp +++ b/src/system/kernel/commpage.cpp @@ -54,8 +54,9 @@ get_commpage_image() area_id clone_commpage_area(team_id team, void** address) { + *address = (void*)KERNEL_USER_DATA_BASE; return vm_clone_area(team, "commpage", address, - B_RANDOMIZED_ANY_ADDRESS, B_READ_AREA | B_EXECUTE_AREA | B_KERNEL_AREA, + B_RANDOMIZED_BASE_ADDRESS, B_READ_AREA | B_EXECUTE_AREA | B_KERNEL_AREA, REGION_PRIVATE_MAP, sCommPageArea, true); } diff --git a/src/system/kernel/team.cpp b/src/system/kernel/team.cpp index da98e04096..d0d68d8c62 100644 --- a/src/system/kernel/team.cpp +++ b/src/system/kernel/team.cpp @@ -1338,8 +1338,10 @@ create_team_user_data(Team* team, void* exactAddress = NULL) if (exactAddress != NULL) { address = exactAddress; addressSpec = B_EXACT_ADDRESS; - } else + } else { + address = (void*)KERNEL_USER_DATA_BASE; addressSpec = B_RANDOMIZED_BASE_ADDRESS; + } status_t result = vm_reserve_address_range(team->id, &address, addressSpec, kTeamUserDataReservedSize, RESERVED_AVOID_BASE); @@ -1351,8 +1353,10 @@ create_team_user_data(Team* team, void* exactAddress = NULL) else virtualRestrictions.address = address; virtualRestrictions.address_specification = B_EXACT_ADDRESS; - } else - virtualRestrictions.address_specification = B_RANDOMIZED_ANY_ADDRESS; + } else { + virtualRestrictions.address = (void*)KERNEL_USER_DATA_BASE; + virtualRestrictions.address_specification = B_RANDOMIZED_BASE_ADDRESS; + } physical_address_restrictions physicalRestrictions = {}; team->user_data_area = create_area_etc(team->id, "user area",