From 8f149016fb5fa70620273b23dafb4a586c111787 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Tue, 1 Jul 2025 00:26:29 -0400 Subject: [PATCH] kernel/arch: Put KERNEL_USER_DATA_BASE at USER_STACK_REGION. x86_64 already does this and it seems to work fine. Since stack areas grow downwards and should always have a guard page, overruns shouldn't be too much of a concern (for that matter, randomization still makes a difference here also, it seems.) This allows us to regain another ~256 MB or so of contiguous address space (areas smaller than that could still be inserted in the 0x6.. to 0x7.. block, but if you had 10MB of free address space below 0x6.., and 246MB above it, you couldn't allocate a 256MB block.) Part of #19592. --- headers/private/kernel/arch/arm/arch_kernel.h | 4 ++-- headers/private/kernel/arch/m68k/arch_kernel.h | 4 ++-- headers/private/kernel/arch/mipsel/arch_kernel.h | 4 ++-- headers/private/kernel/arch/ppc/arch_kernel.h | 4 ++-- headers/private/kernel/arch/x86/arch_kernel.h | 5 ++--- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/headers/private/kernel/arch/arm/arch_kernel.h b/headers/private/kernel/arch/arm/arch_kernel.h index 29706219ad..153fa6768f 100644 --- a/headers/private/kernel/arch/arm/arch_kernel.h +++ b/headers/private/kernel/arch/arm/arch_kernel.h @@ -27,8 +27,8 @@ #define USER_SIZE (0x80000000 - (0x10000 + USER_BASE)) #define USER_TOP (USER_BASE + (USER_SIZE - 1)) -#define KERNEL_USER_DATA_BASE 0x60000000 -#define USER_STACK_REGION 0x70000000 +#define KERNEL_USER_DATA_BASE 0x70000000 +#define USER_STACK_REGION 0x70000000 #define USER_STACK_REGION_SIZE ((USER_TOP - USER_STACK_REGION) + 1) #endif /* _KERNEL_ARCH_ARM_KERNEL_H */ diff --git a/headers/private/kernel/arch/m68k/arch_kernel.h b/headers/private/kernel/arch/m68k/arch_kernel.h index 1703e9734e..10a3651ab3 100644 --- a/headers/private/kernel/arch/m68k/arch_kernel.h +++ b/headers/private/kernel/arch/m68k/arch_kernel.h @@ -25,8 +25,8 @@ #define USER_SIZE (0x80000000 - (0x10000 + USER_BASE)) #define USER_TOP (USER_BASE + (USER_SIZE - 1)) -#define KERNEL_USER_DATA_BASE 0x60000000 -#define USER_STACK_REGION 0x70000000 +#define KERNEL_USER_DATA_BASE 0x70000000 +#define USER_STACK_REGION 0x70000000 #define USER_STACK_REGION_SIZE ((USER_TOP - USER_STACK_REGION) + 1) #endif /* _KERNEL_ARCH_M68K_KERNEL_H */ diff --git a/headers/private/kernel/arch/mipsel/arch_kernel.h b/headers/private/kernel/arch/mipsel/arch_kernel.h index 47da8ba256..998ba8fbc9 100644 --- a/headers/private/kernel/arch/mipsel/arch_kernel.h +++ b/headers/private/kernel/arch/mipsel/arch_kernel.h @@ -28,8 +28,8 @@ #define USER_SIZE (0x80000000 - (0x10000 + USER_BASE)) #define USER_TOP (USER_BASE + (USER_SIZE - 1)) -#define KERNEL_USER_DATA_BASE 0x60000000 -#define USER_STACK_REGION 0x70000000 +#define KERNEL_USER_DATA_BASE 0x70000000 +#define USER_STACK_REGION 0x70000000 #define USER_STACK_REGION_SIZE ((USER_TOP - USER_STACK_REGION) + 1) #endif /* _KERNEL_ARCH_MIPSEL_KERNEL_H */ diff --git a/headers/private/kernel/arch/ppc/arch_kernel.h b/headers/private/kernel/arch/ppc/arch_kernel.h index 66d842f4f9..63aec29acd 100644 --- a/headers/private/kernel/arch/ppc/arch_kernel.h +++ b/headers/private/kernel/arch/ppc/arch_kernel.h @@ -25,8 +25,8 @@ #define USER_SIZE (0x80000000 - (0x10000 + USER_BASE)) #define USER_TOP (USER_BASE + (USER_SIZE - 1)) -#define KERNEL_USER_DATA_BASE 0x60000000 -#define USER_STACK_REGION 0x70000000 +#define KERNEL_USER_DATA_BASE 0x70000000 +#define USER_STACK_REGION 0x70000000 #define USER_STACK_REGION_SIZE ((USER_TOP - USER_STACK_REGION) + 1) #endif /* _KERNEL_ARCH_PPC_KERNEL_H */ diff --git a/headers/private/kernel/arch/x86/arch_kernel.h b/headers/private/kernel/arch/x86/arch_kernel.h index f3ea30c4a2..8b8f82d370 100644 --- a/headers/private/kernel/arch/x86/arch_kernel.h +++ b/headers/private/kernel/arch/x86/arch_kernel.h @@ -61,8 +61,7 @@ #define USER32_SIZE 0x100000000 #define USER32_TOP (USER_BASE + (USER32_SIZE - 1)) -#define KERNEL_USER32_DATA_BASE 0x60000000 - +#define KERNEL_USER32_DATA_BASE 0x70000000 #define USER32_STACK_REGION 0x70000000 #define USER32_STACK_REGION_SIZE ((USER32_TOP - USER32_STACK_REGION) + 1) @@ -89,7 +88,7 @@ #define USER_SIZE (KERNEL_BASE - (0x10000 + USER_BASE)) #define USER_TOP (USER_BASE + (USER_SIZE - 1)) -#define KERNEL_USER_DATA_BASE 0x60000000 +#define KERNEL_USER_DATA_BASE 0x70000000 #define USER_STACK_REGION 0x70000000 #define USER_STACK_REGION_SIZE ((USER_TOP - USER_STACK_REGION) + 1)